def test_should_return_shared_notes_if_cached(self, note_sharing_service_mock): note_sharing_service_mock.list_it_for_user.return_value = [] db_instance = self.mock.MagicMock() db_instance.id = 1 user = residents.User(db_instance=db_instance) user._shared_notes = [] shared_notes = user.shared_notes self.assertEqual(shared_notes, [])
def test_should_call_note_sharing_service_to_list_for_user_if_not_cached(self, note_sharing_service_mock): note_sharing_service_mock.list_it_for_user.return_value = [] db_instance = self.mock.MagicMock() db_instance.id = 1 user = residents.User(db_instance=db_instance) user.shared_notes self.assertTrue(note_sharing_service_mock.list_it_for_user.called) note_sharing_service_mock.list_it_for_user.assert_called_with(1)
def test_should_call_delete_if_note_instantiated(self, note_service_note): note_mock = self.mock.MagicMock() note_service_note.create_for_user.return_value = note_mock db_instance = self.mock.MagicMock() db_instance.id = 1 user = residents.User(db_instance=db_instance) user.delete_a_note(id=1) self.assertTrue(note_mock.delete.called)
def test_should_call_service_if_not_cached(self, note_service): note_service.list_for_user.return_value = [] db_instance = self.mock.MagicMock() db_instance.id = 1 user = residents.User(db_instance=db_instance) notes = user.notes self.assertTrue(note_service.list_for_user.called) self.assertEqual(notes, [])
def test_should_call_note_service_to_create_for_user_if_not_cached(self, note_sharing_service_mock, note_service_mock): note_sharing_1 = self.mock.MagicMock(user_id=1, note_id=10) note_sharing_2 = self.mock.MagicMock(user_id=1, note_id=20) note_sharing_service_mock.list_it_for_user.return_value = [note_sharing_1, note_sharing_2] db_instance = self.mock.MagicMock() db_instance.id = 1 user = residents.User(db_instance=db_instance) user.shared_notes note_service_mock.create_for_user.assert_called_with(1, 20) # TODO: How to test this better?
def setUp(self): db_instance_mock = self.mock.MagicMock() db_instance_mock.id = 1 db_instance_mock.username = '******' db_instance_mock.email = 'breno@breno' db_instance_mock.token = 'ToKeN' db_instance_mock.password = '******' db_instance_mock.avatar_path = 'some/path' self.user = residents.User(db_instance_mock)
def test_should_call_services_to_create_new(self, note_service_mock): db_instance = self.mock.MagicMock() db_instance.id = 1 note = { 'id': '1', 'name': 'this is a note', 'content': 'This is a note', 'color': '#FFFFFF' } user = residents.User(db_instance=db_instance) user.create_a_note(note) self.assertTrue(note_service_mock.create_new.called)
def test_should_call_update_if_note_was_instantiated(self, note_service_note): note_mock = self.mock.MagicMock() note_service_note.create_for_user.return_value = note_mock db_instance = self.mock.MagicMock() db_instance.id = 1 user = residents.User(db_instance=db_instance) note_changes = { 'id': '1', 'name': 'this is a note', 'content': 'This is a note', 'color': '#FFFFFF' } user.update_a_note(id=1, note_changes=note_changes) self.assertTrue(note_mock.update.called)
def setUp(self): db_instance_mock = self.mock.MagicMock() db_instance_mock.password = '******' db_instance_mock.id = 1 self.user = residents.User(db_instance_mock)
def setUp(self): db_instance_mock = self.mock.MagicMock() db_instance_mock.id = 1 self.user = residents.User(db_instance_mock)
def test_should_call_services_to_instantiate(self, note_service_mock): db_instance = self.mock.MagicMock() db_instance.id = 1 user = residents.User(db_instance=db_instance) user.get_a_note(1) self.assertTrue(note_service_mock.create_for_user.called)
def setUp(self): db_instance_mock = self.mock.MagicMock() db_instance_mock.id = 1 db_instance_mock.username = '******' db_instance_mock.email = 'breno@breno' self.user = residents.User(db_instance_mock)
def setUp(self): db_instance_mock = self.mock.MagicMock() db_instance_mock.avatar_path = 'some/path' db_instance_mock.id = 1 self.user = residents.User(db_instance_mock)
def setUp(self): self.db_instance_mock = self.mock.MagicMock() self.db_instance_mock.username = '******' self.db_instance_mock.id = 1 self.user = residents.User(self.db_instance_mock)
def setUp(self): self.db_instance_mock = self.mock.MagicMock() self.db_instance_mock.email = '*****@*****.**' self.db_instance_mock.id = 1 self.user = residents.User(self.db_instance_mock)