Пример #1
0
 def test_show(self):
     c = Controller({}, self.mock_app)
     req = Request.blank('?id=test')
     id = c.create(req).body['id']
     c = Controller({'id': '00000000-0000-0000-0000-000000000000'},
                    self.mock_app)
     req = Request.blank('')
     self.assertRaises(HTTPNotFound, c.show, req)
     c = Controller({'id': id}, self.mock_app)
     req = Request.blank('')
     res = c.show(req)
     self.assertEqual(res.body['id'], id)
Пример #2
0
 def test_show(self):
     c = Controller({}, self.mock_app)
     req = Request.blank('?id=test')
     id = c.create(req).body['id']
     c = Controller({'id': '00000000-0000-0000-0000-000000000000'},
                    self.mock_app)
     req = Request.blank('')
     self.assertRaises(HTTPNotFound, c.show, req)
     c = Controller({'id': id}, self.mock_app)
     req = Request.blank('')
     res = c.show(req)
     self.assertEqual(res.body['id'], id)
Пример #3
0
 def test_delete(self):
     c = Controller({}, self.mock_app)
     req = Request.blank('?id=test')
     id = c.create(req).body['id']
     c = Controller({'id': '00000000-0000-0000-0000-000000000000'},
                    self.mock_app)
     req = Request.blank('')
     self.assertRaises(HTTPNotFound, c.delete, req)
     c = Controller({'id': id}, self.mock_app)
     req = Request.blank('')
     res = c.delete(req)
     self.assertEqual(res.body['id'], id)
     self.assertEqual(res.body['status'], 'DELETED')
Пример #4
0
 def test_delete(self):
     c = Controller({}, self.mock_app)
     req = Request.blank('?id=test')
     id = c.create(req).body['id']
     c = Controller({'id': '00000000-0000-0000-0000-000000000000'},
                    self.mock_app)
     req = Request.blank('')
     self.assertRaises(HTTPNotFound, c.delete, req)
     c = Controller({'id': id}, self.mock_app)
     req = Request.blank('')
     res = c.delete(req)
     self.assertEqual(res.body['id'], id)
     self.assertEqual(res.body['status'], 'DELETED')
Пример #5
0
 def test_index(self):
     c = Controller({}, self.mock_app)
     req = Request.blank('')
     res = c.index(req)
     self.assertEqual(res.body, [])
     req = Request.blank('?id=test')
     res = c.create(req)
     req = Request.blank('?id=test2')
     res = c.create(req)
     req = Request.blank('')
     res = c.index(req)
     self.assertEqual(len(res.body), 2)
     req = Request.blank('?id=test2')
     res = c.index(req)
     self.assertEqual(len(res.body), 1)
     self.assertEqual(res.body[0]['id'], 'test2')
Пример #6
0
 def test_index(self):
     c = Controller({}, self.mock_app)
     req = Request.blank('')
     res = c.index(req)
     self.assertEqual(res.body, [])
     req = Request.blank('?id=test')
     res = c.create(req)
     req = Request.blank('?id=test2')
     res = c.create(req)
     req = Request.blank('')
     res = c.index(req)
     self.assertEqual(len(res.body), 2)
     req = Request.blank('?id=test2')
     res = c.index(req)
     self.assertEqual(len(res.body), 1)
     self.assertEqual(res.body[0]['id'], 'test2')
Пример #7
0
 def test_create(self):
     c = Controller({}, self.mock_app)
     req = Request.blank('?id=test')
     res = c.create(req)
     self.assertEqual(res.body['id'], 'test')
Пример #8
0
 def test_create(self):
     c = Controller({}, self.mock_app)
     req = Request.blank('?id=test')
     res = c.create(req)
     self.assertEqual(res.body['id'], 'test')