예제 #1
0
 def test_empty_artist(self):
     a = Artist()
     try:
         a.save()
         self.fail('Should have thrown IntegrityError')
     except IntegrityError:
         pass
예제 #2
0
    def test_media_string(self):

        a = Artist(name='z')
        a.save()
        m = ArtistMedia(artist=a, webpage='www.www.com')
        m.save()
        self.assertEqual(super(ArtistMedia,m).__str__(), 'www.www.com')
예제 #3
0
    def test_artist_url_2(self):
        a = Artist(id=1,name='Artist One')
        a.save()

        a = Artist(id=2,name='Artist Two')
        a.save()

        a = Artist(id=3,name='Artist Three')
        a.save()
        self.assertEqual(a.get_absolute_url(),'/artists/{:d}/'.format(a.id))
예제 #4
0
    def test_save_media(self):

        a = Artist(name='z')
        a.save()
        m = ArtistMedia(artist=a)
        m.save()

        m = ArtistMedia.objects.get(artist=a)
        self.assertIsNotNone(m)
        self.assertEqual(m.artist,a)
예제 #5
0
    def test_empty_media(self):

        a = Artist(name='z')
        a.save()
        m = ArtistMedia(artist=a)
        try:
            m.save()
            self.fail('Should have thrown an Exception')
        except:
            pass
예제 #6
0
    def test_get_artist(self):

        # test artist
        a = Artist(name='Artist Name',label='Artist Label',origin='Artist City',genre='Artist Genre')
        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.genre,'Artist Genre')
예제 #7
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)
예제 #8
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)
예제 #9
0
class ArtistAPITest(APITestCase):
	def setUp(self):
		self.stage = Stage(id=1, name="new stage")
		self.stage.save()
		self.artist = Artist(id=1, stage=self.stage, name="new artist")
		self.artist.save()

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

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

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

	def testPost(self):
		response = self.client.post("/api/artists/1/", {'artist':1})
		self.assertEqual(status.HTTP_405_METHOD_NOT_ALLOWED, response.status_code)
예제 #10
0
	def setUp(self):
		self.stage = Stage(id=1, name="new stage")
		self.stage.save()
		self.artist = Artist(id=1, stage=self.stage, name="new artist")
		self.artist.save()
예제 #11
0
    def test_artist_url_1(self):

        a = Artist()
        a.save()
        self.assertEqual(a.get_absolute_url(),'/artists/{:d}/'.format(a.id))
예제 #12
0
 def create_artist(self, artist_data):
     a=Artist(**artist_data)
     a.save()
     self.stdout.write("+created artist: "+artist_data['name'])
     return a