コード例 #1
0
def test_write_only_activity_parameters_no_activate_others(no_init):
    Database("PCB").register()
    obj = ExcelImporter()
    obj.db_name = "PCB"
    obj.data = deepcopy(DATA)
    obj.write_database(activate_parameters=False)

    NEW = [
        {
            "code": "45cb34db4147e510a2561cceec541f6b",
            "database": "PCB",
            "exchanges": [],
            "name": "unmounted printed circuit board",
            "type": "process",
            "unit": "square meter",
            "parameters": [{"name": "something_test", "amount": 2, "formula": "3 + 2"}],
        }
    ]
    obj = ExcelImporter()
    obj.db_name = "PCB"
    obj.write_activity_parameters(NEW)

    assert ActivityParameter.select().count() == 1
    assert ActivityParameter.get().formula == "3 + 2"
    assert "parameters" not in get_activity(("PCB", "45cb34db4147e510a2561cceec541f6b"))
    assert "parameters" in get_activity(("PCB", "32aa5ab78beda5b8c8efbc89587de7a5"))
コード例 #2
0
def test_write_only_activity_parameters_no_activate_others(no_init):
    Database("PCB").register()
    obj = ExcelImporter()
    obj.db_name = "PCB"
    obj.data = deepcopy(DATA)
    obj.write_database(activate_parameters=False)

    NEW = [{
        'code':
        '45cb34db4147e510a2561cceec541f6b',
        'database':
        'PCB',
        'exchanges': [],
        'name':
        'unmounted printed circuit board',
        'type':
        'process',
        'unit':
        'square meter',
        'parameters': [{
            'name': 'something_test',
            'amount': 2,
            'formula': '3 + 2'
        }],
    }]
    obj = ExcelImporter()
    obj.db_name = "PCB"
    obj.write_activity_parameters(NEW)

    assert ActivityParameter.select().count() == 1
    assert ActivityParameter.get().formula == '3 + 2'
    assert 'parameters' not in get_activity(
        ('PCB', '45cb34db4147e510a2561cceec541f6b'))
    assert 'parameters' in get_activity(
        ('PCB', '32aa5ab78beda5b8c8efbc89587de7a5'))
コード例 #3
0
def test_write_only_activity_parameters(no_init):
    assert not ActivityParameter.select().count()
    Database("PCB").register()
    obj = ExcelImporter()
    obj.db_name = "PCB"
    obj.data = deepcopy(DATA)
    obj.write_database()
    assert ActivityParameter.select().count() == 1
    assert ActivityParameter.get().amount != 7

    NEW = [{
        'code':
        '32aa5ab78beda5b8c8efbc89587de7a5',
        'database':
        'PCB',
        'parameters': [{
            'name': 'PCB_mass_total',
            'amount': 11,
            'formula': '7'
        }],
    }]
    obj.write_activity_parameters(NEW)
    assert ActivityParameter.select().count() == 1
    a = ActivityParameter.get()
    assert a.formula == '7'
    assert a.amount == 7
コード例 #4
0
def test_write_only_activity_parameters(no_init):
    assert not ActivityParameter.select().count()
    Database("PCB").register()
    obj = ExcelImporter()
    obj.db_name = "PCB"
    obj.data = deepcopy(DATA)
    obj.write_database()
    assert ActivityParameter.select().count() == 1
    assert ActivityParameter.get().amount != 7

    NEW = [
        {
            "code": "32aa5ab78beda5b8c8efbc89587de7a5",
            "database": "PCB",
            "parameters": [{"name": "PCB_mass_total", "amount": 11, "formula": "7"}],
        }
    ]
    obj.write_activity_parameters(NEW)
    assert ActivityParameter.select().count() == 1
    a = ActivityParameter.get()
    assert a.formula == "7"
    assert a.amount == 7