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
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
def test_csv_lcia_extraction(): fp = os.path.join(CSV_FIXTURES_DIR, "lcia.csv") expected = [ "lcia.csv", [ ["name", "categories", "amount"], ["Aluminium", "Resource::in ground", "42"], ["Uranium ore, 1.11 GJ per kg", "Resource", "1000000"], ], ] assert CSVExtractor.extract(fp) == expected
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