def test_find_artist_nonexistent(self):
     self.add_drop()
     self.assertIsNone(viewmodel.find_artist(
         'asdf'))  #no artists in database, will return None
     viewmodel.add_artist('lkjfei', '*****@*****.**')
     self.assertIsNone(viewmodel.find_artist(
         ''))  #even with an artist in the database, this will return None
 def test_delete_artwork_good_data(self):
     self.add_example_artwork()
     artist = viewmodel.find_artist('Yoshitaka Amano')
     self.assertEqual(
         1,
         viewmodel.delete_artwork(
             artist.artist_id,
             'Final Fantasy VI Cover Art'))  #returns that 1 row was deleted
    def add_example_artwork(self):
        '''This creates an artist and artwork which satisfy the requirements of the database'''
        self.add_drop()
        viewmodel.add_artist('Yoshitaka Amano', '*****@*****.**')
        artwork_in = 'Final Fantasy VI Cover Art'
        price_in = 50
        available_in = False

        self.artist = viewmodel.find_artist('Yoshitaka Amano')
        viewmodel.add_artwork(self.artist.id, artwork_in, price_in,
                              available_in)
    def test_get_available_artwork_good_data(self):
        self.add_example_artwork()  #the artwork in here is unavailable
        self.assertEqual(0, len(viewmodel.get_all_available_artwork(
            1)))  #so when searched, it doesn't come up

        viewmodel.add_artist('asdf', '*****@*****.**')
        artist = viewmodel.find_artist('asdf')
        viewmodel.add_artwork(artist.artist_id, 'l;kj', 20000, True)
        self.assertEqual(
            1, len(viewmodel.get_all_available_artwork(artist.artist_id))
        )  #now there is an available artwork, so it returns that data
    def test_add_artwork_good_data(self):
        self.add_drop()
        viewmodel.add_artist('Yoshitaka Amano', '*****@*****.**')
        artwork_in = 'Final Fantasy VI Cover Art'
        price_in = 50
        available_in = False
        self.artist = viewmodel.find_artist('Yoshitaka Amano')

        self.assertEqual(
            'Artwork saved.',
            viewmodel.add_artwork(self.artist.artist_id, artwork_in, price_in,
                                  available_in))
    def test_add_artwork_bad_price(self):
        self.add_drop()
        viewmodel.add_artist('Yoshitaka Amano', '*****@*****.**')
        artwork_in = 'Cloud Concept Art'
        available_in = True

        self.artist = viewmodel.find_artist('Yoshitaka Amano')
        self.assertNotEqual('Artwork saved.',
                            viewmodel.add_artwork(self.artist.artist_id,
                                                  artwork_in, '$50',
                                                  available_in))  #try string
        self.assertNotEqual('Artwork saved.',
                            viewmodel.add_artwork(self.artist.artist_id,
                                                  artwork_in, -5000000,
                                                  available_in))  #try negative
        self.assertNotEqual(
            'Artwork saved.',
            viewmodel.add_artwork(self.artist.artist_id, artwork_in, 999999999,
                                  available_in))  #try over a million
        self.assertNotEqual('Artwork saved.',
                            viewmodel.add_artwork(
                                self.artist.artist_id, artwork_in, -0.0000001,
                                available_in))  #try close to zero