コード例 #1
0
 def test_quantity_pass(self):
     """
     Acces Code Validate Quantity - Tests if the function runs without an exception
     :return:
     """
     schema = AccessCodeSchema()
     original_data = {'data': {}}
     data = {'min_quantity': 5, 'max_quantity': 10, 'tickets_number': 30}
     AccessCodeSchema.validate_order_quantity(schema, data, original_data)
コード例 #2
0
 def test_quantity_max_gt_ticket(self):
     """
     Acces Code Validate Quantity - Tests if the exception is raised when max_quantity greater than ticket_number
     :return:
     """
     schema = AccessCodeSchema()
     original_data = {'data': {}}
     data = {'min_quantity': 10, 'max_quantity': 20, 'tickets_number': 15}
     with self.assertRaises(UnprocessableEntityError):
         AccessCodeSchema.validate_order_quantity(schema, data, original_data)
コード例 #3
0
 def test_quantity_min_gt_max(self):
     """
     Acces Code Validate Quantity - Tests if the exception is raised when min tickets > max tickets
     :return:
     """
     schema = AccessCodeSchema()
     original_data = {'data': {}}
     data = {'min_quantity': 10, 'max_quantity': 5, 'tickets_number': 30}
     with self.assertRaises(UnprocessableEntity):
         AccessCodeSchema.validate_order_quantity(schema, data,
                                                  original_data)
コード例 #4
0
    def test_quantity_db_populate(self):
        """
        Acces Code Validate Quantity - Tests if validation works on values stored in db and not given in 'data'
        :return:
        """
        with self.app.test_request_context():
            schema = AccessCodeSchema()
            AccessCodeFactory()

            original_data = {'data': {'id': 1}}
            data = {}
            AccessCodeSchema.validate_order_quantity(schema, data,
                                                     original_data)