def generate_command(
         self, document: Document) -> Optional[GeneratedSnippetResult]:
     """Generates a boilerplate Cheetah code snippet based on the current inputs and outputs
     of this tool wrapper."""
     tool = GalaxyToolXmlDocument(document)
     generator = GalaxyToolCommandSnippetGenerator(tool)
     return generator.generate_snippet()
    def test_find_snippet_position_returns_expected_result(self, source: str, expected_position: Position) -> None:
        document = TestUtils.to_document(source)
        tool = GalaxyToolXmlDocument(document)
        generator = GalaxyToolCommandSnippetGenerator(tool)

        actual_position = generator._find_snippet_insert_position()

        assert actual_position == expected_position
    def test_build_snippet_returns_expected_result(self, tool_file: str, expected_snippet_file: str) -> None:
        document = TestUtils.get_test_document_from_file(tool_file)
        expected_snippet = TestUtils.get_test_file_contents(expected_snippet_file)
        tool = GalaxyToolXmlDocument(document)
        generator = GalaxyToolCommandSnippetGenerator(tool)

        actual_snippet = generator._build_snippet()

        assert actual_snippet == expected_snippet
Exemplo n.º 4
0
    def test_generate_snippet_with_command_with_cdata_returns_snippet_only(self) -> None:
        document = TestUtils.to_document("<tool><command><![CDATA[]]></command></tool>")
        tool = GalaxyToolXmlDocument(document)
        generator = GalaxyToolCommandSnippetGenerator(tool)

        result = generator.generate_snippet()

        assert "<command" not in result.snippet
        assert "<![CDATA[" not in result.snippet