Exemplo n.º 1
0
def update_registry(file, status, content):
    if status == CacheFileRequest.CHANGED or status == CacheFileRequest.OPENED:
        reload_steps(content, file)
    elif status == CacheFileRequest.CREATED or status == CacheFileRequest.CLOSED:
        _load_from_disk(file)
    else:
        registry.remove_steps(file)
Exemplo n.º 2
0
def process_cache_file_request(request):
    file = request.filePath
    status = request.status
    if status == CacheFileRequest.CHANGED or status == CacheFileRequest.OPENED:
        reload_steps(file, request.content)
    elif status == CacheFileRequest.CREATED:
        if not registry.is_file_cached(file):
            _load_from_disk(file)
    elif status == CacheFileRequest.CLOSED:
        _load_from_disk(file)
    else:
        registry.remove_steps(file)
    return Empty()
Exemplo n.º 3
0
    def test_loader_reload_registry_for_given_content(self):
        content = dedent("""
            @step("print hello")
            def printf():
                print("hello")
            """)
        load_steps(Parser.parse("foo.py", content))

        self.assertTrue(registry.is_implemented("print hello"))

        content = dedent("""
                @step("print world")
                def printf():
                    print("hello")
                """)

        reload_steps('foo.py', content)

        self.assertFalse(registry.is_implemented("print hello"))
        self.assertTrue(registry.is_implemented("print world"))
Exemplo n.º 4
0
    def test_loader_reload_registry_for_given_content(self):
        content = """
            @step("print hello")
            def print():
                print("hello")
            """
        ast = generate_ast(content, "foo.py")
        load_steps(ast, "foo.py")

        self.assertTrue(registry.is_implemented("print hello"))

        content = """
                @step("print world")
                def print():
                    print("hello")
                """

        reload_steps(content, 'foo.py')

        self.assertFalse(registry.is_implemented("print hello"))
        self.assertTrue(registry.is_implemented("print world"))
Exemplo n.º 5
0
def _load_from_disk(file_path):
    if path.isfile(file_path):
        f = open(file_path, 'r+')
        reload_steps(f.read(), file_path)
        f.close()
Exemplo n.º 6
0
def _load_from_disk(file_path):
    if path.isfile(file_path):
        reload_steps(file_path)