コード例 #1
0
 def create_test_data(self):
     self.clear_tables()
     Artists(artist='test', email='*****@*****.**').save()
     Artworks(artist=artist_db.artist_query('test'), artwork_name='test_art_1', price=123, available=False).save()
     Artworks(artist=artist_db.artist_query('test'), artwork_name='test_art_2', price=123).save()
     Artworks(artist=artist_db.artist_query('test'), artwork_name='test_art_3', price=123).save()
     Artists(artist='testNoArt', email='*****@*****.**').save()
コード例 #2
0
 def test_search_for_all_by_artist_no_art_in_db(self):
     self.clear_tables()
     self.create_test_data()
     artist_name = artist_db.artist_query('testNoArt').get()
     result = artist_db.search_all_by_artist(artist_name)
     art_count = result.count()
     self.assertEqual(art_count, 0)
コード例 #3
0
 def test_search_for_all_by_artist_in_db(self):
     self.clear_tables()
     self.create_test_data()
     index_count = 0
     test_list = ['test_art_1', 'test_art_2', 'test_art_3']
     artist_name = artist_db.artist_query('test').get()
     result = artist_db.search_all_by_artist(artist_name)
     for art in result:
         self.assertEqual(test_list[index_count], art.artwork_name)
         index_count += 1
コード例 #4
0
def add_artist():
    artist_name = ui.get_name()
    # artist query used to insure that the artist is not already in the database to avoid DB unique constraint error
    if artist_query(artist_name).count() == 0:
        email = ui.get_email()
        try:
            create_new_artist(artist_name, email)
        except EntryError:
            raise EntryError('Error adding artist\n')
    else:
        print('Artist already exists\n')
コード例 #5
0
def add_art():
    artist_name = artist_query(ui.get_name())
    art_name = ui.get_art_name()
    value = ui.get_value()
    # if nothing is returnered from the artist query for the artist name, no attempt will be made to create the art in the db
    if artist_name.count() == 0:
        print('No artist in db\n')
    else:
        try:
            create_art_entry(artist_name, art_name, value)
        except IntegrityError as e:
            raise EntryError('No artist by that name in DB')
コード例 #6
0
 def test_artist_query_not_in_database(self):
     self.clear_tables()
     self.create_test_data()
     result = artist_db.artist_query('test_name_not_in_db')
     self.assertEqual(result, '')
コード例 #7
0
 def test_create_art_non_positive_float_price(self):
     self.clear_tables()
     with self.assertRaises(EntryError):
         artist_db.create_art_entry(artist_db.artist_query('test'), 'new_art', -500)
コード例 #8
0
 def test_art_name_already_exists(self):
     self.clear_tables()
     self.create_test_data()
     with self.assertRaises(EntryError):
         artist_db.create_art_entry(artist_db.artist_query('test'), 'test_art_2', 123)
コード例 #9
0
 def test_create_art_artist_exists(self):
     self.clear_tables()
     self.create_test_data()
     artist_db.create_art_entry(artist_db.artist_query('test'), 'new_art', 500)
     result = Artworks.select().where(Artworks.artwork_name == 'new_art').get()
     self.assertEqual(result.artwork_name, 'new_art')
コード例 #10
0
 def test_artist_query_in_database(self):
     self.clear_tables()
     self.create_test_data()
     result = artist_db.artist_query('test').get()
     self.assertEqual(result.artist, 'test')
コード例 #11
0
def search_by_artist_available():
    name = ui.get_name()
    artist_object = artist_query(name)
    artwork_objects = search_by_available(artist_object)
    utility.artwork_output(artwork_objects)