예제 #1
0
파일: test_data.py 프로젝트: GWhized/dexy
def test_generic_data():
    with wrap() as wrapper:
        wrapper.to_walked()
        wrapper.to_checked()

        CONTENTS = "contents go here"

        # Create a GenericData object
        settings = {
                'canonical-name' : 'doc.txt'
                }
        data = dexy.data.Generic("doc.txt", ".txt", "abc000", settings, wrapper)
        data.setup_storage()

        # Assign some text contents
        data._data = CONTENTS
        assert data.has_data()
        assert not data.is_cached(True)

        # Save data to disk
        data.save()
        assert data.has_data()
        assert data.is_cached(True)
        assert data.filesize(True) > 10

        # Clear data from memory
        data._data = None

        # Load it again from disk
        data.load_data(True)
        assert data._data == CONTENTS

        assert data.as_text() == CONTENTS
예제 #2
0
def test_generic_data():
    with wrap() as wrapper:
        wrapper.to_walked()
        wrapper.to_checked()

        CONTENTS = "contents go here"

        # Create a GenericData object
        settings = {'canonical-name': 'doc.txt'}
        data = dexy.data.Generic("doc.txt", ".txt", "abc000", settings,
                                 wrapper)
        data.setup_storage()

        # Assign some text contents
        data._data = CONTENTS
        assert data.has_data()
        assert not data.is_cached(True)

        # Save data to disk
        data.save()
        assert data.has_data()
        assert data.is_cached(True)
        assert data.filesize(True) > 10

        # Clear data from memory
        data._data = None

        # Load it again from disk
        data.load_data(True)
        assert data._data == CONTENTS

        assert data.as_text() == CONTENTS
예제 #3
0
def test_generic_data():
    with wrap() as wrapper:
        CONTENTS = "contents go here"

        # Create a GenericData object
        data = dexy.data.GenericData("doc.txt", ".txt", "hash1", wrapper)

        # Assign some text contents
        data._data = CONTENTS
        assert data.has_data()
        assert not data.is_cached()
        assert not data.filesize()

        # Save data to disk
        data.save()
        assert data.has_data()
        assert data.is_cached()
        assert data.filesize() > 10

        # Clear data from memory
        data._data = None
        assert data.has_data()

        # Load it again from disk
        data.load_data()
        assert data._data == CONTENTS

        # The convenience methods load from disk if needed.
        data._data = None
        assert data.as_text() == CONTENTS

        data._data = None
        assert data.as_sectioned()['1'] == CONTENTS