Ejemplo n.º 1
0
 def _valid_sync_response(self, sync_result):
     self.assertIn("to_add", sync_result.keys())
     self.assertIn("to_remove", sync_result.keys())
     self.assertIn("to_update", sync_result.keys())
     self.assertTrue(
         all(
             Validator.validate_expense_simple(e)
             for e in sync_result['to_add']))
     self.assertTrue(
         all(
             Validator.validate_expense_simple(e)
             for e in sync_result['to_update']))
     self.assertTrue(
         all(
             Validator.validate_property(exp_id, 'id')
             for exp_id in sync_result['to_remove']))
Ejemplo n.º 2
0
def validate_get_expenses_list(property_name,
                               property_value,
                               expense_id,
                               ordering_direction,
                               batch_size,
                               none_is_ok=True):
    assert property_name in expense_schema['properties'].keys(
    ), "%s is not a valid expense property" % property_name

    if property_value:
        assert Validator.validate_property(property_value, property_name), '%s is not a valid value for %s' % \
                                                                           (str(property_value), property_name)

    assert OrderingDirection.is_member(
        ordering_direction), ApiError.INVALID_ORDER_PARAM

    if property_value:
        assert expense_id, "If a property_value is set, the start_from_id is mandatory"

    assert batch_size < MAX_BATCH_SIZE, ApiError.BATCH_SIZE_EXCEEDED
    assert batch_size > 0, ApiError.INVALID_BATCH_SIZE