def test_with_data_store(mocker): """Test when the data store is already set.""" mock_data_store = mocker.MagicMock( spec=phonebook._datastore.base.BaseDataStore) mocker.patch.object(phonebook._main, "_DATA_STORE", mock_data_store) phonebook.get(_USER["name"]) mock_data_store.get.assert_called_once_with(_USER["name"])
def _verify_number(self, name, number): self.assertEquals(phonebook.get(name), number)
def _verify_add_and_get(self, name, number): self.assertEquals(phonebook.add(name, number), True) self.assertEquals(phonebook.get(name), number)
def _handle_get(args): """Output the result of the "get" command.""" result = phonebook.get(args.name) _print_result(result, args.output_format)
def _verify_not_added(self, name, number): self.assertEquals(phonebook.add(name, number), False) self.assertEquals(phonebook.get(name), "Unknown")