def test_vote_number_must_be_unique(self):
		dee = Competitor()
		dee.name = 'Delilian Alford'
		dee.nick_name = 'Dee'
		dee.no = 1
		dee.save()

		chris = Competitor()
		chris.name = 'Christopher Jonathan Roy Chaafe'
		chris.nick_name = 'Chris'
		chris.no = 1
		self.assertRaises(IntegrityError, chris.save)
示例#2
0
    def test_vote_number_must_be_unique(self):
        dee = factory.create_competitor()

        chris = Competitor()
        chris.name = 'Christopher Jonathan Roy Chaafe'
        chris.nick_name = 'Chris'
        chris.no = 1
        self.assertRaises(IntegrityError, chris.save)
    def test_no_must_be_unique(self):
        kangsom = Competitor.objects.create(name='Tanatat Chaiyaat', nick_name='Kangsom', no=8)

        hunz = Competitor()
        hunz.name = 'Isariya Phataramanop'
        hunz.nick_name = 'Hunz'
        hunz.no = 8
        self.assertRaises(IntegrityError, hunz.save)
示例#4
0
 def test_get_home_page(self):
     dee = Competitor()
     dee.name = 'Delilian Alford'
     dee.nick_name = 'Dee'
     dee.no = 1
     dee.save()
     
     url = '/'
     response = self.client.get(url)
     self.assertEqual(200, response.status_code)
     self.assertContains(response, 'Dee')
	def test_save_competitor(self):
		dee = Competitor()
		dee.name = 'Delilian Alford'
		dee.nick_name = 'Dee'
		dee.no = 1
		self.assertFalse(dee.id) # before save , no id
		dee.save()
		self.assertTrue(dee.id) # id is auto generated after saved

		dee_id = dee.id
		dee = Competitor.objects.get(id=dee_id)
		self.assertEqual('Delilian Alford' , dee.name)
		self.assertEqual('Dee' , dee.nick_name)
		self.assertEqual(1 , dee.no)
示例#6
0
    def test_vote(self):
	dee = Competitor()
	dee.name = 'Delilian Alford'
	dee.nick_name = 'Dee'
	dee.no = 1
	dee.save()

	url = '/thestar/vote/?no=1'
	response = self.client.get(url)
	self.assertEqual(200, response.status_code)
	number_of_votes_for_dee = Vote.objects.all().count()
	self.assertEqual(1, number_of_votes_for_dee)

	number_of_votes_for_dee = Vote.objects.all().count()
	self.assertEqual(1, number_of_votes_for_dee)
    def test_save_competitor(self):
        """
        The star should have these fields
        """
        kangsom = Competitor()
        kangsom.name = "Tanatat Chaiyaat"
        kangsom.nick_name = "Kangsom"
        kangsom.no = 8
        self.assertFalse(kangsom.id)
        kangsom.save()
        self.assertTrue(kangsom.id)

        kangsom_id = kangsom.id
        kangsom = Competitor.objects.get(id=kangsom_id)
        self.assertEqual('Tanatat Chaiyaat', kangsom.name)
        self.assertEqual('Kangsom', kangsom.nick_name)
        self.assertEqual(8, kangsom.no)