コード例 #1
0
ファイル: tests.py プロジェクト: PabloValor/dp
    def test_gameplayer_update_notification_E(self):
        """ 
          When a Gameplayer another_chance is updated we create a Notification

          Owner invites Gameplayer again after he had asked for another chance to play
        """

        # Player invited
        gp = GamePlayerFactory()
        self.assertEqual(NotificationGame.objects.count(), 1)
        self.assertEqual(NotificationGame.objects.filter(player = gp.player).count(), 1)

        # Player rejects 
        gp.status = False
        gp.save()
        self.assertEqual(NotificationGame.objects.filter(player = gp.player).count(), 1)
        self.assertEqual(NotificationGame.objects.count(), 2)

        # Player asks for another chance
        gp.another_chance = True
        gp.save()
        self.assertEqual(NotificationGame.objects.filter(player = gp.player).count(), 1)
        self.assertEqual(NotificationGame.objects.count(), 3)

        # Player invites again the user
        gp.reset()
        gp.save()
        self.assertEqual(NotificationGame.objects.filter(player = gp.player).count(), 2)
        self.assertEqual(NotificationGame.objects.filter(player = gp.player, active = True).count(), 1)
        self.assertEqual(NotificationGame.objects.count(), 4)
コード例 #2
0
ファイル: tests.py プロジェクト: PabloValor/dp
    def test_gameplayer_update_notification_B(self):
        """ 
          When a Gameplayer status is updated we create a Notification

          Gameplayer rejects to play
        """
        gp = GamePlayerFactory()
        gp.status = False
        gp.save()

        self.assertEqual(NotificationGame.objects.count(), 2)
        self.assertEqual(NotificationGame.objects.all()[1].notification_type, '3')
        self.assertEqual(NotificationGame.objects.all()[1].player, gp.game.owner)
コード例 #3
0
    def test_gameplayer_update_notification_B(self):
        """ 
          When a Gameplayer status is updated we create a Notification

          Gameplayer rejects to play
        """
        gp = GamePlayerFactory()
        gp.status = False
        gp.save()

        self.assertEqual(NotificationGame.objects.count(), 2)
        self.assertEqual(NotificationGame.objects.all()[1].notification_type,
                         '3')
        self.assertEqual(NotificationGame.objects.all()[1].player,
                         gp.game.owner)
コード例 #4
0
    def test_gameplayer_update_notification_E(self):
        """ 
          When a Gameplayer another_chance is updated we create a Notification

          Owner invites Gameplayer again after he had asked for another chance to play
        """

        # Player invited
        gp = GamePlayerFactory()
        self.assertEqual(NotificationGame.objects.count(), 1)
        self.assertEqual(
            NotificationGame.objects.filter(player=gp.player).count(), 1)

        # Player rejects
        gp.status = False
        gp.save()
        self.assertEqual(
            NotificationGame.objects.filter(player=gp.player).count(), 1)
        self.assertEqual(NotificationGame.objects.count(), 2)

        # Player asks for another chance
        gp.another_chance = True
        gp.save()
        self.assertEqual(
            NotificationGame.objects.filter(player=gp.player).count(), 1)
        self.assertEqual(NotificationGame.objects.count(), 3)

        # Player invites again the user
        gp.reset()
        gp.save()
        self.assertEqual(
            NotificationGame.objects.filter(player=gp.player).count(), 2)
        self.assertEqual(
            NotificationGame.objects.filter(player=gp.player,
                                            active=True).count(), 1)
        self.assertEqual(NotificationGame.objects.count(), 4)