def test_payment_line_task_id():
    schema = get_add_edit_paymentline_schema(includes=('task_id',))
    value = {'task_id': 5}
    assert schema.deserialize(value) == value
    value = {}
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
Example #2
0
def test_payment_line_task_id():
    schema = get_add_edit_paymentline_schema(includes=('task_id', ))
    value = {'task_id': 5}
    assert schema.deserialize(value) == value
    value = {}
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
def test_payment_line_date():
    import datetime
    schema = get_add_edit_paymentline_schema(includes=('date',))
    schema = schema.bind()
    value = {'date': datetime.date.today().isoformat()}
    assert schema.deserialize(value) == {'date': datetime.date.today()}
    value = {}
    assert schema.deserialize(value) == value
def test_payment_line_description():
    schema = get_add_edit_paymentline_schema(includes=('description',))
    schema = schema.bind()
    value = {'description': "test\n"}
    assert schema.deserialize(value) == value
    value = {'description': "\n"}
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
Example #5
0
def test_payment_line_date():
    import datetime
    schema = get_add_edit_paymentline_schema(includes=('date', ))
    schema = schema.bind()
    value = {'date': datetime.date.today().isoformat()}
    assert schema.deserialize(value) == {'date': datetime.date.today()}
    value = {}
    assert schema.deserialize(value) == value
Example #6
0
def test_payment_line_description():
    schema = get_add_edit_paymentline_schema(includes=('description', ))
    schema = schema.bind()
    value = {'description': "test\n"}
    assert schema.deserialize(value) == value
    value = {'description': "\n"}
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
Example #7
0
    def get_schema(self, submitted):
        """
        Return the schema for PaymentLine add/edition

        :param dict submitted: The submitted datas
        :returns: A colander.Schema
        """
        excludes = ('task_id', )
        return get_add_edit_paymentline_schema(excludes=excludes)
Example #8
0
    def get_schema(self, submitted):
        """
        Return the schema for PaymentLine add/edition

        :param dict submitted: The submitted datas
        :returns: A colander.Schema
        """
        excludes = ('task_id',)
        return get_add_edit_paymentline_schema(excludes=excludes)
def test_payment_line_amount():
    schema = get_add_edit_paymentline_schema(includes=('amount',))
    schema = schema.bind()

    value = {'amount': 12.5}
    assert schema.deserialize(value) == {'amount': 1250000}

    value = {'amount': 'a'}
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
    value = {}
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
Example #10
0
def test_payment_line_amount():
    schema = get_add_edit_paymentline_schema(includes=('amount', ))
    schema = schema.bind()

    value = {'amount': 12.5}
    assert schema.deserialize(value) == {'amount': 1250000}

    value = {'amount': 'a'}
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
    value = {}
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
def test_payment_line():
    schema = get_add_edit_paymentline_schema()
    schema = schema.bind()

    value = {
        'task_id': 5,
        'date': datetime.date.today().isoformat(),
        'amount': 12.5,
        'description': u"Description"
    }
    expected_value = {
        'task_id': 5,
        'date': datetime.date.today(),
        'amount': 1250000,
        'description': u"Description",
        'order': 1
    }
    assert schema.deserialize(value) == expected_value
Example #12
0
def test_payment_line():
    schema = get_add_edit_paymentline_schema()
    schema = schema.bind()

    value = {
        'task_id': 5,
        'date': datetime.date.today().isoformat(),
        'amount': 12.5,
        'description': u"Description"
    }
    expected_value = {
        'task_id': 5,
        'date': datetime.date.today(),
        'amount': 1250000,
        'description': u"Description",
        'order': 1
    }
    assert schema.deserialize(value) == expected_value