def test_add(self, mocker, sent): mocker.patch('infrastructure.repositories.mem.poll.repo_data.CHOICES', []) with repo.ChoiceMemRepo() as rep: choice = mocker.Mock(id=sent.id) rep.add(choice) assert rep.data == {} assert rep.data == {str(sent.id): choice}
def test_get(self, mocker, sent): uid = uuid4() mocker.patch('infrastructure.repositories.mem.poll.repo_data.CHOICES', []) with repo.ChoiceMemRepo() as rep: rep.data = {str(uid): sent.choice} resp = rep.get(uid) assert resp == sent.choice
def test_init(self, mocker, sent): c_id = uuid4() m_choice = {'id': str(c_id)} mocker.patch('infrastructure.repositories.mem.poll.repo_data.CHOICES', [m_choice]) m_choice_from_dict = mocker.patch( 'infrastructure.repositories.mem.poll.entity.Choice.from_dict', return_value=sent.choice) repo.ChoiceMemRepo() m_choice_from_dict.assert_called_once_with(m_choice)
def test_list(self, mocker, sent): uid1 = uuid4() uid2 = uuid4() mocker.patch('infrastructure.repositories.mem.poll.repo_data.CHOICES', []) with repo.ChoiceMemRepo() as rep: rep.data = {str(uid1): sent.choice1, str(uid2): sent.choice2} resp = rep.list() assert tuple(resp) == (sent.choice1, sent.choice2)
def get_mem_repo(): from infrastructure.repositories.mem import poll as mem_repo mem_choice_repo = mem_repo.ChoiceMemRepo() mem_poll_repo = mem_repo.PollMemRepo() return mem_choice_repo, mem_poll_repo