diff options
author | Sergey Yershov <syershov@maps.me> | 2016-10-19 19:07:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-19 19:07:31 +0300 |
commit | 36825ee0250dd7e05fa9b0a8f60bd382e8665203 (patch) | |
tree | 56bf3c76fdd5c96b478a4fe378ef2480be3b658f | |
parent | b16cb4f4d2f39c7aca1ad5a66e106bdd1e2efb52 (diff) | |
parent | 61d8f1effdc1509b8772872d2a7da2d3b2fa1564 (diff) |
Merge pull request #4531 from Zverik/fbt2
[tests] Fix booking tests again
-rw-r--r-- | partners_api/booking_api.cpp | 4 | ||||
-rw-r--r-- | partners_api/booking_api.hpp | 2 | ||||
-rw-r--r-- | partners_api/partners_api_tests/booking_tests.cpp | 9 |
3 files changed, 10 insertions, 5 deletions
diff --git a/partners_api/booking_api.cpp b/partners_api/booking_api.cpp index b634411716..6bb2dc1a75 100644 --- a/partners_api/booking_api.cpp +++ b/partners_api/booking_api.cpp @@ -13,7 +13,7 @@ char const BookingApi::kDefaultCurrency[1]; -BookingApi::BookingApi() : m_affiliateId(BOOKING_AFFILIATE_ID) +BookingApi::BookingApi() : m_affiliateId(BOOKING_AFFILIATE_ID), m_testingMode(false) { stringstream ss; ss << BOOKING_KEY << ":" << BOOKING_SECRET; @@ -266,6 +266,8 @@ string BookingApi::MakeApiUrl(string const & func, bool firstRun = true; for (auto const & param : params) ss << (firstRun ? firstRun = false, "" : "&") << param.first << "=" << param.second; + if (m_testingMode) + ss << "&show_test=1"; return ss.str(); } diff --git a/partners_api/booking_api.hpp b/partners_api/booking_api.hpp index db9b9c41c4..4e92a8ca83 100644 --- a/partners_api/booking_api.hpp +++ b/partners_api/booking_api.hpp @@ -14,6 +14,7 @@ class BookingApi { string m_affiliateId; string m_apiUrl; + bool m_testingMode; public: struct HotelPhotoUrls @@ -118,6 +119,7 @@ public: BookingApi(); string GetBookingUrl(string const & baseUrl, string const & lang = string()) const; string GetDescriptionUrl(string const & baseUrl, string const & lang = string()) const; + inline void SetTestingMode(bool testing) { m_testingMode = testing; } // Real-time information methods (used for retriving rapidly changing information). // These methods send requests directly to Booking. diff --git a/partners_api/partners_api_tests/booking_tests.cpp b/partners_api/partners_api_tests/booking_tests.cpp index 9d055a9fe3..05b28b25ae 100644 --- a/partners_api/partners_api_tests/booking_tests.cpp +++ b/partners_api/partners_api_tests/booking_tests.cpp @@ -13,7 +13,8 @@ UNIT_TEST(Booking_SmokeTest) UNIT_TEST(Booking_GetMinPrice) { BookingApi api; - constexpr string kHotelId = "245721"; // Izmailovo Gamma, 996 rooms + api.SetTestingMode(true); + string const kHotelId = "98251"; // Special hotel id for testing. { string price; @@ -29,13 +30,13 @@ UNIT_TEST(Booking_GetMinPrice) TEST(!price.empty(), ()); TEST(!currency.empty(), ()); - TEST_EQUAL(currency, "RUB", ()); + TEST_EQUAL(currency, "USD", ()); } { string price; string currency; - api.GetMinPrice(kHotelId, "EUR", [&price, ¤cy](string const & val, string const & curr) + api.GetMinPrice(kHotelId, "RUB", [&price, ¤cy](string const & val, string const & curr) { price = val; currency = curr; @@ -45,7 +46,7 @@ UNIT_TEST(Booking_GetMinPrice) TEST(!price.empty(), ()); TEST(!currency.empty(), ()); - TEST_EQUAL(currency, "EUR", ()); + TEST_EQUAL(currency, "RUB", ()); } { |