def test_classify_empty_time(self, admin_client): """ If the request_time isn't provided, default to the current time. """ locale, other_locale = LocaleFactory.create_batch(2) country = CountryFactory() release_channel = ReleaseChannelFactory() matching_recipe = RecipeFactory( enabled=True, locales=[locale], countries=[country], release_channels=[release_channel], start_time=aware_datetime(2016, 1, 1), end_time=aware_datetime(2016, 1, 3), ) RecipeFactory(locales=[other_locale]) # Non-matching with patch('normandy.classifier.middleware.timezone') as timezone: timezone.now.return_value = aware_datetime(2016, 1, 2) response = admin_client.get('/admin/classifier_preview', { 'locale': locale.code, 'release_channel': release_channel.slug, 'country': country.code, 'request_time_0': '', 'request_time_1': '', }) assert response.status_code == 200 assert list(response.context['bundle']) == [matching_recipe]
def test_classify(self, admin_client): locale, other_locale = LocaleFactory.create_batch(2) country = CountryFactory() release_channel = ReleaseChannelFactory() matching_recipe = RecipeFactory( enabled=True, locales=[locale], countries=[country], release_channels=[release_channel], start_time=aware_datetime(2016, 1, 1), end_time=aware_datetime(2016, 1, 3), ) RecipeFactory(locales=[other_locale]) # Non-matching response = admin_client.get('/admin/classifier_preview', { 'locale': locale.code, 'release_channel': release_channel.slug, 'country': country.code, 'request_time_0': '2016-01-02', 'request_time_1': '00:00:00', }) assert response.status_code == 200 assert list(response.context['bundle']) == [matching_recipe]
def test_classify_empty_time(self, admin_client): """ If the request_time isn't provided, default to the current time. """ locale, other_locale = LocaleFactory.create_batch(2) country = CountryFactory() release_channel = ReleaseChannelFactory() matching_recipe = RecipeFactory( enabled=True, locales=[locale], countries=[country], release_channels=[release_channel], start_time=aware_datetime(2016, 1, 1), end_time=aware_datetime(2016, 1, 3), ) RecipeFactory(locales=[other_locale]) # Non-matching with patch('normandy.classifier.middleware.timezone') as timezone: timezone.now.return_value = aware_datetime(2016, 1, 2) response = admin_client.get( '/admin/classifier_preview', { 'locale': locale.code, 'release_channel': release_channel.slug, 'country': country.code, 'request_time_0': '', 'request_time_1': '', }) assert response.status_code == 200 assert list(response.context['bundle']) == [matching_recipe]
def test_classify(self, admin_client): locale, other_locale = LocaleFactory.create_batch(2) country = CountryFactory() release_channel = ReleaseChannelFactory() matching_recipe = RecipeFactory( enabled=True, locales=[locale], countries=[country], release_channels=[release_channel], start_time=aware_datetime(2016, 1, 1), end_time=aware_datetime(2016, 1, 3), ) RecipeFactory(locales=[other_locale]) # Non-matching response = admin_client.get( '/admin/classifier_preview', { 'locale': locale.code, 'release_channel': release_channel.slug, 'country': country.code, 'request_time_0': '2016-01-02', 'request_time_1': '00:00:00', }) assert response.status_code == 200 assert list(response.context['bundle']) == [matching_recipe]
def test_it_works(self, api_client): get_country_code_patch = patch("normandy.recipes.models.get_country_code") timezone_patch = patch("normandy.base.middleware.timezone") with get_country_code_patch as get_country_code, timezone_patch as timezone: get_country_code.return_value = "us" timezone.now.return_value = aware_datetime(2016, 1, 1) res = api_client.get("/api/v1/classify_client/") assert res.status_code == 200 assert res.data == {"country": "us", "request_time": "2016-01-01T00:00:00Z"}
def test_it_works(self, api_client): get_country_code_patch = patch('normandy.recipes.models.get_country_code') timezone_patch = patch('normandy.base.middleware.timezone') with get_country_code_patch as get_country_code, timezone_patch as timezone: get_country_code.return_value = 'us' timezone.now.return_value = aware_datetime(2016, 1, 1) res = api_client.get('/api/v1/classify_client/') assert res.status_code == 200 assert res.data == { 'country': 'us', 'request_time': '2016-01-01T00:00:00Z', }
def test_it_works(self, api_client): get_country_code_patch = patch( 'normandy.recipes.models.get_country_code') timezone_patch = patch('normandy.base.middleware.timezone') with get_country_code_patch as get_country_code, timezone_patch as timezone: get_country_code.return_value = 'us' timezone.now.return_value = aware_datetime(2016, 1, 1) res = api_client.get('/api/v1/classify_client/') assert res.status_code == 200 assert res.data == { 'country': 'us', 'request_time': '2016-01-01T00:00:00Z', }