Beispiel #1
0
 def test_basic_curriculum_areas_loader_config(self):
     config_file = "basic-config.yaml"
     area_loader = CurriculumAreasLoader(structure_filename=config_file,
                                         base_path=self.base_path)
     area_loader.load()
     self.assertQuerysetEqual(CurriculumArea.objects.all(),
                              ["<CurriculumArea: Maths>"])
 def test_curriculum_areas_loader_correct_colour_value(self):
     config_file = "basic-config.yaml"
     area_loader = CurriculumAreasLoader(config_file, self.BASE_PATH)
     area_loader.load()
     self.assertEquals(
         CurriculumArea.objects.get(slug="maths").colour,
         "blue",
     )
 def test_basic_curriculum_areas_loader_config(self):
     config_file = "basic-config.yaml"
     area_loader = CurriculumAreasLoader(config_file, self.BASE_PATH)
     area_loader.load()
     self.assertQuerysetEqual(
         CurriculumArea.objects.all(),
         ["<CurriculumArea: Maths>"]
     )
 def test_curriculum_areas_loader_correct_children_number_value(self):
     config_file = "children.yaml"
     area_loader = CurriculumAreasLoader(config_file, self.BASE_PATH)
     area_loader.load()
     self.assertEquals(
         CurriculumArea.objects.get(slug="algebra").number,
         1,
     )
Beispiel #5
0
 def test_curriculum_areas_loader_correct_children_colour_value(self):
     config_file = "children.yaml"
     area_loader = CurriculumAreasLoader(structure_filename=config_file,
                                         base_path=self.base_path)
     area_loader.load()
     self.assertEquals(
         CurriculumArea.objects.get(slug="algebra").colour,
         "blue",
     )
Beispiel #6
0
 def test_curriculum_areas_loader_correct_number_value(self):
     config_file = "basic-config.yaml"
     area_loader = CurriculumAreasLoader(structure_filename=config_file,
                                         base_path=self.base_path)
     area_loader.load()
     self.assertEquals(
         CurriculumArea.objects.get(slug="maths").number,
         1,
     )
Beispiel #7
0
    def test_curriculum_areas_loader_translation(self):
        config_file = "translation.yaml"
        area_loader = CurriculumAreasLoader(structure_filename=config_file,
                                            base_path=self.base_path)
        area_loader.load()

        translated = CurriculumArea.objects.get(slug="translated")
        self.assertSetEqual(set(["en", "de"]), set(translated.languages))
        self.assertEqual("English Name", translated.name)
        with translation.override("de"):
            self.assertEqual("German Name", translated.name)
Beispiel #8
0
    def test_curriculum_areas_loader_missing_translation(self):
        config_file = "translation.yaml"
        area_loader = CurriculumAreasLoader(structure_filename=config_file,
                                            base_path=self.base_path)
        area_loader.load()

        translated = CurriculumArea.objects.get(slug="untranslated")
        self.assertSetEqual(set(["en"]), set(translated.languages))
        self.assertEqual("English Name", translated.name)
        # Check name does not fall back to english for missing translation
        with translation.override("de"):
            self.assertEqual("", translated.name)
 def test_curriculum_areas_loader_multiple_configuration(self):
     config_file = "multiple.yaml"
     area_loader = CurriculumAreasLoader(config_file, self.BASE_PATH)
     area_loader.load()
     self.assertQuerysetEqual(
         CurriculumArea.objects.all(),
         [
             "<CurriculumArea: Maths>",
             "<CurriculumArea: Maths: Algebra>",
             "<CurriculumArea: Maths: Geometry>",
             "<CurriculumArea: Science>",
             "<CurriculumArea: Art>",
         ],
         ordered=False,
     )
 def test_curriculum_areas_loader_empty_children_value(self):
     config_file = "empty-children.yaml"
     area_loader = CurriculumAreasLoader(config_file, self.BASE_PATH)
     self.assertRaises(
         MissingRequiredFieldError,
         area_loader.load,
     )
 def test_curriculum_areas_loader_missing_colour_value(self):
     config_file = "missing-colour.yaml"
     area_loader = CurriculumAreasLoader(config_file, self.BASE_PATH)
     self.assertRaises(
         MissingRequiredFieldError,
         area_loader.load,
     )
 def test_curriculum_areas_loader_empty_configuration_file(self):
     config_file = "empty.yaml"
     area_loader = CurriculumAreasLoader(config_file, self.BASE_PATH)
     self.assertRaises(
         EmptyConfigFileError,
         area_loader.load,
     )
 def test_curriculum_areas_loader_missing_configuration_file(self):
     config_file = "missing.yaml"
     area_loader = CurriculumAreasLoader(config_file, self.BASE_PATH)
     self.assertRaises(
         CouldNotFindConfigFileError,
         area_loader.load,
     )
Beispiel #14
0
 def test_curriculum_areas_loader_children_name_empty(self):
     config_file = "children-name-empty.yaml"
     area_loader = CurriculumAreasLoader(structure_filename=config_file,
                                         base_path=self.base_path)
     self.assertRaises(
         InvalidYAMLValueError,
         area_loader.load,
     )
Beispiel #15
0
 def test_curriculum_areas_loader_empty_children_value(self):
     config_file = "empty-children.yaml"
     area_loader = CurriculumAreasLoader(structure_filename=config_file,
                                         base_path=self.base_path)
     self.assertRaises(
         MissingRequiredFieldError,
         area_loader.load,
     )
Beispiel #16
0
 def test_curriculum_areas_loader_empty_configuration_file(self):
     config_file = "empty.yaml"
     area_loader = CurriculumAreasLoader(structure_filename=config_file,
                                         base_path=self.base_path)
     self.assertRaises(
         EmptyYAMLFileError,
         area_loader.load,
     )
Beispiel #17
0
 def test_curriculum_areas_loader_missing_configuration_file(self):
     config_file = "missing.yaml"
     area_loader = CurriculumAreasLoader(structure_filename=config_file,
                                         base_path=self.base_path)
     self.assertRaises(
         CouldNotFindYAMLFileError,
         area_loader.load,
     )
Beispiel #18
0
 def test_curriculum_areas_loader_missing_number_value(self):
     config_file = "missing-number.yaml"
     area_loader = CurriculumAreasLoader(structure_filename=config_file,
                                         base_path=self.base_path)
     self.assertRaises(
         MissingRequiredFieldError,
         area_loader.load,
     )
 def test_curriculum_areas_loader_correct_children_value(self):
     config_file = "children.yaml"
     area_loader = CurriculumAreasLoader(config_file, self.BASE_PATH)
     area_loader.load()
     self.assertQuerysetEqual(
         CurriculumArea.objects.all(),
         [
             "<CurriculumArea: Maths>",
             "<CurriculumArea: Maths: Algebra>",
             "<CurriculumArea: Maths: Geometry>",
         ],
         ordered=False,
     )
     parent = CurriculumArea.objects.get(slug="maths")
     self.assertQuerysetEqual(
         CurriculumArea.objects.filter(parent=parent),
         [
             "<CurriculumArea: Maths: Algebra>",
             "<CurriculumArea: Maths: Geometry>",
         ],
         ordered=False,
     )
Beispiel #20
0
 def create_curriculum_areas_loader(self, **kwargs):
     """Create curriculum area loader."""
     return CurriculumAreasLoader(**kwargs)
 def create_curriculum_areas_loader(self, structure_file_path, BASE_PATH):
     """Create curriculum area loader."""
     return CurriculumAreasLoader(structure_file_path, BASE_PATH)