def test_quantity_pass(self): """ Discount Code Validate Quantity - Tests if the function runs without an exception :return: """ schema = DiscountCodeSchemaTicket() original_data = {'data': {}} data = {'min_quantity': 10, 'max_quantity': 20, 'tickets_number': 30} DiscountCodeSchemaTicket.validate_quantity(schema, data, original_data)
def test_quantity_max_gt_tickets_number(self): """ Discount Code Validate Quantity - Tests if exception is raised when max_quantity greater than ticket_number :return: """ schema = DiscountCodeSchemaTicket() original_data = {'data': {}} data = {'min_quantity': 10, 'max_quantity': 30, 'tickets_number': 20} with self.assertRaises(UnprocessableEntityError): DiscountCodeSchemaTicket.validate_quantity(schema, data, original_data)
def test_quantity_db_populate(self): """ Discount 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 = DiscountCodeSchemaTicket() DiscountCodeFactory() original_data = {'data': {'id': 1}} data = {} DiscountCodeSchemaTicket.validate_quantity(schema, data, original_data)
def test_quantity_pass(self): """ Discount Code Validate Quantity - Tests if the function runs without an exception :return: """ schema = DiscountCodeSchemaTicket() original_data = { 'data': {} } data = { 'min_quantity': 10, 'max_quantity': 20, 'tickets_number': 30 } DiscountCodeSchemaTicket.validate_quantity(schema, data, original_data)
def test_quantity_max_gt_tickets_number(self): """ Discount Code Validate Quantity - Tests if exception is raised when min_quantity greater than max :return: """ schema = DiscountCodeSchemaTicket() original_data = { 'data': {} } data = { 'min_quantity': 10, 'max_quantity': 30, 'tickets_number': 20 } with self.assertRaises(UnprocessableEntity): DiscountCodeSchemaTicket.validate_quantity(schema, data, original_data)
def test_quantity_db_populate(self): """ Discount Code Validate Quantity - Tests if validation works on values stored in db and not given in 'data' :return: """ with app.test_request_context(): schema = DiscountCodeSchemaTicket() obj = DiscountCodeFactory() db.session.add(obj) db.session.commit() original_data = { 'data': { 'id': 1 } } data = {} DiscountCodeSchemaTicket.validate_quantity(schema, data, original_data)