def test_date_db_populate(self):
        """
        Sessions Validate Date - Tests if validation works on values stored in db and not given in 'data'
        :return:
        """
        with self.app.test_request_context():
            schema = SessionSchema()
            SessionFactory()

            original_data = {'data': {'id': 1}}
            data = {}
            SessionSchema.validate_fields(schema, data, original_data)
示例#2
0
 def test_date_pass(self):
     """
     Sessions Validate Date - Tests if the function runs without an exception
     :return:
     """
     schema = SessionSchema()
     original_data = {'data': {}}
     data = {
         'starts_at':
         datetime(2099, 8, 4, 12, 30, 45).replace(tzinfo=timezone('UTC')),
         'ends_at':
         datetime(2099, 9, 4, 12, 30, 45).replace(tzinfo=timezone('UTC'))
     }
     SessionSchema.validate_fields(schema, data, original_data)
示例#3
0
 def test_date_start_gt_end(self):
     """
     Sessions Validate Date - Tests if exception is raised when ends_at is before starts_at
     :return:
     """
     schema = SessionSchema()
     original_data = {'data': {}}
     data = {
         'starts_at':
         datetime(2099, 9, 4, 12, 30, 45).replace(tzinfo=timezone('UTC')),
         'ends_at':
         datetime(2099, 8, 4, 12, 30, 45).replace(tzinfo=timezone('UTC'))
     }
     with self.assertRaises(UnprocessableEntity):
         SessionSchema.validate_fields(schema, data, original_data)