def test_toss_tournament_ok(self):
     self.login()
     data = {
         'title': 'test_draw',
         'is_shared': True,
         'enable_chat': True,
         'users': ['*****@*****.**'],
         'participants': ["a", "b"],
         'allow_repeat': True,
         }
     draw = TournamentDraw(**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)
 def test_update_tournament_ok(self):
     self.login()
     data = {
         'title': 'test_draw',
         'is_shared': True,
         'enable_chat': True,
         'users': ['*****@*****.**'],
         'participants': ["a", "b"],
         }
     draw = TournamentDraw(**data)
     draw.owner = self.user.pk
     self.mongo.save_draw(draw)
     update_data = {
         'participants': ['Javier', 'Ruben', 'Josemari'],
         'enable_chat': False
     }
     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)