lime-test documentation

lime-test helps you write tests for code that makes use of the Lime CRM platform, such as plugins or non-core packages. It’s implemented as a plugin to pytest, which gives you a set of ready made fixtures that you can use for the more basic types of tests for Lime. For more control, you are encouraged to use the available helper functions that allows you to create more pointed test code.

The following example uses the core_app fixture, which loads a complete LimeApplication with a set of lime types defined that closely matches the current state of the lime-core database. It also loads a complete database to memory that is disregarded after the test ends to ensure that multiple tests don’t interfere with each other.

The code we want to test:

def average(limeobjects, propname):
    values = [o.get_property(propname).value for o in limeobjects]
    return sum(values) / len(values)

The code we can use to test it:

def test_average(core_app):
    Deal = core_app.limetypes.deal
    deals = [
        Deal(value=2),
        Deal(value=4)
    ]
    assert average(deals, 'value') == 3

Contents:

Indices and tables