def test_version_heeader_provided_uppercase(self): session = DesignRuleSessionFactory( test_suite__api_endpoint="https://maykinmedia.nl/") with requests_mock.Mocker() as mock: dir_path = os.path.dirname(os.path.realpath(__file__)) with open(os.path.join(dir_path, "..", "files", "good.json")) as json_file: mock.get('https://maykinmedia.nl/openapi.json', text=json_file.read(), headers={"API-VERSION": "1.1.1"}) response = requests.get("https://maykinmedia.nl/openapi.json") result = run_20200709_api_57(session, response=response) self.assertEqual(DesignRuleResult.objects.count(), 1) self.assertTrue(result.success) self.assertIsNone(result.errors)
def test_design_rule_already_exists(self): session = DesignRuleSessionFactory( test_suite__api_endpoint="https://maykinmedia.nl/") pre_result = DesignRuleResultFactory( design_rule=session, rule_type=DesignRuleChoices.api_51_20200709) with requests_mock.Mocker() as mock: dir_path = os.path.dirname(os.path.realpath(__file__)) with open(os.path.join(dir_path, "..", "files", "good.json")) as json_file: mock.get('https://maykinmedia.nl/openapi.json', text=json_file.read()) response = requests.get("https://maykinmedia.nl/openapi.json") result = run_20200709_api_57(session, response=response) self.assertEqual(DesignRuleResult.objects.count(), 1) self.assertEqual(pre_result.pk, result.pk)
def test_no_version_heeader_provided(self): session = DesignRuleSessionFactory( test_suite__api_endpoint="https://maykinmedia.nl/") with requests_mock.Mocker() as mock: dir_path = os.path.dirname(os.path.realpath(__file__)) with open(os.path.join(dir_path, "..", "files", "good.json")) as json_file: mock.get('https://maykinmedia.nl/openapi.json', text=json_file.read()) response = requests.get("https://maykinmedia.nl/openapi.json") result = run_20200709_api_57(session, response=response) self.assertEqual(DesignRuleResult.objects.count(), 1) self.assertFalse(result.success) self.assertEqual(result.errors, [ _("The headers is missing. Make sure that the 'API-Version' is given." ) ])