def setUp(self): db.create_tables() # create some items with db_session: self.person = Person(firstname="Steve", lastname="Loria") self.person2 = Person(firstname="Monty", lastname="Python") self.item = Item(name="Foo", person=self.person) self.item2 = Item(name="Bar")
def test_post_item_with_person_id(self): res = self._post_json('/api/v1/items/', {"name": "Ipod", "person_id": self.person.id}) assert_equal(res.status_code, 201) item = list(Item.select())[-1] person = Person[self.person.id] assert_equal(item.person, person)
def test_post_item(self): res = self._post_json("/api/v1/items/", {"name": "Ipad", 'checked_out': True}) assert_equal(res.status_code, 201) item = list(Item.select())[-1] assert_true(item is not None) assert_equal(item.name, "Ipad") assert_true(item.checked_out)
def test_post_item_with_person_id(self): res = self._post_json('/api/v1/items/', { "name": "Ipod", "person_id": self.person.id }) assert_equal(res.status_code, 201) item = list(Item.select())[-1] person = Person[self.person.id] assert_equal(item.person, person)
def test_post_item(self): res = self._post_json("/api/v1/items/", { "name": "Ipad", 'checked_out': True }) assert_equal(res.status_code, 201) item = list(Item.select())[-1] assert_true(item is not None) assert_equal(item.name, "Ipad") assert_true(item.checked_out)
def test_delete_item(self): item = Item[self.item.id] assert_in(item, Item.select()[:]) res = self.client.delete("/api/v1/items/{0}".format(self.item.id)) assert_not_in(self.item, Item.select())