示例#1
0
 def test_get_stage(self):
     s = Stage(name='Stage Name')
     s.save()
     b = Stage.objects.get(pk=1)
     self.assertIsNotNone(b)
     self.assertEqual(b.name,'Stage Name')
     self.assertEqual(b,s)
示例#2
0
 def test_get_stage(self):
     s = Stage(location=2)
     s.save()
     b = Stage.objects.get(location=2)
     self.assertIsNotNone(b)
     self.assertEqual(b.location,2)
     self.assertEqual(b,s)
示例#3
0
 def test_stage_location(self):
     n = 9999999999999999999
     s = Stage(location=n)
     try:
         s.save()
         self.fail('Should have thrown an Exception')
     except:
         pass
示例#4
0
    def test_stage_name(self):
        n = 's'*401
        self.assertEqual(len(n),401)

        s = Stage(name=n)
        try:
            s.save()
            self.fail('Should have thrown an error')
        except:
            pass
示例#5
0
    def test_create_artist(self):
        # setup stage
        s = Stage(name='Stage Name')
        s.save()

        # test artist
        a = Artist(name='Artist Name',label='Artist Label',origin='Artist City',website='http://www.artist.com/',genre='Artist Genre',stage=s)
        self.assertIsNotNone(a)
        self.assertEqual(a.name,'Artist Name')
        self.assertEqual(a.label,'Artist Label')
        self.assertEqual(a.origin,'Artist City')
        self.assertEqual(a.website,'http://www.artist.com/')
        self.assertEqual(a.genre,'Artist Genre')
        self.assertEqual(a.stage,s)
示例#6
0
    def test_empty_artist_with_stage(self):
        # setup stage
        s = Stage(name='Stage Name')
        s.save()

        a = Artist(stage=s)
        a.save()
        a = Artist.objects.get(pk=1)
        self.assertIsNotNone(a)
        self.assertEqual(a.name,'')
        self.assertEqual(a.label,'')
        self.assertEqual(a.origin,'')
        self.assertEqual(a.website,'')
        self.assertEqual(a.genre,'')
        self.assertEqual(a.stage,s)
示例#7
0
    def test_get_artist(self):
        # setup stage
        s = Stage(name='Stage Name')
        s.save()

        # test artist
        a = Artist(name='Artist Name',label='Artist Label',origin='Artist City',website='http://www.artist.com/',genre='Artist Genre',stage=s)
        a.save()
        b = Artist.objects.get(name='Artist Name')
        self.assertIsNotNone(b)
        self.assertEqual(b.name,'Artist Name')
        self.assertEqual(b.label,'Artist Label')
        self.assertEqual(b.origin,'Artist City')
        self.assertEqual(b.website,'http://www.artist.com/')
        self.assertEqual(b.genre,'Artist Genre')
        self.assertEqual(b.stage,s)
示例#8
0
class StagesAPITest(APITestCase):
	def setUp(self):
		self.stage = Stage(id = 1, name="new stage")
		self.stage.save()

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

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

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

	def testPost(self):
		response = self.client.post("/api/stages/1/", {'stage':1})
		self.assertEqual(status.HTTP_405_METHOD_NOT_ALLOWED, response.status_code)
示例#9
0
    def create_stage(self, data):

        s=Stage(**data)
        s.save()
        self.stdout.write("+created: stage: "+data['location'])
        return s