Exemplo n.º 1
0
 def test_toss_item_ok(self):
     self.login()
     data = {
         'title': 'test_draw',
         'is_shared': True,
         'enable_chat': True,
         'users': ['*****@*****.**'],
         'items': ["1"],
         'allow_repeat': True,
         }
     draw = RandomItemDraw(**data)
     draw.owner = self.user.pk
     self.mongo.save_draw(draw)
     resp = self.toss(draw)
     print(resp)
     self.assertHttpOK(resp)
     draw = self.mongo.retrieve_draw(draw.pk)
     self.assertEqual(1, len(draw.results))
     self.mongo.remove_draw(draw.pk)
Exemplo n.º 2
0
 def test_update_item_ok(self):
     self.login()
     data = {
         'title': 'test_draw',
         'is_shared': True,
         'enable_chat': True,
         'users': ['*****@*****.**'],
         'items': ["1"],
         'allow_repeat': True,
         }
     draw = RandomItemDraw(**data)
     draw.owner = self.user.pk
     self.mongo.save_draw(draw)
     update_data = {
         'items': [1, 2, 3, 4],
         'title': 'new title'
     }
     resp = self.api_client.patch(self.detail_uri(draw), data=update_data)
     print(resp)
     self.assertHttpAccepted(resp)
     draw = self.mongo.retrieve_draw(draw.pk)
     for key, value in update_data.items():
         self.assertEqual(value, getattr(draw, key))
     self.mongo.remove_draw(draw.pk)