Beispiel #1
0
 def test_invalid_wine_creation(self):
     wine = Wine(**self.invalid_wine_data)
     with self.assertRaises(ValidationError) as context:
         wine.full_clean()
     self.assertEqual(
         set(context.exception.error_dict),
         set(['name', 'winery', 'wine_line', 'varietal'])
     )
Beispiel #2
0
 def handle(self, *args, **options):
     with open('_winemag.csv') as csvfile:
         reader = csv.DictReader(csvfile)
         for row in reader:
             rowPoints = int(row['points'])
             if not row['price']: row['price'] = 999
             rowPrice = float(row['price'])
             p = Wine(name=row['title'],
                      description=row['description'],
                      price=rowPrice,
                      points=rowPoints,
                      ratio=rowPoints / rowPrice)
             p.save()
 def PUT(request, wine_id):
     fields = str_to_dict( request.raw_post_data )
     wine   = Wine( **fields )
     wine.save()
Beispiel #4
0
 def test_wine_creation(self):
     wine = Wine(**self.wine_creation_data)
     wine.full_clean()
     wine.save()
 def POST(request):
     fields = query_to_dict( request.POST )
     wine   = Wine( **fields )
     wine.save()
     return wine