Exemple #1
0
    def test_when_a_country_is_selected_prefixed_with_hyphen_returns_no_error(self):
        countries = "-england"
        validator = Validator(countries, "", "", "Coventry University", "", "0", 100, "0", "en")

        output_countries, output_error_object = validator.validate_countries()

        self.assertEqual(["XG", "XH", "XI"], output_countries)
        self.assertEqual([], output_error_object)
Exemple #2
0
    def test_when_multiple_countries_are_selected_returns_no_error(self):
        countries = "england,wales"
        validator = Validator(countries, "", "", "Coventry University", "", "0", 100, "0", "en")

        output_countries, output_error_object = validator.validate_countries()

        self.assertEqual(["XF", "XI"], output_countries)
        self.assertEqual([], output_error_object)
Exemple #3
0
    def test_when_scotland_is_selected_returns_no_error(self):
        countries = "scotland"
        validator = Validator(countries, "", "", "Coventry University", "", "0", 100, "0", "en")

        output_countries, output_error_object = validator.validate_countries()

        self.assertEqual(["XH"], output_countries)
        self.assertEqual([], output_error_object)
Exemple #4
0
    def test_when_empty_countries_returns_no_error(self):
        countries = ""
        validator = Validator(countries, "", "", "Coventry University", "", "0", 100, "0", "en")

        output_countries, output_error_object = validator.validate_countries()

        self.assertEqual([], output_countries)
        self.assertEqual([], output_error_object)
Exemple #5
0
    def test_when_there_are_invalid_uk_countries_returns_error(self):
        countries = "bosnia,photosynthesis,england"
        validator = Validator(countries, "", "", "Coventry University", "", "0", 100, "0", "en")

        output_countries, output_error_object = validator.validate_countries()
        expected_error_object = [
            {
                "error": "invalid countries",
                "error_values": [{"countries": "bosnia,photosynthesis"}],
            }
        ]

        self.assertEqual([], output_countries)
        self.assertEqual(expected_error_object, output_error_object)
Exemple #6
0
    def test_when_there_are_duplicate_countries_returns_error(self):
        countries = "england,-england"
        validator = Validator(countries, "", "", "Coventry University", "", "0", 100, "0", "en")

        output_countries, output_error_object = validator.validate_countries()
        expected_error_object = [
            {
                "error": "use of the same countries more than once",
                "error_values": [{"countries": "england"}],
            }
        ]

        self.assertEqual([], output_countries)
        self.assertEqual(expected_error_object, output_error_object)