예제 #1
0
    def todo_infile_data(self):
        from openalea.core.data import Model
        # Create a python file
        pyfile = self.tmpdir / 'model.py'
        with open(pyfile, 'wb') as f:
            f.write(b'data 1')

        Model.set_code = debug_parse

        # Check no parse. At this moment we don't want to read content for performance reason
        model = Model(path=pyfile)
        assert hasattr(model, 'parsed') is False

        # To get documentation, Model need to read content
        content = model.read()
        assert model.parsed is True
        model.parsed = False

        # Check that cache works: file don't have changed, no need to read and parse it again
        content = model.read()
        assert model.parsed is False
        assert content == b"data 1"

        # Simulate a change
        with open(pyfile, 'wb') as f:
            f.write(b'new data')

        # pyfile has changed, it need to be read again!
        content = model.read()
        assert model.parsed is True
        assert content == b"new data"

        model.parsed = False
        model.set_cache_mode(model.NO_CACHE)
        model.read()
        assert model.parsed is True
예제 #2
0
    def todo_infile_data(self):
        from openalea.core.data import Model
        # Create a python file
        pyfile = self.tmpdir / 'model.py'
        with open(pyfile, 'w') as f:
            f.write('data 1')

        Model.set_code = debug_parse

        # Check no parse. At this moment we don't want to read content for performance reason
        model = Model(path=pyfile)
        assert hasattr(model, 'parsed') is False

        # To get documentation, Model need to read content
        content = model.read()
        assert model.parsed is True
        model.parsed = False

        # Check that cache works: file don't have changed, no need to read and parse it again
        content = model.read()
        assert model.parsed is False
        assert content == "data 1"

        # Simulate a change
        with open(pyfile, 'w') as f:
            f.write('new data')

        # pyfile has changed, it need to be read again!
        content = model.read()
        assert model.parsed is True
        assert content == "new data"

        model.parsed = False
        model.set_cache_mode(model.NO_CACHE)
        model.read()
        assert model.parsed is True
예제 #3
0
    def todo_inmemory_data(self):
        from openalea.core.model import Model
        Model.parse = debug_parse
        Model.parsed = False

        # Check content is parsed
        model = Model(content=b'Hi ho', filename='model.py')
        assert model.parsed is True
        model.parsed = False

        model = Model(content=b'Hi ho', filename='model.py')

        # Check content is not parsed because content has not changed
        model.parsed = False
        content = model.read()
        assert model.parsed is False

        # Check content is parsed again because content has been explicitly changed
        model.content = b'captain'
        assert model.parsed is True
예제 #4
0
    def todo_inmemory_data(self):
        from openalea.core.model import Model
        Model.parse = debug_parse
        Model.parsed = False

        # Check content is parsed
        model = Model(content='Hi ho', filename='model.py')
        assert model.parsed is True
        model.parsed = False

        model = Model(content='Hi ho', filename='model.py')

        # Check content is not parsed because content has not changed
        model.parsed = False
        content = model.read()
        assert model.parsed is False

        # Check content is parsed again because content has been explicitly changed
        model.content = 'captain'
        assert model.parsed is True