Ejemplo n.º 1
0
def test_serialize_deserialize(tide, json_):
    """
    test serialize/deserialize/update_from_dict doesn't raise errors
    """
    c_cats = CatsMover(curr_file, tide=tide)

    toserial = c_cats.serialize(json_)
    dict_ = c_cats.deserialize(toserial)

    # check our CatsMover attributes
    if json_ == 'webapi':
        assert toserial['filename'] == basename(toserial['filename'])
    else:
        # in save context, we expect a full path to file
        assert toserial['filename'] != basename(toserial['filename'])

    if tide:
        assert 'tide' in toserial
        dict_['tide'] = tide  # no longer updating properties of nested objects
        assert c_cats.tide is tide

        if json_ == 'webapi':
            assert (toserial['tide']['filename'] ==
                    basename(toserial['tide']['filename']))
        else:
            assert (toserial['tide']['filename'] !=
                    basename(toserial['tide']['filename']))

    c_cats.update_from_dict(dict_)
Ejemplo n.º 2
0
def test_serialize_deserialize(tide, json_):
    """
    test serialize/deserialize/update_from_dict doesn't raise errors
    """
    c_cats = CatsMover(curr_file, tide=tide)

    toserial = c_cats.serialize(json_)
    dict_ = c_cats.deserialize(toserial)

    # check our CatsMover attributes
    if json_ == 'webapi':
        assert toserial['filename'] == basename(toserial['filename'])
    else:
        # in save context, we expect a full path to file
        assert toserial['filename'] != basename(toserial['filename'])

    if tide:
        assert 'tide' in toserial
        dict_['tide'] = tide  # no longer updating properties of nested objects
        assert c_cats.tide is tide

        if json_ == 'webapi':
            assert (toserial['tide']['filename'] == basename(
                toserial['tide']['filename']))
        else:
            assert (toserial['tide']['filename'] != basename(
                toserial['tide']['filename']))

    c_cats.update_from_dict(dict_)
Ejemplo n.º 3
0
def test_serialize_deserialize_curronly(do):
    """
    test to_dict function for Wind object
    create a new wind object and make sure it has same properties
    """

    c_cats = CatsMover(curr_file)
    json_ = c_cats.serialize(do)
    dict_ = c_cats.deserialize(json_)
    if do == 'create':
        c2 = CatsMover.new_from_dict(dict_)
        assert c_cats == c2
    else:
        c_cats.from_dict(dict_)
Ejemplo n.º 4
0
def test_serialize_deserialize(tide):
    """
    test serialize/deserialize/update_from_dict doesn't raise errors
    """

    c_cats = CatsMover(curr_file, tide=tide)
    toserial = c_cats.serialize('webapi')
    dict_ = c_cats.deserialize(toserial)
    if tide:
        assert 'tide' in toserial
        dict_['tide'] = tide  # no longer updating properties of nested objects
        assert c_cats.tide is tide

    c_cats.update_from_dict(dict_)
Ejemplo n.º 5
0
def test_serialize_deserialize(tide):
    """
    test serialize/deserialize/update_from_dict doesn't raise errors
    """
    c_cats = CatsMover(curr_file, tide=tide)

    serial = c_cats.serialize()
    assert validate_serialize_json(serial, c_cats)

    # check our CatsMover attributes

    deser = CatsMover.deserialize(serial)

    assert deser == c_cats
Ejemplo n.º 6
0
def test_serialize_deserialize(tide):
    """
    test serialize/deserialize/update_from_dict doesn't raise errors
    """
    c_cats = CatsMover(curr_file, tide=tide)

    serial = c_cats.serialize()
    assert validate_serialize_json(serial, c_cats)

    # check our CatsMover attributes

    deser = CatsMover.deserialize(serial)

    assert deser == c_cats
Ejemplo n.º 7
0
def test_serialize_deserialize_tide(do):
    """
    test to_dict function for Wind object
    create a new wind object and make sure it has same properties
    """

    c_cats = CatsMover(curr_file, tide=td)
    json_ = c_cats.serialize(do)
    dict_ = c_cats.deserialize(json_)
    if do == 'create':
        dict_.update({'tide': td})
        c2 = CatsMover.new_from_dict(dict_)
        assert c_cats == c2
    else:
        assert json_['tide'] == td.serialize(do)
        c_cats.from_dict(dict_)
        assert c_cats.tide is td