def test_upppercase_name(self): """ Tests the clean method when the name contains an uppercase character. """ warehouse = Warehouse(backend='elasticsearch', name='testDatabase', time_series=True) msg = 'Value must be lowercase string.' with six.assertRaisesRegex(self, ValidationError, msg): warehouse.full_clean()
def test_disallowed_time_series(self): """ Tests the clean method when time_series is selected but not is allowed with the selected backend. """ warehouse = Warehouse(backend='mongodb', name='test_database', time_series=True) msg = ('The time series feature is not enabled ' 'for the selected backend.') with six.assertRaisesRegex(self, ValidationError, msg): warehouse.clean()
def test_special_character_name(self): """ Tests the clean method when the name contains a special character. """ warehouse = Warehouse(backend='elasticsearch', name='test_databa$e', time_series=True) msg = ('Name cannot contain special characters other than ' 'underscores and hypens.') with six.assertRaisesRegex(self, ValidationError, msg): warehouse.full_clean()
def test_allowed_time_series(self): """ Tests the clean method when time_series is selected and is allowed with the selected backend. """ mock_module = Mock() mock_module.TIME_SERIES_ENABLED = True # patch this to avoid errors if Elasticsearch is not connected with patch('warehouses.models.Warehouse.get_module', return_value=mock_module): warehouse = Warehouse(backend='elasticsearch', name='test_index', time_series=True) try: warehouse.clean() except ValidationError: self.fail('A ValidationError was raised unexpectedly')