Example #1
0
 def setUp(self):
     super().setUp()
     self.i1_ref = Ingredient.from_params('vodka', True, 40).ref
     self.i2 = Ingredient.from_params('gin', True, 35)
     self.d1 = Dispenser.from_params(0, type='empty')
     self.d2 = Dispenser.from_params(1,
                                     self.i2,
                                     5000,
                                     type='optic',
                                     disabled=False,
                                     dispense_function=lambda a: a)
Example #2
0
 def test_get_drinks(self):
     d = Drink.from_params(name="hi",
                           components=[
                               DrinkComponent.from_params(
                                   ingredient=Ingredient.from_params(
                                       'orange', False),
                                   measure=20)
                           ])
     response = self.client.get('/api/drinks/')
     self.assertEqual(response.status_code, 200)
     self.assertTrue(response.json['drinks'][0]['ref'] == d.ref)
Example #3
0
 def test_get_single_drink(self):
     d = Drink.from_params(name="hi",
                           components=[
                               DrinkComponent.from_params(
                                   ingredient=Ingredient.from_params(
                                       'orange', False),
                                   measure=20)
                           ])
     response = self.client.get('/api/drinks/' + d.ref)
     self.assertEqual(response.json['ref'], d.ref)
     response = self.client.get('/api/drinks/ghnj')
     self.assertEqual(response.status_code, 404)
Example #4
0
    def post(self):
        args = post_parser.parse_args()
        name = args['name']
        alcoholic = args['alcoholic']
        abs = args['abs']

        if alcoholic and not abs:
            abort(400, "alcoholic drinks must specify ABS")
        if Ingredient.query.filter_by(name=name).first():
            abort(409, "Name already in use")
        i = Ingredient.from_params(name, alcoholic, abs)
        return make_response(jsonify(i.as_json()), 201)
Example #5
0
 def setUp(self):
     super().setUp()
     self.i1 = Ingredient.from_params('vodka', True, 40)
     self.i2 = Ingredient.from_params('gin', True, 35)
     self.d1 = Dispenser.from_params(0, self.i1, 1000)
     self.d2 = Dispenser.from_params(1, self.i2, 500)
Example #6
0
 def setUp(self):
     super().setUp()
     self.i1 = Ingredient.from_params('vodka', True, 40).ref
     self.i2 = Ingredient.from_params('gin', True, 35).ref
     self.i3 = Ingredient.from_params('orange juice', False).ref
Example #7
0
 def setUp(self):
     super().setUp()
     Ingredient.from_params('vodka', True, 40)
     Ingredient.from_params('gin', True, 35)
     Ingredient.from_params('orange juice', False)