def test_add_art_with_missing_data(self): self.remake_tables() art1 = Art(artist=1, name='art1') with self.assertRaises(ArtError): add_art(art1)
def test_add_art_with_ununique_name(self): self.remake_tables() self.add_test_data() art1 = Art(artist=1, name='art1', price=0.50) with self.assertRaises(ArtError): add_art(art1)
def test_new_art_available_true(self): self.remake_tables() Artist.create(name='ats1', email_address='*****@*****.**') art1 = Art(artist=1, name='art1', price=5) add_art(art1) available_true = get_art_by_availability() self.assertEqual(art1, available_true[0])
def test_get_art_by_id(self): self.remake_tables() Artist.create(name='ats1', email_address='*****@*****.**') art1 = Art(artist=1, name='art1', price=5) add_art(art1) art1 = get_art_by_id(1) self.assertIsNotNone(art1)
def test_add_art_with_existing_artist(self): self.remake_tables() Sethany = Artist.create(name='ats1', email_address='*****@*****.**') art1 = Art(artist=1, name='art1', price=0.50) add_art(art1) fetch_art = Art.select().where(Art.name == 'art1') self.assertTrue(art1 == fetch_art[0], msg=f'{art1} is not the same as {fetch_art}')
def test_change_available_to_false_from_true(self): self.remake_tables() Artist.create(name='ats1', email_address='*****@*****.**') art1 = Art(artist=1, name='art1', price=5, available=True) add_art(art1) art1 = get_art_by_availability() self.assertTrue(art1[0].available) change_available(1) art1 = get_art_by_availability() self.assertTrue(art1 == [])
def test_delete_art(self): self.remake_tables() Artist.create(name='ats1', email_address='*****@*****.**') art1 = Art(artist=1, name='art1', price=5) add_art(art1) all_art = get_all_art() self.assertTrue(all_art != []) delete_art(1) all_art = get_all_art() self.assertTrue(all_art == [])
def test_add_art_with_empty_artist_table(self): self.remake_tables() with self.assertRaises(ArtError): art1 = Art(artist=1, name='art1', price=0.50) add_art(art1)