예제 #1
0
 def setUp(self):
     create_tables()
     # create some items
     self.person = Person.create(firstname="Steve", lastname="Loria")
     self.person2 = Person.create(firstname="Monty", lastname="Python")
     self.item = Item.create(name="Foo", person=self.person)
     self.item2 = Item.create(name="Bar")
예제 #2
0
 def setUp(self):
     create_tables()
     # create some items
     self.person = Person.create(firstname="Steve", lastname="Loria")
     self.person2 = Person.create(firstname="Monty", lastname="Python")
     self.item = Item.create(name="Foo", person=self.person)
     self.item2 = Item.create(name="Bar")
예제 #3
0
 def test_put_item(self):
     res = self._put_json(
         "/api/v1/items/{0}".format(self.item.id), {"checked_out": True, "person_id": self.person2.id}
     )
     item = Item.get(Item.id == self.item.id)
     assert_true(item.checked_out)
     assert_equal(item.person, self.person2)
예제 #4
0
 def test_post_item(self):
     res = self._post_json("/api/v1/items/", {"name": "Ipad", "checked_out": True})
     assert_equal(res.status_code, 201)
     item = Item.select().order_by(Item.updated.desc()).first()
     assert_true(item is not None)
     assert_equal(item.name, "Ipad")
     assert_true(item.checked_out)
예제 #5
0
 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 = Item.select().order_by(Item.updated.desc()).first()
     assert_equal(item.person, self.person)
예제 #6
0
 def test_put_item(self):
     res = self._put_json("/api/v1/items/{0}".format(self.item.id), {
         "checked_out": True,
         "person_id": self.person2.id
     })
     item = Item.get(Item.id == self.item.id)
     assert_true(item.checked_out)
     assert_equal(item.person, self.person2)
예제 #7
0
 def test_post_item(self):
     res = self._post_json("/api/v1/items/", {
         "name": "Ipad",
         'checked_out': True
     })
     assert_equal(res.status_code, 201)
     item = Item.select().order_by(Item.updated.desc()).first()
     assert_true(item is not None)
     assert_equal(item.name, "Ipad")
     assert_true(item.checked_out)
예제 #8
0
 def test_delete_item(self):
     all_items = [i for i in Item.select()]
     assert_in(self.item, all_items)
     res = self.client.delete("/api/v1/items/{0}".format(self.item.id))
     all_items = [i for i in Item.select()]
     assert_not_in(self.item, all_items)
예제 #9
0
 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 = Item.select().order_by(Item.updated.desc()).first()
     assert_equal(item.person, self.person)
예제 #10
0
 def test_delete_item(self):
     all_items = [i for i in Item.select()]
     assert_in(self.item, all_items)
     res = self.client.delete("/api/v1/items/{0}".format(self.item.id))
     all_items = [i for i in Item.select()]
     assert_not_in(self.item, all_items)