Example #1
0
 def test_sponsor_name(self):
     n = 'n'*401
     s = Sponsor(name=n)
     try:
         s.save()
         self.fail('Should have thrown an exception')
     except:
         pass
Example #2
0
    def test_get_sponsor(self):

        # test artist
        a = Sponsor(name='sponsor', industry='business')
        a.save()
        b = Sponsor.objects.get(name='sponsor')
        self.assertIsNotNone(b)
        self.assertEqual(b.name,'sponsor')
        self.assertEqual(b.industry,'business')
Example #3
0
    def test_sponsor_url_1(self):
        s = Sponsor(id=1, name='Sponsor One')
        s.save()

        s = Sponsor(id=2, name='Sponsor Two')
        s.save()

        s = Sponsor(id=3, name='Sponsor Three')
        s.save()

        self.assertEqual(s.get_absolute_url(),'/sponsors/{:d}/'.format(s.id))
        self.assertEqual(s.name,'Sponsor Three')
Example #4
0
class SponsorsAPITest(APITestCase):
	def setUp(self):
		self.stage = Stage(id=1, name="new stage")
		self.stage.save()
		self.sponsor = Sponsor(id=1, stage = self.stage, name = "new sponsor")
		self.sponsor.save()

	def tearDown(self):
		self.stage.delete()

	def testStageGet(self):
		response = self.client.get("/api/sponsors/1/", format="application/json")
		self.assertEqual(status.HTTP_200_OK, response.status_code)

	def testStageGet2(self):
		response = self.client.get("/api/sponsors/2/", format="application/json")
		self.assertEqual(status.HTTP_404_NOT_FOUND, response.status_code)

	def testPost(self):
		response = self.client.post("/api/sponsors/1/", {'sponsor':1})
		self.assertEqual(status.HTTP_405_METHOD_NOT_ALLOWED, response.status_code)
Example #5
0
	def setUp(self):
		self.stage = Stage(id=1, name="new stage")
		self.stage.save()
		self.sponsor = Sponsor(id=1, stage = self.stage, name = "new sponsor")
		self.sponsor.save()
Example #6
0
 def test_empty_sponsor(self):
     s = Sponsor()
     s.save()
     self.assertIsNotNone(s)
Example #7
0
 def test_get_sponsor_name(self):
     s = Sponsor(name='Sponsor Name')
     s.save()
     s = Sponsor.objects.get(name='Sponsor Name')
     self.assertIsNotNone(s)
     self.assertEqual(s.__str__(),'Sponsor Name')
Example #8
0
 def test_save_sponsor(self):
     s = Sponsor(name='Sponsor Name')
     s.save()
     z = Sponsor.objects.get(name='Sponsor Name')
     self.assertIsNotNone(z)
     self.assertEqual(s, z)
Example #9
0
 def test_empty_sponsor(self):
     s = Sponsor()
     s.save()
     s = Sponsor.objects.get(pk=1)
     self.assertIsNotNone(s)
     self.assertEqual(s.name,'')
Example #10
0
 def test_save_sponsor(self):
     s = Sponsor(name='Sponsor Name')
     s.save()
     s = Sponsor.objects.get(pk=1)
     self.assertIsNotNone(s)
     self.assertEqual(s.name,'Sponsor Name')
Example #11
0
 def create_sponsor(self, sponsor_data):
     a=Sponsor(**sponsor_data)
     a.save()
     self.stdout.write("+created sponsor: "+sponsor_data['name'])
     return a