def test_writing_new_datapackage(basic, redirect_userdata): rwr = rower.Rower("animals") rwr.define_RoWs() rwr.label_RoWs() dp = rwr.save_data_package("foo", "bar") assert len(rower.Rower("animals").list_existing()) == 8 assert "foo" in rower.Rower("animals").list_existing()[-1]
def test_with_ecoinvent_generic(): assert not len(Database('animals')) animal_data = { ('animals', 'dogo'): { 'name': 'dogs', 'reference product': 'dog', 'exchanges': [], 'unit': 'kilogram', 'location': 'BR', }, ('animals', 'st bernhard'): { 'name': 'dogs', 'reference product': 'dog', 'exchanges': [], 'unit': 'kilogram', 'location': 'CH', }, ('animals', 'mutt'): { 'name': 'dogs', 'reference product': 'dog', 'exchanges': [], 'unit': 'kilogram', 'location': 'RoW', }, } db = Database('animals') db.write(animal_data) rwr = rower.Rower('animals') rwr.load_existing(rwr.EI_GENERIC) rwr.define_RoWs() rwr.label_RoWs() assert get_activity(('animals', 'mutt'))['location'] == "RoW_88"
def test_userdata_redirect(basic, redirect_userdata): rwr = rower.Rower("animals") rwr.define_RoWs() rwr.label_RoWs() dp = rwr.save_data_package("foo", "bar") assert "rower" not in dp assert "pytest" in dp
def test_locations_changed_as_expected(basic): rwr = rower.Rower("animals") rwr.define_RoWs() rwr.label_RoWs() assert get_activity(('animals', 'mutt pup'))['location'] == 'RoW_user_0' assert get_activity(('animals', 'mutt'))['location'] == 'RoW_user_0' assert get_activity(('animals', 'moggy'))['location'] == 'RoW_user_1'
def test_custom_exclusions(basic, redirect_userdata): rwr = rower.Rower("animals") rwr.define_RoWs(default_exclusions=('foo', 'bar')) expected = { 'RoW_user_0': ('CN', 'DE', 'bar', 'foo'), 'RoW_user_1': ('IR', 'bar', 'foo'), } assert rwr.user_rows == expected
def test_without_default_exclusions(basic, redirect_userdata): rwr = rower.Rower("animals") rwr.define_RoWs(default_exclusions=False) expected = { 'RoW_user_0': ('CN', 'DE'), 'RoW_user_1': ('IR', ), } assert rwr.user_rows == expected
def test_with_default_exclusions(basic, redirect_userdata): rwr = rower.Rower("animals") rwr.define_RoWs() expected = { 'RoW_user_0': ('AQ', 'AUS-AC', 'Bajo Nuevo', 'CN', 'Clipperton Island', 'Coral Sea Islands', 'DE'), 'RoW_user_1': ('AQ', 'AUS-AC', 'Bajo Nuevo', 'Clipperton Island', 'Coral Sea Islands', 'IR'), } assert rwr.user_rows == expected
def test_with_ecoinvent_specific_shortcut(): assert not len(Database('animals')) animal_data = { ('animals', "6ccf7e69afcf1b74de5b52ae28bbc1c2"): { 'name': 'dogs', 'reference product': 'dog', 'exchanges': [], 'unit': 'kilogram', 'location': 'RoW', }, } db = Database('animals') db.write(animal_data) rwr = rower.Rower('animals') rwr.apply_existing_activity_map(rwr.EI_3_4_CONSEQUENTIAL) assert get_activity( ('animals', "6ccf7e69afcf1b74de5b52ae28bbc1c2"))['location'] == "RoW_64"
def test_existing_ecoinvent_present(basic, redirect_userdata): assert len(rower.Rower("animals").list_existing()) == 7
def setUp(self): self.rower = rower.Rower()