Esempio n. 1
0
def test_to_and_from_dict_roundtrip(some_interdeps):

    for idps in some_interdeps:
        desc = RunDescriber(interdeps=idps)

        ser_desc = desc._to_dict()

        new_desc = RunDescriber._from_dict(ser_desc)

        assert isinstance(new_desc, RunDescriber)
        assert desc == new_desc
Esempio n. 2
0
def test_construct_current_rundescriber_from_v3(some_interdeps):
    interdeps_ = some_interdeps[0]
    interdeps = new_to_old(interdeps_)

    v3 = RunDescriberV3Dict(interdependencies=interdeps._to_dict(),
                            interdependencies_=interdeps_._to_dict(),
                            version=3,
                            shapes=None)
    rds1 = RunDescriber._from_dict(v3)
    rds_upgraded = from_dict_to_current(v3)
    assert rds1._to_dict() == v3
    assert rds_upgraded._to_dict() == v3
Esempio n. 3
0
def test_construct_currect_rundesciber_from_v2(some_interdeps):
    interdeps_ = some_interdeps[0]
    interdeps = new_to_old(interdeps_)

    v2 = RunDescriberV2Dict(interdependencies=interdeps._to_dict(),
                            interdependencies_=interdeps_._to_dict(),
                            version=2)
    rds1 = RunDescriber._from_dict(v2)
    rds2 = from_dict_to_current(v2)

    assert rds1._to_dict() == v2
    assert rds2._to_dict() == v2
Esempio n. 4
0
def test_construct_currect_rundesciber_from_v1(some_interdeps):
    interdeps_ = some_interdeps[0]
    interdeps = new_to_old(interdeps_)

    v1 = RunDescriberV1Dict(interdependencies=interdeps_._to_dict(), version=1)
    rds1 = RunDescriber._from_dict(v1)
    rds2 = from_dict_to_current(v1)

    expected_v2_dict = RunDescriberV2Dict(
        interdependencies=interdeps._to_dict(),
        interdependencies_=interdeps_._to_dict(),
        version=2)
    assert rds1._to_dict() == expected_v2_dict
    assert rds2._to_dict() == expected_v2_dict
Esempio n. 5
0
def test_construct_currect_rundesciber_from_fake_v3(some_interdeps):
    interdeps_ = some_interdeps[0]
    interdeps = new_to_old(interdeps_)

    v3 = RunDescriberV2Dict(interdependencies=interdeps._to_dict(),
                            interdependencies_=interdeps_._to_dict(),
                            version=3)
    v3['foobar'] = {"foo": ["bar"]}
    rds1 = RunDescriber._from_dict(v3)
    rds2 = from_dict_to_current(v3)
    v2 = v3.copy()
    v2.pop('foobar')
    v2['version'] = 2
    assert rds1._to_dict() == v2
    assert rds2._to_dict() == v2
Esempio n. 6
0
def test_construct_current_rundescriber_from_v1(some_interdeps):
    interdeps_ = some_interdeps[0]
    interdeps = new_to_old(interdeps_)

    v1 = RunDescriberV1Dict(interdependencies=interdeps_._to_dict(), version=1)
    rds1 = RunDescriber._from_dict(v1)
    rds_upgraded = from_dict_to_current(v1)

    expected_v3_dict = RunDescriberV3Dict(
        interdependencies=interdeps._to_dict(),
        interdependencies_=interdeps_._to_dict(),
        version=3,
        shapes=None,
    )
    assert rds1._to_dict() == expected_v3_dict
    assert rds_upgraded._to_dict() == expected_v3_dict
Esempio n. 7
0
def test_construct_current_rundescriber_from_fake_v4(some_interdeps):
    interdeps_ = some_interdeps[0]
    interdeps = new_to_old(interdeps_)

    v4 = RunDescriberV3Dict(interdependencies=interdeps._to_dict(),
                            interdependencies_=interdeps_._to_dict(),
                            version=4,
                            shapes=None)
    v4['foobar'] = {"foo": ["bar"]}
    rds1 = RunDescriber._from_dict(v4)
    rds_upgraded = from_dict_to_current(v4)
    v3 = v4.copy()
    v3.pop('foobar')
    v3['version'] = 3
    assert rds1._to_dict() == v3
    assert rds_upgraded._to_dict() == v3
Esempio n. 8
0
def test_construct_currect_rundesciber_from_v0(some_paramspecs):

    pgroup1 = some_paramspecs[1]

    interdeps = InterDependencies(pgroup1['ps1'], pgroup1['ps2'],
                                  pgroup1['ps3'], pgroup1['ps4'],
                                  pgroup1['ps6'])
    v0 = RunDescriberV0Dict(interdependencies=interdeps._to_dict(), version=0)
    rds1 = RunDescriber._from_dict(v0)

    rds2 = from_dict_to_current(v0)

    expected_v2_dict = RunDescriberV2Dict(
        interdependencies=interdeps._to_dict(),
        interdependencies_=old_to_new(interdeps)._to_dict(),
        version=2)
    assert DeepDiff(rds1._to_dict(), expected_v2_dict, ignore_order=True) == {}
    assert DeepDiff(rds2._to_dict(), expected_v2_dict, ignore_order=True) == {}