There was huge shock yesterday evening when it was announced that Theresa May had made Boris Johnson her foreign secretary.

The announcement was immediately met with a mixture of disbelief, amusement and horror. After all, this is the man who recently accused the current US president of having an "ancestral dislike" for Britain and who once compared Obama's likely successor Hilary Clinton to a "sadistic nurse in a mental hospital."

The idea of handing such a delicate and important job to a man who likened the EU to Hitler, backed Assad and Putin in Syria and who previously used the racially offensive terms of "coolies" and "piccaninnies," seems brave at best and utterly disastrous at worst.

Yet making Johnson foreign secretary is not quite such a leap in the dark as it might first appear. In fact, although little noticed in Westminster, Boris has spent the past four years preparing himself for just such a position.

Shortly after winning re-election as London mayor in 2012, Boris announced that he would embark on a series of "prime ministerial" international trips in order to drum up business for London.

In typical Boris-style, the announcement involved going back on his own previous criticism of his former opponent Ken Livingstone for planning to do just the same. "Londoners want a mayor for London, not a mayor for the world," Johnson's spokesperson said just three months earlier when Livingstone announced almost identical plans.

Despite his apparent previous opposition to such an international role, Johnson immediately threw himself into the job, announcing plans for trips to Brazil, the Middle East and China. Further trips to Israel, the US and Iraq followed.

Although ostensibly sold as being attempts to promote London businesses, the trips appeared to be at least as much about promoting Boris's own personal brand as they were about the capital. On one trip Boris, accompanied by a journalist from the Sun, tried desperately to arrange a photo shoot on the front line between Kurdish fighters and Isis, only to be blocked by the Foreign Office. In the end a slightly embarrassing photo-op of Boris lying fully-suited in the dirt with a kalashnikov, was arranged in a Kurdish training camp.

A freedom of information request later revealed that Foreign Office staff had to intervene to pick up Johnson's unpaid hotel bar tab for the trip, while emails also revealed Johnson's desire to increase the amount of "sightseeing" on the trip and add that staff had to step in to prevent Johnson from driving a sports car out of a showroom.

Other trips were similarly shambolic. A visit to Palestine had to be cut short on security grounds after he made what were described as “inaccurate, misinformed and disrespectful remarks” about the Palestinian-led Boycott, Divest, and Sanctions (BDS) movement.  Another visit to Japan, ostensibly sold as an attempt to sell British technology to the country, descended into farce after he boasted in a press conference about London's contactless Oyster card technology.

“I can get on the Tube, I can get on a bus and just wave it in the general direction of the cashless receiver and, completely painlessly, very small amounts are deducted from my bank account,” he told a distinctly non-plussed audience.

When a member of the audience pointed out that such technology had been used in Tokyo since 2001, a surprised Johnson replied: "Really? Doesn't this undermine my whole raison d’être for being here?" Johnson quickly salvaged the trip however, after he was later filmed ruthlessly rugby-tackling a small child. The footage went instantly viral worldwide and helped turn Boris into a household name across the globe. This was clearly far more vaulable to the mayor than any deal on travel cards.

The whiff of cronyism has also tended to follow Johnson on his trips. When Boris embarked on a tour of the Middle East supposedly to promote British business, there was outrage after he invited his former campaign manager Lynton Crosby to join him. Quite what advantage there was to be had for London, in its mayor taking an Australian election strategist on a tour of Middle East dictatorships, wasn't entirely clear. Eyebrows were also raised by the Foreign Office, after he invited Conservative MP Nadhim Zahawi whose parents happen to be Kurdish, to accompany him to the region.

Another running theme of Boris's trips as mayor, were his repeated attempts to promote interest in London's new Routemaster-style buses. The unwieldy and overheated vehicles, further purchases of which have now been cancelled by Johnson's successor Sadiq Khan, were highly expensive to design and produce. However, they were sold to Londoners as being a design classic which would be snapped up by other world cities. In 2013, Johnson told the Evening Standard that he expected "hundreds" of the vehicles to be sold in the Far East. When Johnson embarked on an Asian tour, a specially imported model of the bus was sent over to the region. However, despite all this expense there were no takers. Explaining their reluctance to purchase the buses, one potential buyer in Hong Long explained: "KMB has no intention of introducing the New Bus for London to Hong Kong in view of the lack of an air-conditioning, necessary given Hong Kong’s climate, and the open design of the rear door, which does not meet the operating situation". City Hall have yet to report a single buyer.

Johnson's appointment as foreign secretary is not quite as inexplicable as many have suggested. He is a well-known figure who has flown the flag for the UK, both during the Olympics and during his own trips as mayor.

But over the next few years Britain faces huge international challenges as it tries to find a new place for itself in the world. Navigating those choppy waters requires a steady hand and a masterful diplomatic touch. All the evidence from Boris's career so far is that he has neither.