def test_set_unknown_categories_fails(self):
username = "toshibot"
name = "ToshiBot"
categories = await self.setup_categories()
async with self.pool.acquire() as con:
await con.execute("INSERT INTO users (username, toshi_id, name, is_app, is_public) VALUES ($1, $2, $3, true, true)",
username, TEST_ADDRESS, name)
resp = await self.fetch_signed("/user", signing_key=TEST_PRIVATE_KEY, method="PUT", body={
"categories": [categories[-1][0] + 10, 'badcat']
})
self.assertResponseCodeEqual(resp, 400)
resp = await self.fetch("/user/{}".format(TEST_ADDRESS))
self.assertResponseCodeEqual(resp, 200)
body = json_decode(resp.body)
self.assertIn("categories", body)
self.assertEqual(len(body['categories']), 0)
评论列表
文章目录