def test__repopulate_apps_not_called(self, _repopulate_mock): """ In a tenant that does nothing to define the apps that must be reloaded nothing happens """ environ = MagicMock() environ.get.return_value = 'tenant.com' with self.settings(SERVICE_VARIANT='lms'): start_tenant(None, environ) _repopulate_mock.assert_not_called()
def test_must_reset_because_domain(self, _, _reset_mock, _analyze_mock): """ If the analysis determines that a reset is required. It has to be done """ environ = MagicMock() environ.get.return_value = 'tenant.com' _analyze_mock.return_value = (True, None) with self.settings(SERVICE_VARIANT='lms'): start_tenant(None, environ) _reset_mock.assert_called()
def test_can_keep(self, _update_mock, _reset_mock, _analyze_mock): """ When the domain and current config match, the analysis will determine that we can keep the current settings """ environ = MagicMock() environ.get.return_value = 'tenant.com' _analyze_mock.return_value = (False, True) with self.settings(SERVICE_VARIANT='lms'): start_tenant(None, environ) _reset_mock.assert_not_called() _update_mock.assert_not_called()
def test_can_not_keep_because_analysis(self, _update_mock, _reset_mock, _analyze_mock): """ Unless the domain and current config match, the analysis will always determine we can not keep the current settings """ environ = MagicMock() environ.get.return_value = 'tenant.com' _analyze_mock.return_value = (False, False) with self.settings(SERVICE_VARIANT='lms'): start_tenant(None, environ) _reset_mock.assert_not_called() _update_mock.assert_called()
def test__repopulate_apps_called(self, _repopulate_mock, _get_config_mock): """ A tenant that defines the EDNX_TENANT_INSTALLED_APPS calls the function """ environ = MagicMock() environ.get.return_value = 'tenant.com' config = { "EDNX_USE_SIGNAL": True, } _get_config_mock.return_value = config, "tenant-key" with self.settings(SERVICE_VARIANT='lms', EDNX_TENANT_INSTALLED_APPS=['fake_app']): start_tenant(None, environ) _repopulate_mock.assert_called()