예제 #1
0
    def test_no_json_provided(self):
        session = DesignRuleSessionFactory(test_suite__api_endpoint="https://maykinmedia.nl/api/v1")

        result = run_20200709_api_48(session, "https://maykinmedia.nl/api/v1")
        self.assertEqual(DesignRuleResult.objects.count(), 1)
        self.assertFalse(result.success)
        self.assertEqual(result.errors, [_("The API did not give a valid JSON output.")])
예제 #2
0
    def test_design_rule_already_exists(self):
        session = DesignRuleSessionFactory(test_suite__api_endpoint="https://maykinmedia.nl/api/v1")
        pre_result = DesignRuleResultFactory(design_rule=session, rule_type=DesignRuleChoices.api_48_20200709)

        result = run_20200709_api_48(session, "https://maykinmedia.nl/api/v1")
        self.assertEqual(DesignRuleResult.objects.count(), 1)
        self.assertEqual(pre_result.pk, result.pk)
예제 #3
0
    def test_with_no_paths(self):
        dir_path = os.path.dirname(os.path.realpath(__file__))
        with open(os.path.join(dir_path, "..", "files", "no_paths.json")) as json_file:
            session = DesignRuleSessionFactory(test_suite__api_endpoint="https://maykinmedia.nl/api/v1", json_result=json.loads(json_file.read()))

        result = run_20200709_api_48(session, "https://maykinmedia.nl/api/v1")
        self.assertEqual(DesignRuleResult.objects.count(), 1)
        self.assertFalse(result.success)
        self.assertEqual(result.errors, [_("There are no paths found")])
예제 #4
0
    def test_with_trailing_slashes(self):
        dir_path = os.path.dirname(os.path.realpath(__file__))
        with open(os.path.join(dir_path, "..", "files", "with_trailing_slashes.json")) as json_file:
            session = DesignRuleSessionFactory(test_suite__api_endpoint="https://maykinmedia.nl/api/v1", json_result=json.loads(json_file.read()))

        result = run_20200709_api_48(session, "https://maykinmedia.nl/api/v1")
        errors = [
            _("Path: {} ends with a slash").format("/designrule-session/"),
            _("Path: {} ends with a slash").format("/designrule-session/{id}/"),
        ]
        self.assertEqual(DesignRuleResult.objects.count(), 1)
        self.assertFalse(result.success)
        self.assertEqual(result.errors, errors)
예제 #5
0
    def test_no_trailing_slashes(self):
        dir_path = os.path.dirname(os.path.realpath(__file__))
        with open(os.path.join(dir_path, "..", "files", "good.json")) as json_file:
            session = DesignRuleSessionFactory(test_suite__api_endpoint="https://maykinmedia.nl/api/v1", json_result=json.loads(json_file.read()))

        with requests_mock.Mocker() as mock:
            mock.get('https://maykinmedia.nl/api/v1/designrule-session/', status_code=404)
            mock.get('https://maykinmedia.nl/api/v1/designrule-session/shield/%7Buuid%7D/', status_code=404)
            mock.get('https://maykinmedia.nl/api/v1/designrule-session/%7Buuid%7D/', status_code=404)
            mock.get('https://maykinmedia.nl/api/v1/designrule-testsuite/', status_code=404)
            mock.get('https://maykinmedia.nl/api/v1/designrule-testsuite/%7Buuid%7D/', status_code=404)
            mock.post("https://maykinmedia.nl/api/v1/designrule-session/", status_code=404)
            mock.post("https://maykinmedia.nl/api/v1/designrule-testsuite/", status_code=404)
            mock.post("https://maykinmedia.nl/api/v1/designrule-testsuite/%7Buuid%7D/start_session/", status_code=404)

            result = run_20200709_api_48(session, "https://maykinmedia.nl/api/v1")

        self.assertEqual(DesignRuleResult.objects.count(), 1)
        self.assertTrue(result.success)
        self.assertEqual(result.errors, None)