Exemplo n.º 1
0
def test_task_line(config, request_with_config, estimation, unity, tva,
                   product, product_without_tva):
    schema = get_add_edit_taskline_schema()
    request_with_config.context = estimation
    schema = schema.bind(request=request_with_config)
    value = {
        'description': u'test',
        'cost': 450,
        'quantity': 1,
        'unity': u'Mètre',
        'tva': 20.00,
        'product_id': product.id
    }
    assert schema.deserialize(value) == {
        'description': u'test',
        'cost': 45000000,
        'quantity': 1.0,
        'unity': u'Mètre',
        'tva': 2000,
        'product_id': product.id,
        'order': 1
    }
    value = {
        'description': u'test',
        'cost': 450,
        'quantity': 1,
        'unity': u'Mètre',
        'tva': 20.00,
        'product_id': product_without_tva.id
    }
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
Exemplo n.º 2
0
def test_task_line_quantity():
    schema = get_add_edit_taskline_schema(includes=('quantity', ))
    schema = schema.bind()
    value = {'quantity': 1}
    assert schema.deserialize(value) == value
    value = {}
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
Exemplo n.º 3
0
def test_task_line_description():
    schema = get_add_edit_taskline_schema(includes=('description', ))
    schema = schema.bind()
    value = {'description': "test\n"}
    assert schema.deserialize(value) == {'description': 'test'}
    value = {'description': "\n"}
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
Exemplo n.º 4
0
    def get_schema(self, submitted):
        """
        Return the schema for TaskLine add/edition

        :param dict submitted: The submitted datas
        :returns: A colander.Schema
        """
        excludes = ('group_id',)
        return get_add_edit_taskline_schema(excludes=excludes)
Exemplo n.º 5
0
    def get_schema(self, submitted):
        """
        Return the schema for TaskLine add/edition

        :param dict submitted: The submitted datas
        :returns: A colander.Schema
        """
        excludes = ('group_id',)
        return get_add_edit_taskline_schema(excludes=excludes)
Exemplo n.º 6
0
def test_task_line_unity(unity):
    schema = get_add_edit_taskline_schema(includes=('unity', ))
    schema = schema.bind()
    value = {'unity': u"Mètre"}
    assert schema.deserialize(value) == value
    value = {'unity': u"Panies"}
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
    value = {}
    schema.deserialize(value)
Exemplo n.º 7
0
def test_task_line_tva(tva):
    schema = get_add_edit_taskline_schema(includes=('tva', ))
    schema = schema.bind()
    value = {'tva': 20.00}
    assert schema.deserialize(value) == {'tva': 2000}
    value = {'tva': 21.00}
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
    value = {}
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
Exemplo n.º 8
0
def test_task_line_cost():
    schema = get_add_edit_taskline_schema(includes=('cost', ))
    schema = schema.bind()
    value = {'cost': 12.50}
    assert schema.deserialize(value) == {'cost': 1250000}
    value = {'cost': 'a'}
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
    value = {}
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
Exemplo n.º 9
0
def test_task_line_product_id(config, request_with_config, estimation,
                              product):
    schema = get_add_edit_taskline_schema(includes=('product_id', ))
    request_with_config.context = estimation
    schema = schema.bind(request=request_with_config)
    value = {'product_id': product.id}
    assert schema.deserialize(value) == value
    value = {'product_id': product.id + 1}
    with pytest.raises(colander.Invalid):
        schema.deserialize(value)
    value = {}
    assert schema.deserialize(value) == value