def test_configuration_check(self):
        settings.MULTITENANT_STATICFILES_DIRS = "tenants/%s/static"  # Not a list.
        finder = TenantFileSystemFinder()

        errors = finder.check()
        self.assertEqual(len(errors), 1)
        self.assertTrue(errors[0].is_serious())
    def test_configuration_check(self):
        settings.MULTITENANT_STATICFILES_DIRS = "tenants/%s/static"  # Not a list.
        finder = TenantFileSystemFinder()

        errors = finder.check()
        self.assertEqual(len(errors), 1)
        self.assertTrue(errors[0].is_serious())
    def test_storages_setter(self):
        finder = TenantFileSystemFinder()

        self.assertTrue(
            len(finder._storages) == 0,
            "Locations should not be initialized during construction",
        )
        finder.storages = "/test/path"
        self.assertEqual(finder._storages[self.tenant.schema_name], "/test/path")
    def test_storages_setter(self):
        finder = TenantFileSystemFinder()

        self.assertTrue(
            len(finder._storages) == 0,
            "Locations should not be initialized during construction",
        )
        finder.storages = "/test/path"
        self.assertEqual(finder._storages[self.tenant.schema_name], "/test/path")
    def test_storages_getter_after_connection_change(self):
        finder = TenantFileSystemFinder()
        finder.storages

        connection.schema_name = "another_test"
        finder.storages

        self.assertTrue(len(finder._storages) == 2)
        self.assertIn("another_test", finder._storages)
    def test_location_getter_after_connection_change(self):
        finder = TenantFileSystemFinder()
        locations = finder.locations

        connection.schema_name = "another_test"
        locations = finder.locations

        self.assertTrue(len(finder._locations) == 2)
        self.assertIn("another_test", finder._locations)
        self.assertEqual(locations[0][1], "tenants/another_test/static")
 def test_storages_getter_lazy_loading(self):
     finder = TenantFileSystemFinder()
     self.assertNotIn(
         self.tenant.schema_name,
         finder._storages,
         "Storages should not be initialized during construction.",
     )
     finder.storages
     self.assertIn(
         self.tenant.schema_name,
         finder._storages,
         "Lazy loading of storages failed!",
     )
 def test_location_getter_lazy_loading(self):
     finder = TenantFileSystemFinder()
     self.assertNotIn(
         self.tenant.schema_name,
         finder._locations,
         "Locations should not be initialized during construction.",
     )
     locations = finder.locations
     self.assertIn(
         self.tenant.schema_name,
         finder._locations,
         "Lazy loading of locations failed!",
     )
     self.assertEqual(locations[0][1], "tenants/test/static")
 def test_storages_getter_empty_after_init(self):
     finder = TenantFileSystemFinder()
     self.assertTrue(len(finder._storages) == 0)
示例#10
0
 def test_location_getter_empty_after_init(self):
     finder = TenantFileSystemFinder()
     self.assertTrue(len(finder._locations) == 0)