Ejemplo n.º 1
0
 def test_artwork_repects_unique_name(self):
     name = "painting"
     price = 100
     Artwork.create(artist=self.artist, name=name, price=price, sold=False)
     with self.assertRaises(IntegrityError):
         Artwork.create(artist=self.artist,
                        name=name,
                        price=price,
                        sold=False)
Ejemplo n.º 2
0
 def test_artwork_created(self):
     name = "painting"
     price = 100
     artwork = Artwork.create(artist=self.artist,
                              name=name,
                              price=price,
                              sold=False)
     self.assertTrue(artwork.name == "painting")
Ejemplo n.º 3
0
def add_artwork(artist_id_in, artwork_name_in, price_in, available_in):
    try:
        artwork = Artwork.create(artist_id=artist_id_in,
                                 artwork_name=artwork_name_in,
                                 price=price_in,
                                 available=available_in)
        artwork.save()
        return 'Artwork saved.'
    except DatabaseError:  # as de:
        #return de
        return 'There was an error in adding the artwork. Make sure it isn\'t already in database.'
Ejemplo n.º 4
0
def create():
    try:
        artist_control.show_all()
        artist = artist_control.get_by_id()
        name = get_artwork_name()
        price = get_artwork_price()
        sold = False
        artwork = Artwork.create(
            artist=artist, name=name, price=price, sold=sold)
        ui.display('Success')
        ui.display(format_artwork(artwork))

    except IntegrityError:
        ui.display('Artwork already exists')
Ejemplo n.º 5
0
 def test_artwork_can_be_retrieved_by_user(self):
     name = "paintings"
     price = 100.24
     Artwork.create(artist=self.artist, name=name, price=price, sold=False)
     Artwork.create(artist=self.artist,
                    name=f"{name}1",
                    price=price,
                    sold=False)
     Artwork.create(artist=self.artist,
                    name=f"{name}2",
                    price=price,
                    sold=False)
     self.assertEqual(len(self.artist.artworks), 3)
Ejemplo n.º 6
0
 def test_artwork_repects_foreign_key_constraint(self):
     name = "painting"
     price = 100
     with self.assertRaises(IntegrityError):
         Artwork.create(name=name, price=price, sold=False)