コード例 #1
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)
コード例 #2
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)
コード例 #3
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)
コード例 #4
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)
コード例 #5
0
def test_append_file_to_existing():
    """Append file to existing channel"""

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

    data = "new content"

    file_template = om.Key('appended.txt', channel)
    file_template.data = data
    file_template.write()

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

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

    om.delete(file_instance.path)
コード例 #6
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)
コード例 #7
0
channel_to_file = {
    '.kvs': '.json',
    '.txt': '.txt',
    '.mdw': '.txt',
}

mapping = {
    '.txt': DotTxt,
    '.mdw': DotMdw,
    '.json': DotJson
    # '.ini': DotIni,
    # '.gdoc': DotGdoc
}

if __name__ == '__main__':
    import openmetadata as om

    path = r'A:\development\marcus\scripts\python\about\test\.meta\chan4.kvs\properties.json'
    key = om.Key(path)
    key.read()
    print key.path
    print key.exists
    print key.data

    # inputted = {"Key": "Value"}
    # asstring = processoutgoing(inputted, '.json')
    # asdict = processincoming(asstring, '.json')

    # print asstring
    # print asdict