def test_simple_delete(self): json = self.post_json('/exs', utils.get_test_ex()).json uri = '/exs/%s' % (json['uuid']) self.delete(uri) response = self.get_json(uri, expect_errors=True) self.assertEqual(response.status_int, 404) self.assertEqual(response.content_type, 'application/json') self.assertTrue(response.json['error_message'])
def test_get_exs(self): uuids = [] for i in xrange(1, 6): c = utils.get_test_ex(id=i, uuid=uuidutils.generate_uuid()) self.dbapi.create_ex(c) uuids.append(unicode(c['uuid'])) res = self.dbapi.get_exs() reid = [] for re in res: reid.append(re['uuid']) uuids.sort() reid.sort() self.assertEqual(uuids, reid) return uuids
def test_simple_create(self): json = self.post_json('/exs', utils.get_test_ex()).json expect = { "uuid": "1be26c0b-03f2-4d2e-ae87-c02d7f33c123", "title": "new ex", "content": "new content", } for key, value in expect.items(): self.assertEqual(json[key], value) uri = '/exs/%s' % (json['uuid']) json = self.get_json(uri) for key, value in expect.items(): self.assertEqual(json[key], value)
def test_simple_update(self): json = self.post_json('/exs', utils.get_test_ex()).json uri = '/exs/%s' % (json['uuid']) self.put_json(uri, utils.get_test_ex(title="update")) json = self.get_json(uri) self.assertEqual(json['title'], "update")
def _create_test_ex(self, **kwargs): c = utils.get_test_ex(**kwargs) self.dbapi.create_ex(c) return c