Beispiel #1
0
def test_addobject():
    """py.test for ex_addobject.py"""
    zones = bunchdt["zone"]  # all the zones
    assert len(zones) == 7
    modeleditor.addobject(bunchdt,
                          data,
                          commdct,
                          "Zone".upper(),
                          None,
                          aname="NewZone")
    assert len(zones) == 8
    assert zones[-1].obj == [
        "ZONE",
        "NewZone",
        0.0,
        0.0,
        0.0,
        0.0,
        1,
        1,
        "autocalculate",
        "autocalculate",
        "autocalculate",
        "",
        "",
        "Yes",
    ]
Beispiel #2
0
def test_addobject():
    """py.test for ex_addobject.py"""
    zones = bunchdt['zone'.upper()] # all the zones
    assert len(zones) == 7
    modeleditor.addobject(bunchdt, data, 
        commdct, "Zone".upper(), aname="NewZone")
    assert len(zones) == 8
    assert zones[-1].obj == ['ZONE', 'NewZone', 0., 0., 0., 0., 1, 1,
        'autocalculate', 'autocalculate', 'autocalculate', '', '', 'Yes']
Beispiel #3
0
def test_addobject():
    """py.test for ex_addobject.py"""
    zones = bunchdt['zone'.upper()]  # all the zones
    assert len(zones) == 7
    modeleditor.addobject(bunchdt,
                          data,
                          commdct,
                          "Zone".upper(),
                          aname="NewZone")
    assert len(zones) == 8
    assert zones[-1].obj == [
        'ZONE', 'NewZone', 0., 0., 0., 0., 1, 1, 'autocalculate',
        'autocalculate', 'autocalculate', '', '', 'Yes'
    ]
Beispiel #4
0
def test_addobject():
    """py.test for ex_addobject.py"""
    zones = bunchdt["zone".upper()]  # all the zones
    assert len(zones) == 7
    modeleditor.addobject(bunchdt, data, commdct, "Zone".upper(), aname="NewZone")
    assert len(zones) == 8
    assert zones[-1].obj == [
        "ZONE",
        "NewZone",
        0.0,
        0.0,
        0.0,
        0.0,
        1,
        1,
        "autocalculate",
        "autocalculate",
        "autocalculate",
        "",
        "",
        "Yes",
    ]
Beispiel #5
0
def test___objecthasfields():
    """py.test for __objecthasfields"""
    thedata = (
        ("ZONE", dict(Name="testzone", X_Origin=32), "testzone", True),
        # key, fielddict, aname, istrue
        ("ZONE", dict(Name="testzone", X_Origin=32), "testzone1", False),
        # key, fielddict, aname, istrue
    )
    for key, fielddict, aname, istrue in thedata:
        idfobject = modeleditor.addobject(bunchdt, data, commdct, key, None,
                                          **fielddict)
        idfobject.Name = aname  # modify the name, to check for a False return
        result = modeleditor.__objecthasfields(bunchdt, data, commdct,
                                               idfobject, **fielddict)
        assert result == istrue
Beispiel #6
0
def test___objecthasfields():
    """py.test for __objecthasfields"""
    thedata = (
    ("ZONE", dict(Name="testzone", X_Origin=32), "testzone", True), 
    # key, fielddict, aname, istrue
    ("ZONE", dict(Name="testzone", X_Origin=32), "testzone1", False), 
    # key, fielddict, aname, istrue
    )
    for key, fielddict, aname, istrue in thedata:
        idfobject = modeleditor.addobject(bunchdt, data, commdct, 
            key, **fielddict)
        idfobject.Name = aname # modify the name, to check for a False return
        result = modeleditor.__objecthasfields(bunchdt, data, commdct, 
            idfobject, **fielddict)
        assert result == istrue
Beispiel #7
0
def test_addobject():
    """py.test for addobject"""
    thedata = (
    ('ZONE', None, dict(Name="Gumby", X_Origin=50)), # key, aname, fielddict
    ('ZONE', 'karamba', {}), # key, aname, fielddict
    ('ZONE', None, {}), # key, aname, fielddict
    ('ZONE', None, dict(Name="Gumby", X_Origin=50)), # key, aname, fielddict
    )
    for key, aname, fielddict in thedata:
        result = modeleditor.addobject(bunchdt, data, commdct, 
            key, aname, **fielddict)
        assert bunchdt[key][-1].key == key # wierd, but correct :-)
        if aname:
            assert data.dt[key][-1][1] == aname
            assert bunchdt[key][-1].Name == aname
        if fielddict:
            for k, v in fielddict.items():
                assert bunchdt[key][-1][k] == v
Beispiel #8
0
def test_addobject():
    """py.test for addobject"""
    thedata = (
        ('ZONE', None, dict(Name="Gumby", X_Origin=50)), # key, aname, fielddict
        ('ZONE', 'karamba', {}), # key, aname, fielddict
        ('ZONE', None, {}), # key, aname, fielddict
        ('ZONE', None, dict(Name="Gumby", X_Origin=50)), # key, aname, fielddict
    )
    for key, aname, fielddict in thedata:
        result = modeleditor.addobject(
            bunchdt, data, commdct,
            key, aname, **fielddict)
        assert bunchdt[key][-1].key == key # wierd, but correct :-)
        if aname:
            assert data.dt[key][-1][1] == aname
            assert bunchdt[key][-1].Name == aname
        if fielddict:
            for kkey, value in list(fielddict.items()):
                assert bunchdt[key][-1][kkey] == value