예제 #1
0
 def test_with_api(self):
     """
     test api endpoint with default valid api key
     """
     client = APIClient(EndPoints.countries)
     response = client.get()
     assert response.code == HTTPStatus.OK, response.raw_content
예제 #2
0
 def concurrent_task(self):
     """
     function for testing cocurrent calls on countries API
     """
     client = APIClient(EndPoints.countries)
     response = client.get()
     assert response.code == HTTPStatus.OK, response.raw_content
예제 #3
0
 def test_holidays_limited_access(self):
     """
     Negative case
     test limited access on endpoint, endpoint is limited is one past year
     """
     client = APIClient(EndPoints.holidays)
     response = client.get(params={'country': 'BE', 'year': 2018})
     assert response.code == HTTPStatus.PAYMENT_REQUIRED, "Expected PAYMENT_REQUIRED"
예제 #4
0
 def test_incorrect_api(self):
     """
     test api endpoint with malformed api key
     """
     client = APIClient(EndPoints.countries,
                        default_api_key=False,
                        api_key="2a5e5e8f-1a10-48bf-8be7-0555d2c1hdg")
     response = client.get()
     assert response.code == HTTPStatus.UNAUTHORIZED, response.raw_content
예제 #5
0
 def test_without_api(self):
     """
     test api endpoint with out api key
     """
     client = APIClient(EndPoints.countries,
                        default_api_key=False,
                        api_key=None)
     response = client.get()
     assert response.code == HTTPStatus.UNAUTHORIZED, response.raw_content
예제 #6
0
 def test_search_countries(self, test_case):
     """
     test search countries
     """
     client = APIClient(EndPoints.countries)
     response = client.get(params={'search': test_case.search_term})
     assert response.code == test_case.status_code, response.raw_content
     if test_case.status_code == HTTPStatus.OK:
         content = response.json_content
         countries = content.get('countries')
         assert len(countries) == test_case.results_count, "countries count did not match"
예제 #7
0
 def test_get_countries_with_public_holidays(self, test_case):
     """
     test get countries with public holdiays
     """
     client = APIClient(EndPoints.countries)
     response = client.get(params={'public': test_case.public_holidays, 'search': test_case.search_term})
     assert response.code == test_case.status_code, response.raw_content
     if test_case.status_code == HTTPStatus.OK:
         content = response.json_content
         countries = content.get('countries')
         assert len(countries) == test_case.results_count, "countries count did not match"
예제 #8
0
 def test_get_countries(self):
     """
     test get countries
     """
     client = APIClient(EndPoints.countries)
     response = client.get()
     assert response.code == HTTPStatus.OK, response.raw_content
     content = response.json_content
     countries = content.get('countries')
     assert countries, f"expected contries list, found None"
     assert len(countries) == self.ALL_COUNTRIES, "countries count did not match"
예제 #9
0
 def test_previous_upcoming_holiday_for_given_date(self, test_case):
     """
     Negative case
     test previous & upcoming holiday per country, by year, by month, by day
     """
     client = APIClient(EndPoints.holidays)
     response = client.get(
         params={
             'country': 'IN',
             'year': 2019,
             'month': 1,
             'day': 1,
             'previous': True,
             'upcoming': True
         })
     assert response.code == HTTPStatus.BAD_REQUEST, "Expected BAD_REQUEST"
예제 #10
0
 def test_previous_holiday_for_given_date(self, test_case):
     """
     test previous holiday per country, by year, by month, by day
     """
     client = APIClient(EndPoints.holidays)
     response = client.get(
         params={
             'country': test_case.country_code,
             'year': test_case.year,
             'month': test_case.month,
             'day': test_case.day,
             'previous': True
         })
     assert response.code == test_case.status_code
     if test_case.status_code == HTTPStatus.OK:
         holidays = response.json_content['holidays']
         assert holidays[0][
             'date'] == test_case.expected_holiday_date, "Mismatch in exepcted holiday date"
예제 #11
0
 def test_holidays_count(self, test_case):
     """
     test holidays per country, by year, by month, by day
     """
     client = APIClient(EndPoints.holidays)
     response = client.get(
         params={
             'country': test_case.country_code,
             'year': test_case.year,
             'month': test_case.month,
             'day': test_case.day
         })
     assert response.code == test_case.status_code
     if test_case.status_code == HTTPStatus.OK:
         holidays = response.json_content['holidays']
         assert len(
             holidays
         ) == test_case.results_count, "Mismatch in holidays count"
예제 #12
0
 def test_search_holiday_for_given_params(self, test_case):
     """
     test search holiday positive & negative cases. (Min 5 char is valid search term)
     """
     client = APIClient(EndPoints.holidays)
     response = client.get(
         params={
             'country': test_case.country_code,
             'year': test_case.year,
             'month': test_case.month,
             'day': test_case.day,
             'search': test_case.search_term
         })
     assert response.code == test_case.status_code
     if test_case.status_code == HTTPStatus.OK:
         holidays = response.json_content['holidays']
         assert len(
             holidays
         ) == test_case.results_count, "Mismatch in holidays count"