def test_missing_collection(self, mock_logging_error: mock.MagicMock) -> None: """A collection from the config is missing.""" self._db.has_scoring_models.drop() maintenance.check_scoring_models(self._db) mock_logging_error.assert_called_once() self.assertIn('has_scoring_models', mock_logging_error.call_args[0])
def test_missing_collection(self, mock_logging_error): """A collection from the config is missing.""" # Note it could be any of the collection of _SCORING_MODEL_FIELDS. self._db.associations.drop() maintenance.check_scoring_models(self._db) mock_logging_error.assert_called_once() self.assertIn('associations', mock_logging_error.call_args[0])
def test_only_empty_fields(self, mock_logging_error: mock.MagicMock) -> None: """A collection from the config has only empty fields.""" self._db.has_scoring_models.drop() self._db.has_scoring_models.insert_one({'filters': []}) maintenance.check_scoring_models(self._db) mock_logging_error.assert_called_once() self.assertIn('has_scoring_models', mock_logging_error.call_args[0])
def test_only_empty_fields(self, mock_logging_error): """A collection from the config has only empty fields.""" # Note it could be any of the collection of _SCORING_MODEL_FIELDS. self._db.associations.drop() self._db.associations.insert_one({'filters': []}) maintenance.check_scoring_models(self._db) mock_logging_error.assert_called_once() self.assertIn('associations', mock_logging_error.call_args[0])
def test_unknown_scoring_model(self, mock_logging_error): """A record has an unknown scoring model.""" # Note it could be any of the collection of _SCORING_MODEL_FIELDS. self._db.associations.drop() self._db.associations.insert_one({'_id': 'culprit', 'filters': ['unknown-not-implemented']}) maintenance.check_scoring_models(self._db) mock_logging_error.assert_called_once() self.assertIn('associations', mock_logging_error.call_args[0]) self.assertIn('culprit', mock_logging_error.call_args[0])
def test_unknown_scoring_model(self, mock_logging_error: mock.MagicMock) -> None: """A record has an unknown scoring model.""" self._db.has_scoring_models.drop() self._db.has_scoring_models.insert_one( {'_id': 'culprit', 'filters': ['unknown-not-implemented']}) maintenance.check_scoring_models(self._db) mock_logging_error.assert_called_once() self.assertIn('has_scoring_models', mock_logging_error.call_args[0]) self.assertIn('culprit', mock_logging_error.call_args[0])
def test_check_all(self, mock_logging_error): """No problems with scoring models.""" maintenance.check_scoring_models(self._db) self.assertFalse(mock_logging_error.called)
def test_check_all(self, mock_logging_error: mock.MagicMock) -> None: """No problems with scoring models.""" maintenance.check_scoring_models(self._db) self.assertFalse(mock_logging_error.called, msg=mock_logging_error.call_args)