예제 #1
0
def test_channel_set_multiple_times():
    """Set channel data multiple times"""
    folder = om.Factory.create(root)
    channel = om.Channel('testing.kvs', folder)

    channel.data = {
        u'file1': {
            u'some data': u'data'
        },
        'file2': {
            'some': u'data'
        }
    }
    channel.data = {
        u'file1': {
            u'some data': u'data'
        },
        'file2': {
            'some': u'data'
        }
    }
    channel.data = {
        u'file4': {
            u'some data': u'data'
        },
        'file1': {
            'some': u'data'
        }
    }

    print channel.data
예제 #2
0
def test_relativepath():
    """Children contain relative paths"""
    folder = om.Folder(persist)
    for child in folder:
        om_relpath = child.relativepath
        parent_path = os.path.join(folder.path, om.constant.Meta)
        manual_relpath = os.path.relpath(child.path, parent_path)

        assert_equals(om_relpath, manual_relpath)

    # Manually adding a child
    channel = om.Channel(os.path.join(persist, r'.meta\chan.txt'), folder)
    assert_equals(
        channel.relativepath,
        os.path.relpath(channel.path,
                        os.path.join(folder.path, om.constant.Meta)))

    channel = om.Channel(os.path.join(dynamic, r'.meta\chan.txt'), folder)
    assert_true(os.path.isabs(channel.relativepath))
예제 #3
0
def test_comparison():
    """Separate instances of same path are equal"""
    folder = om.Folder(dynamic)

    # Add channel to it
    channel = om.Channel('new_channel.txt', folder)
    file = om.Key('document.txt', channel)

    file_other = om.Key('document.txt', channel)

    assert_equals(file, file_other)
예제 #4
0
def test_clear_channel():
    """Clear individual channel"""
    folder = om.Folder(persist)

    # Add channel to it
    channel = om.Channel('new_channel.txt', folder)
    file = om.Key('document.txt', channel)

    file.data = "This is some data"
    file.write()

    channel.clear()

    assert_equals(channel.exists, False)
예제 #5
0
def test_clear_folder():
    """Remove ALL metadata"""
    folder = om.Folder(dynamic)

    # Add channel to it
    channel = om.Channel('new_channel.txt', folder)
    file = om.Key('document.txt', channel)

    file.data = "This is some data"
    file.write()

    folder.clear()

    assert_equals(folder.exists, False)
예제 #6
0
def test_full_template():
    """New metadata from scratch using templates"""

    folder = om.Folder(dynamic)
    chan = om.Channel('chan.txt', parent=folder)
    file = om.Key('document.txt', parent=chan)

    data = 'some text'

    file.data = data
    file.write()

    # Read it back in
    file_instance = om.Factory.create(file.path)
    file_instance.read()

    assert_equals(file_instance.data, data)

    om.delete(folder.path)
예제 #7
0
def test_append_metadata_to_channel():
    """Append metadata to existing channel"""

    meta = om.Folder(persist)
    channel = meta.children[0]

    submeta = om.Folder('.meta', parent=channel)
    subchannel = om.Channel('subchan.txt', parent=submeta)

    data = 'some text'

    file = om.Key('document.txt', parent=subchannel)
    file.data = data
    file.write()

    # Read it back in
    file_instance = om.Factory.create(file.path)
    file_instance.read()

    assert_is_instance(file_instance, om.Key)
    assert_equals(file_instance.data, data)

    om.delete(file_instance.path)
예제 #8
0
def test_defaultfileextension():
    """Default file extensions of Channel works"""
    folder = om.Folder(persist)
    channel = om.Channel('testing_dfe.txt', folder)
    channel.data = {'key': {'hello': 5}}