Exemplo n.º 1
0
    def test_ensure_various_artists_return_existing(self):
        """
        Test our App.ensure_various_artists() function and ensure that
        it returns an existing 'Various' artist if one exists.
        """
        App.ensure_various_artists()
        self.assertEqual(Artist.objects.count(), 1)
        ar = Artist.objects.get()
        ar_pk = ar.pk
        self.assertEqual(ar.name, 'Various')
        self.assertEqual(ar.various, True)

        self.assertEqual(App.ensure_various_artists(), False)
        ar = Artist.objects.get()
        self.assertEqual(ar.pk, ar_pk)
        self.assertEqual(ar.name, 'Various')
        self.assertEqual(ar.various, True)
Exemplo n.º 2
0
 def test_ensure_various_artists_create_artist(self):
     """
     Test our App.ensure_various_artists() function and ensure that
     it creates a Various artist if needed.
     """
     self.assertEqual(Artist.objects.count(), 0)
     self.assertEqual(App.ensure_various_artists(), True)
     self.assertEqual(Artist.objects.count(), 1)
     ar = Artist.objects.get()
     self.assertEqual(ar.name, 'Various')
     self.assertEqual(ar.various, True)