def test_given_db_when_get_list_of_studies_is_called_then_db_all_is_called( self): # given repo = DataRepoTinydb("") repo.doc_to_study = mock.Mock(return_value=42) type(repo).db = mock.PropertyMock() repo.db.all = mock.Mock(return_value=[]) # when repo.get_list_of_studies() # then repo.db.all_assert_calles_once()
def test_given_db_of_n_elements_when_get_list_of_studies_is_called_then_doc_to_study_is_called_n_times( self, ): # given n = 5 repo = DataRepoTinydb("") repo.doc_to_study = mock.Mock(return_value=42) type(repo).db = mock.PropertyMock() repo.db.all = mock.Mock(return_value=[""] * n) # when repo.get_list_of_studies() # then assert repo.doc_to_study.call_count == n
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