示例#1
0
 def test_search_artwork_by_artist(
         self):  # Try pulling up all artwork for a given artist
     artworkDB.add_artist('Bob', '*****@*****.**')
     artworkDB.add_artwork('Bob', 'Life of Insanity', 90, False)
     artwork = artworkDB.search_artwork_by_artist('Bob')
     for art in artwork:
         self.assertEqual(art.name, 'Life of Insanity')
示例#2
0
    def test_add_artist(
        self
    ):  # Tests to see if it can retrieve an artists data after adding it to the database
        self.add_generic_sample_data()
        artworkDB.add_artist('Matthew', '*****@*****.**')

        artist = Artist.get_or_none(Artist.name == 'Matthew',
                                    Artist.email == '*****@*****.**')
        self.assertIsNotNone(artist)
示例#3
0
 def test_add_artwork(
     self
 ):  # Try to retrieve data about an artwork after adding it to the database
     artworkDB.add_artist('Bob', '*****@*****.**')
     artworkDB.add_artwork('Bob', 'Air is Empathy', 6600, True)
     artwork = Artwork.get_or_none(Artwork.name == 'Air is Empathy',
                                   Artwork.price == 6600,
                                   Artwork.available == True)
     self.assertIsNotNone(artwork)
示例#4
0
 def test_search_available_by_artist(
     self
 ):  # Makes sure only available artwork is returned for this function
     artworkDB.add_artist('Bob', '*****@*****.**')
     artworkDB.add_artwork('Bob', 'Life of Insanity', 90, True)
     artworkDB.add_artwork('Bob', 'Modern Age', 400, False)
     artworkDB.add_artwork('Bob', 'Rain and Snow', 448, False)
     artwork = artworkDB.search_available_by_artist('Bob')
     for art in artwork:
         self.assertEqual(art.name, 'Life of Insanity')
示例#5
0
    def add_generic_sample_data(
            self
    ):  # Adds sample data for my test methods to work with if needed
        artworkDB.add_artist('Bob', '*****@*****.**')
        artworkDB.add_artist('Maria', '*****@*****.**')

        artworkDB.add_artwork('Bob', 'Simplicity Defined', 3400.00, True)
        artworkDB.add_artwork('Bob', 'Life Without Entropy', 8200.00, True)
        artworkDB.add_artwork('Bob', 'Love in the Winter', 2200.00, False)

        artworkDB.add_artwork('Maria', 'Waves Abound', 6700.00, False)
        artworkDB.add_artwork('Maria', 'A Distant Mountain', 960.00, False)
        artworkDB.add_artwork('Maria', 'In the End', 7600.00, True)
示例#6
0
 def test_add_artist_email_null(
         self):  # Makes sure database won't accept a null artist email
     with self.assertRaises(IntegrityError):
         artworkDB.add_artist('Harry', None)
示例#7
0
 def test_add_artist_name_null(
         self):  # Make sure database won't accept a null artist name
     with self.assertRaises(IntegrityError):
         artworkDB.add_artist(None, '*****@*****.**')
示例#8
0
 def test_add_artist_email_already_exists(
         self):  # Makes sure an artist's email can't be added twice
     self.add_generic_sample_data()
     with self.assertRaises(IntegrityError):
         artworkDB.add_artist('Bobby', '*****@*****.**')
示例#9
0
 def test_add_artist_name_already_exists(
         self):  # Makes sure an artist can't be added twice to the database
     self.add_generic_sample_data()
     with self.assertRaises(IntegrityError):
         artworkDB.add_artist('Bob', '*****@*****.**')
示例#10
0
def add_artist():
    artist_name = view.get_user_input('What\'s the name of the new artist?')
    artist_email = view.get_user_input('What\'s the artist\'s email address?')
    print(artworkDB.add_artist(artist_name, artist_email))