def test_create_email_exists(self): self.mox.StubOutWithMock(user_service, 'read') user_service.read(TEST_EMAIL).AndReturn(TEST_USER) self.mox.StubOutWithMock(tiny_classified, 'get_db_adapter') self.mox.ReplayAll() with self.assertRaises(ValueError): user_service.create(TEST_USER)
def test_create_success(self): self.mox.StubOutWithMock(user_service, 'read') user_service.read(TEST_EMAIL).AndReturn(None) test_db_adapter = mox.Mox().CreateMock(db_service.DBAdapter) test_db_adapter.upsert_user(TEST_USER) tiny_classified.set_db_adapter(test_db_adapter) self.mox.ReplayAll() user_service.create(TEST_USER)