コード例 #1
0
 def test_update_linked_sets_ok(self):
     self.login()
     data = {
         'title': 'test_draw',
         'is_shared': True,
         'enable_chat': True,
         'users': ['*****@*****.**'],
         'sets': [[1, 2], [2, 3]],
         'allow_repeat': True,
         }
     draw = LinkSetsDraw(**data)
     draw.owner = self.user.pk
     self.mongo.save_draw(draw)
     update_data = {
         'sets': [
             ["One", "Two", "Three"],
             ["Caramba", "Jeropa"]
         ]
     }
     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)
コード例 #2
0
 def test_schedule_linked_sets_invalid_date(self):
     self.login()
     data = {
         'title': 'test_draw',
         'is_shared': True,
         'enable_chat': True,
         'users': ['*****@*****.**'],
         'sets': [[1], [2]],
         'allow_repeat': True,
         }
     draw = LinkSetsDraw(**data)
     draw.owner = self.user.pk
     self.mongo.save_draw(draw)
     resp = self.schedule_toss(draw, 'invalid date :)')
     print(resp)
     self.assertHttpBadRequest(resp)
     self.mongo.remove_draw(draw.pk)
コード例 #3
0
 def test_toss_linked_sets_ok(self):
     self.login()
     data = {
         'title': 'test_draw',
         'is_shared': True,
         'enable_chat': True,
         'users': ['*****@*****.**'],
         'sets': [[1, 2], [2, 3]],
         'allow_repeat': True,
         }
     draw = LinkSetsDraw(**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)
コード例 #4
0
 def test_schedule_linked_sets_ok(self):
     self.login()
     data = {
         'title': 'test_draw',
         'is_shared': True,
         'enable_chat': True,
         'users': ['*****@*****.**'],
         'sets': [[1], [2]],
         'allow_repeat': True,
         }
     draw = LinkSetsDraw(**data)
     draw.owner = self.user.pk
     self.mongo.save_draw(draw)
     resp = self.schedule_toss(draw, '2015-10-21T00:00:00Z')
     print(resp)
     self.assertHttpOK(resp)
     self.assertEqual([1, 2], self.deserialize(resp)['items'][0])
     self.assertEqual('2015-10-21T00:00:00',
                      self.deserialize(resp)['publication_datetime'])
     draw = self.mongo.retrieve_draw(draw.pk)
     self.assertEqual(1, len(draw.results))
     self.mongo.remove_draw(draw.pk)