def test_given_data_repo_if_study_is_not_inside_database_then_db_insert_is_called( self, ): # given repo = DataRepoTinydb("") repo.is_study_inside_database = mock.Mock(return_value=False) type(repo).db = mock.PropertyMock() study_dto = StudyDTO(path="path") # when repo.save_study(study_dto) # then repo.db.insert.assert_called_once()
def test_integration_given_data_repo_if_study_is_found_once_in_database_then_db_update_is_called( self, ): # given repo = DataRepoTinydb("") type(repo).db = mock.PropertyMock() repo.db.search = mock.Mock(return_value=["A"]) study_dto = StudyDTO(path="path") # when repo.save_study(study_dto) # then repo.db.update.assert_called_once()
def test_given_data_repo_when_save_study_is_called_then_is_study_inside_database_is_called( self, ): # given repo_mock = DataRepoTinydb("") type(repo_mock).db = mock.PropertyMock() repo_mock.is_study_inside_database = mock.Mock() study_dto = StudyDTO(path="path") # when repo_mock.save_study(study_dto) # then repo_mock.is_study_inside_database.assert_called_with(study=study_dto)
def test_is_job_id_inside_database_returns_true_only_if_one_job_id_is_found( self): # given repo = DataRepoTinydb("") type(repo).db = mock.PropertyMock() study_dto = StudyDTO(path="path") study_dto.job_id = 6381 repo.get_list_of_studies = mock.Mock(return_value=[study_dto]) repo.save_study(study_dto) # when output = repo.is_job_id_inside_database(6381) # then assert output is True