Beispiel #1
0
def test_excel_export_no_params(setup):
    ParameterizedExchange.delete().execute()
    ActivityParameter.delete().execute()
    DatabaseParameter.delete().execute()
    ProjectParameter.delete().execute()
    assert not ProjectParameter.select().count()
    write_lci_csv("example")
Beispiel #2
0
def test_write_lci_sections(setup):
    expected =  [
        ['Database', 'example'],
        ['extra', 'yes please'],
        [],
        ['Database parameters'],
        ['name', 'amount', 'formula', 'database'],
        ['blue', '12.0', '', 'example'],
        ['red', '29.0', '(foo + blue ** 2) / 5', 'example'],
        [],
    ]
    given = CSVExtractor.extract(write_lci_csv(
        "example",
        sections=['database', 'database parameters']
    ))[1]
    assert given == expected

    expected =  [
        ['Activity', 'An activity'],
        ['code', 'A'],
        ['foo', 'bar'],
        ['location', 'GLO'],
        ['unit', 'kg'],
        ['Exchanges'],
        ['name', 'amount', 'location', 'unit', 'type', 'formula', 'original_amount'],
        ['An activity', '1', 'GLO', 'kg', 'production', '', ''],
        ['Another activity', '9.0', 'here', '', 'technosphere', 'foo * bar + 4', '0'],
        [],
        ['Activity', 'Another activity'],
        ['code', 'B'],
        ['location', 'here'],
        ['this', 'that'],
        ['Exchanges'],
        ['name', 'amount', 'location', 'type'],
        ['Another activity', '10', 'here', 'production'],
        []
    ]
    given = CSVExtractor.extract(write_lci_csv(
        "example",
        sections=['activities', 'exchanges']
    ))[1]
    assert given == expected

    expected =  [
        ['Project parameters'],
        ['name', 'amount', 'formula'],
        ['foo', '1.0', 'green / 7'],
        ['green', '7.0', ''],
        [],
    ]
    given = CSVExtractor.extract(write_lci_csv(
        "example",
        sections=['project parameters', 'activity parameters', 'exchanges']
    ))[1]
    assert given == expected
Beispiel #3
0
def test_write_lci_sections(setup):
    expected = [
        ["Database", "example"],
        ["extra", "yes please"],
        [],
        ["Database parameters"],
        ["name", "amount", "formula", "database"],
        ["blue", "12.0", "", "example"],
        ["red", "29.0", "(foo + blue ** 2) / 5", "example"],
        [],
    ]
    given = CSVExtractor.extract(
        write_lci_csv("example", sections=["database", "database parameters"])
    )[1]
    assert given == expected

    expected = [
        ["Activity", "An activity"],
        ["code", "A"],
        ["foo", "bar"],
        ["location", "GLO"],
        ["unit", "kg"],
        ["Exchanges"],
        ["name", "amount", "location", "unit", "type", "formula", "original_amount"],
        ["An activity", "1", "GLO", "kg", "production", "", ""],
        ["Another activity", "9.0", "here", "", "technosphere", "foo * bar + 4", "0"],
        [],
        ["Activity", "Another activity"],
        ["code", "B"],
        ["location", "here"],
        ["this", "that"],
        ["Exchanges"],
        ["name", "amount", "location", "type"],
        ["Another activity", "10", "here", "production"],
        [],
    ]
    given = CSVExtractor.extract(
        write_lci_csv("example", sections=["activities", "exchanges"])
    )[1]
    assert given == expected

    expected = [
        ["Project parameters"],
        ["name", "amount", "formula"],
        ["foo", "1.0", "green / 7"],
        ["green", "7.0", ""],
        [],
    ]
    given = CSVExtractor.extract(
        write_lci_csv(
            "example",
            sections=["project parameters", "activity parameters", "exchanges"],
        )
    )[1]
    assert given == expected
Beispiel #4
0
def test_write_lci_csv_complicated(setup):
    given = CSVExtractor.extract(write_lci_csv("example"))[1]
    expected = CSVExtractor.extract(
        os.path.join(CSV_FIXTURES_DIR, "complicated.csv"))[1]
    assert given == expected
Beispiel #5
0
def test_excel_export_all(setup):
    write_lci_csv("example")