コード例 #1
0
ファイル: test_data.py プロジェクト: adityaathalye/dexy
def test_key_value_data_sqlite():
    with wrap() as wrapper:
        data = dexy.data.KeyValueData("doc.sqlite3", ".sqlite3", "hash1", wrapper)

        data.append('foo', 'bar')
        assert len(data.keys()) == 1

        assert data.value('foo') == 'bar'
        assert ["%s: %s" % (k, v) for k, v in data.storage][0] == "foo: bar"

        data.as_text() == "foo: bar"
コード例 #2
0
ファイル: test_data.py プロジェクト: adityaathalye/dexy
def test_key_value_data():
    with wrap() as wrapper:
        data = dexy.data.KeyValueData("doc.json", ".json", "hash1", wrapper, storage_type='json')

        assert not data._data
        assert data.storage._data == {}

        # We use the append method to add key-value pairs.
        data.append('foo', 'bar')
        assert len(data.keys()) == 1

        assert data.value('foo') == 'bar'
        assert data.storage['foo'] == 'bar'
        assert data.as_text() == "foo: bar"
        data.as_sectioned()['foo'] == 'bar'
コード例 #3
0
def test_key_value_data():
    with wrap() as wrapper:
        settings = {'canonical-name': 'doc.json', 'storage-type': 'json'}
        data = dexy.data.KeyValue("doc.json", ".json", "doc.json", settings,
                                  wrapper)
        data.setup_storage()

        assert not data._data
        assert data.storage._data == {}

        # We use the append method to add key-value pairs.
        data.append('foo', 'bar')
        assert len(list(data.keys())) == 1

        assert data.value('foo') == 'bar'
        assert data.storage['foo'] == 'bar'
コード例 #4
0
def test_keyvalue_data_stores_dict():
    with wrap() as wrapper:
        doc = Doc("hello.json",
                  wrapper, [],
                  data_type="keyvalue",
                  contents="dummy contents")

        wrapper.run_docs(doc)
        data = doc.output_data()

        assert data.alias == 'keyvalue'
        assert list(data.keys()) == []

        data.append("foo", 123)
        data.append("bar", 456)

        assert sorted(data.keys()) == ["bar", "foo"]
コード例 #5
0
def test_key_value_data_sqlite():
    with wrap() as wrapper:
        wrapper.to_walked()
        wrapper.to_checked()

        settings = {'canonical-name': 'doc.sqlite3'}

        data = dexy.data.KeyValue("doc.sqlite3", ".sqlite3", "abc000",
                                  settings, wrapper)
        data.setup_storage()
        data.storage.connect()

        data.append('foo', 'bar')
        assert len(list(data.keys())) == 1

        assert data.value('foo') == 'bar'
        assert ["%s: %s" % (k, v) for k, v in data.items()][0] == "foo: bar"
コード例 #6
0
ファイル: test_data.py プロジェクト: GWhized/dexy
def test_key_value_data_sqlite():
    with wrap() as wrapper:
        wrapper.to_walked()
        wrapper.to_checked()

        settings = {
                'canonical-name' : 'doc.sqlite3'
                }

        data = dexy.data.KeyValue("doc.sqlite3", ".sqlite3", "abc000", settings, wrapper)
        data.setup_storage()
        data.storage.connect()

        data.append('foo', 'bar')
        assert len(data.keys()) == 1

        assert data.value('foo') == 'bar'
        assert ["%s: %s" % (k, v) for k, v in data.storage.iteritems()][0] == "foo: bar"
コード例 #7
0
ファイル: test_data.py プロジェクト: GWhized/dexy
def test_key_value_data():
    with wrap() as wrapper:
        settings = {
                'canonical-name' : 'doc.json',
                'storage-type' : 'json'
                }
        data = dexy.data.KeyValue("doc.json", ".json", "doc.json", settings, wrapper)
        data.setup_storage()

        assert not data._data
        assert data.storage._data == {}

        # We use the append method to add key-value pairs.
        data.append('foo', 'bar')
        assert len(data.keys()) == 1

        assert data.value('foo') == 'bar'
        assert data.storage['foo'] == 'bar'
コード例 #8
0
ファイル: test_data.py プロジェクト: GWhized/dexy
def test_keyvalue_data_stores_dict():
    with wrap() as wrapper:
        doc = Doc("hello.json",
                wrapper,
                [],
                data_type="keyvalue",
                contents="dummy contents"
                )

        wrapper.run_docs(doc)
        data = doc.output_data()

        assert data.alias == 'keyvalue'
        assert data.keys() == []

        data.append("foo", 123)
        data.append("bar", 456)

        assert sorted(data.keys()) == ["bar", "foo"]