def test_given_tinydb_document_when_doc_to_study_called_then_return_corresponding_study( self, ): # given expected_study = StudyDTO(path="path") expected_study.job_id = 42 expected_study.n_cpu = 999 doc = tinydb.database.Document(expected_study.__dict__, 42) # when output_study = DataRepoTinydb.doc_to_study(doc) # then assert expected_study.__dict__ == output_study.__dict__
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