Ejemplo n.º 1
0
 def test_resource_loader_invalid_copies_value(self):
     config_file = "invalid-copies.yaml"
     resource_loader = ResourcesLoader(structure_filename=config_file, base_path=self.BASE_PATH)
     self.assertRaises(
         InvalidYAMLValueError,
         resource_loader.load,
     )
Ejemplo n.º 2
0
 def test_resource_loader_missing_configuration_file(self):
     config_file = "missing.yaml"
     resource_loader = ResourcesLoader(config_file, self.BASE_PATH)
     self.assertRaises(
         CouldNotFindConfigFileError,
         resource_loader.load,
     )
Ejemplo n.º 3
0
 def test_resource_loader_empty_configuration_file(self):
     config_file = "empty.yaml"
     resource_loader = ResourcesLoader(structure_filename=config_file, base_path=self.BASE_PATH)
     self.assertRaises(
         EmptyYAMLFileError,
         resource_loader.load,
     )
Ejemplo n.º 4
0
 def test_resource_loader_missing_copies_value(self):
     config_file = "missing-copies.yaml"
     resource_loader = ResourcesLoader(structure_filename=config_file, base_path=self.BASE_PATH)
     self.assertRaises(
         MissingRequiredFieldError,
         resource_loader.load,
     )
Ejemplo n.º 5
0
 def test_resource_loader_invalid_module_value(self):
     config_file = "invalid-module.yaml"
     resource_loader = ResourcesLoader(structure_filename=config_file, base_path=self.BASE_PATH)
     self.assertRaises(
         AttributeError,
         resource_loader.load,
     )
Ejemplo n.º 6
0
 def test_resource_loader_missing_configuration_file(self):
     config_file = "missing.yaml"
     resource_loader = ResourcesLoader(structure_filename=config_file, base_path=self.BASE_PATH)
     self.assertRaises(
         CouldNotFindYAMLFileError,
         resource_loader.load,
     )
Ejemplo n.º 7
0
 def test_resource_loader_empty_configuration_file(self):
     config_file = "empty.yaml"
     resource_loader = ResourcesLoader(config_file, self.BASE_PATH)
     self.assertRaises(
         EmptyConfigFileError,
         resource_loader.load,
     )
Ejemplo n.º 8
0
 def test_resource_loader_invalid_template_value(self):
     config_file = "invalid-template.yaml"
     resource_loader = ResourcesLoader(config_file, self.BASE_PATH)
     self.assertRaises(
         FileNotFoundError,
         resource_loader.load,
     )
Ejemplo n.º 9
0
 def test_resource_loader_invalid_copies_value(self):
     config_file = "invalid-copies.yaml"
     resource_loader = ResourcesLoader(config_file, self.BASE_PATH)
     self.assertRaises(
         InvalidConfigValueError,
         resource_loader.load,
     )
Ejemplo n.º 10
0
 def test_resource_loader_missing_module_value(self):
     config_file = "missing-module.yaml"
     resource_loader = ResourcesLoader(config_file, self.BASE_PATH)
     self.assertRaises(
         MissingRequiredFieldError,
         resource_loader.load,
     )
Ejemplo n.º 11
0
 def test_resource_loader_trimmed_module_value(self):
     config_file = "trimmed-module.yaml"
     resource_loader = ResourcesLoader(structure_filename=config_file, base_path=self.BASE_PATH)
     resource_loader.load()
     self.assertEquals(
         Resource.objects.get(slug="resource-untranslated").generator_module,
         "GridResourceGenerator",
     )
Ejemplo n.º 12
0
 def test_resource_loader_invalid_thumbnail_value(self):
     config_file = "invalid-thumbnail.yaml"
     resource_loader = ResourcesLoader(structure_filename=config_file,
                                       base_path=self.BASE_PATH)
     self.assertRaises(
         FileNotFoundError,
         resource_loader.load,
     )
Ejemplo n.º 13
0
 def test_resource_loader_correct_slug_value(self):
     config_file = "basic-config.yaml"
     resource_loader = ResourcesLoader(config_file, self.BASE_PATH)
     resource_loader.load()
     self.assertEquals(
         Resource.objects.get(slug="grid").slug,
         "grid",
     )
