Esempio n. 1
0
    def test_auctions_commit(self):
        results, droplist = util.round_results(commit=True)

        print ''
        print '------------------- Test with commit: --------------------------'

        drop1 = Player.objects.get(name='rb3')
        drop2 = Player.objects.get(name='wr2')
        
        print '%40s' % ('Check auction winners:'),
        self.assertEqual(droplist[0], drop1.pk)
        self.assertEqual(droplist[1], drop2.pk)
        print ' OK'

        invalid_drop = Bid.objects.filter(player__name = 'rb5').filter(drop__name = 'rb3')[0]
        invalid_funds = Bid.objects.filter(player__name = 'wr1').filter(drop__name = 'wr3')[0]
                
        print '%40s' % ('Check invalid drop:'),
        self.assertEqual(invalid_drop.validity, Bid.DROP)
        print ' OK'

        print '%40s' % ('Check invalid funds:'),
        self.assertEqual(invalid_funds.validity, Bid.FUNDS)
        print ' OK'

        print '%40s' % ('Check accounts:'),
        teams = Team.objects.all()
        accounts = {'a':50, 'b':49, 'c':149}
        for t in teams:
            self.assertEqual(t.account, accounts[t.name])
        self.assertEqual(len(Bid.objects.filter(processed=True)), 7)        
        print ' OK'
Esempio n. 2
0
    def test_index_page(self):
        print ''
        print '------------------- Testing front page: --------------------------'
        results, droplist = util.round_results(commit=True)
        client = Client()
        response = client.get('/')
#        self.assertContains(response, "No polls are available.")
#        self.assertQuerysetEqual(response.context['trades'], [])        

        print '%40s' % ('Check for trades in html context:'),
        self.assertEqual(len(response.context['trades']), 0)        
        self.assertEqual(len(Bid.objects.filter(processed=True)), 7)        
        self.assertEqual(len(Bid.objects.filter(succesful=True)), 3)        
        print ' OK'
Esempio n. 3
0
    def test_results_page(self):
        print ''
        print '------------------- Testing results page: --------------------------'
        results, droplist = util.round_results(commit=True)
        this_week         = util.waiver_week(timezone.now())
        url = '/results/%d/' % (this_week)
        client = Client()
        response = client.get(url)

        
        print '%40s' % ('Check wr1 present in html context:'),
        wr1 = Player.objects.get(name='wr1')
        self.assertTrue(wr1 in response.context['rounds'].keys())        
        print ' OK'
Esempio n. 4
0
    def test_auctions(self):
        """Test several auction scenarios"""
        results, droplist = util.round_results(commit=False)

        print ''
        print '----------------- Test without commit: ------------------------'
        
        drop1 = Player.objects.get(name='rb3')
        drop2 = Player.objects.get(name='wr2')


        print '%40s' % ('Check auction winners:'),
        self.assertEqual(droplist[0], drop1.pk)
        self.assertEqual(droplist[1], drop2.pk)
        print ' OK'

        print '%40s' % ('Check accounts:'),
        teams = Team.objects.all()
        for t in teams:
            self.assertEqual(t.account, 150)
        print ' OK'