Example #1
0
    def test_rank_army_validation(self):
        '''The membership's army has to match the membership rank's army'''
        army = FullArmyFactory.create(title=u'Test Army')
        other_army = FullArmyFactory.create(title=u'other Army')

        player = PlayerFactory()
        membership = models.ArmyMembership(player=player,
                                           army=army)
        membership.save()

        self.assertEqual(membership.full_clean(), None)

        membership.rank = other_army.ranks.first()

        self.assertRaises(ValidationError, membership.full_clean)
Example #2
0
    def test_division_playes(self):
        army = FullArmyFactory.create(title=u'Test Army')
        self.assertEqual(army.players.count(), 0)

        player = PlayerFactory()
        membership = models.ArmyMembership(player=player,
                                           army=army)
        membership.save()
        self.assertTrue(player in army.players.all())
Example #3
0
    def test_player_as_army_member(self):
        army = FullArmyFactory.create(title=u"Test Army")
        player = PlayerFactory.create()

        # make the player a member of the army
        models.ArmyMembership.objects.create(player=player, army=army)
        self.assertEqual(len(models.ArmyMembership.objects.all()), 1)
        self.assertEqual(len(player.armies.all()), 1)
        self.assertEqual(player.armies.first().title, u"Test Army")