Ejemplo n.º 14
0
 def test_resource_loader_correct_module_value(self):
     config_file = "basic-config.yaml"
     resource_loader = ResourcesLoader(config_file, self.BASE_PATH)
     resource_loader.load()
     self.assertEquals(
         Resource.objects.get(slug="grid").generator_module,
         "GridResourceGenerator",
     )
Ejemplo n.º 15
0
 def test_resource_loader_correct_template_value(self):
     config_file = "basic-config.yaml"
     resource_loader = ResourcesLoader(config_file, self.BASE_PATH)
     resource_loader.load()
     self.assertEquals(
         Resource.objects.get(slug="grid").webpage_template,
         "resources/grid.html",
     )
Ejemplo n.º 16
0
 def test_resource_loader_correct_thumbnail_value(self):
     config_file = "basic-config.yaml"
     resource_loader = ResourcesLoader(config_file, self.BASE_PATH)
     resource_loader.load()
     self.assertEquals(
         Resource.objects.get(slug="grid").thumbnail_static_path,
         "img/resources/grid/thumbnail.png",
     )
Ejemplo n.º 17
0
 def test_resource_loader_multiple_configuration(self):
     config_file = "multiple.yaml"
     resource_loader = ResourcesLoader(structure_filename=config_file, base_path=self.BASE_PATH)
     resource_loader.load()
     self.assertQuerysetEqual(
         Resource.objects.all(),
         [
             "<Resource: Resource 1>",
             "<Resource: Resource 2>",
         ],
         ordered=False,
     )
Ejemplo n.º 18
0
 def test_basic_resource_loader_config(self):
     config_file = "basic-config.yaml"
     resource_loader = ResourcesLoader(structure_filename=config_file, base_path=self.BASE_PATH)
     resource_loader.load()
     resources = Resource.objects.all()
     self.assertEqual(1, len(resources))
     resource = resources[0]
     self.assertEqual("Resource 1", resource.name)
     self.assertIn("Description of resource 1", resource.content)
     self.assertEqual("resource-untranslated", resource.slug)
     self.assertEqual("GridResourceGenerator", resource.generator_module)
     self.assertEqual(False, resource.copies)
Ejemplo n.º 19
0
 def test_resource_loader_config_missing_translation_fallback(self):
     config_file = "basic-config.yaml"
     resource_loader = ResourcesLoader(structure_filename=config_file, base_path=self.BASE_PATH)
     resource_loader.load()
     resources = Resource.objects.all()
     self.assertEqual(1, len(resources))
     resource = resources[0]
     with translation.override("de"):
         # Name should fall back to English
         self.assertEqual("Resource 1", resource.name)
         # Content should not fall back to English
         self.assertEqual("", resource.content)
Ejemplo n.º 20
0
 def test_resource_loader_multiple_configuration(self):
     config_file = "multiple.yaml"
     resource_loader = ResourcesLoader(config_file, self.BASE_PATH)
     resource_loader.load()
     self.assertQuerysetEqual(
         Resource.objects.all(),
         [
             "<Resource: Grid>",
             "<Resource: Job Badges>",
         ],
         ordered=False,
     )
Ejemplo n.º 21
0
 def test_resource_loader_translation(self):
     config_file = "translation.yaml"
     resource_loader = ResourcesLoader(structure_filename=config_file, base_path=self.BASE_PATH)
     resource_loader.load()
     resources = Resource.objects.all()
     self.assertEqual(1, len(resources))
     resource = resources[0]
     self.assertEqual("English Resource Name", resource.name)
     self.assertIn("English resource description", resource.content)
     with translation.override("de"):
         self.assertEqual("German Resource Name", resource.name)
         self.assertIn("German resource description", resource.content)
Ejemplo n.º 22
0
 def create_resources_loader(self, structure_file, BASE_PATH):
     """Create resources loader."""
     return ResourcesLoader(structure_file, BASE_PATH)
Ejemplo n.º 23
0
 def test_basic_resource_loader_config(self):
     config_file = "basic-config.yaml"
     resource_loader = ResourcesLoader(config_file, self.BASE_PATH)
     resource_loader.load()
     self.assertQuerysetEqual(Resource.objects.all(), ["<Resource: Grid>"])
Ejemplo n.º 24
0
 def create_resources_loader(self, **kwargs):
     """Create resources loader."""
     return ResourcesLoader(**kwargs)