TheRenegadeCoder / subete

The Sample Programs API in Python
https://subete.therenegadecoder.com
MIT License
2 stars 2 forks source link

Add Test URL Method to LanguageCollection #12

Closed jrg94 closed 3 years ago

jrg94 commented 3 years ago

The following code no longer works:

    def _build_test_link(self, language: LanguageCollection, letter: str) -> InlineText:
        """
        A helper method which creates a link to the test file for a given language collection.

        :param LanguageCollection language: a language collection
        :param str letter: the first letter of the language
        :return: a markdown link to a test file if it exists; an empty string otherwise
        """
        test_file_path = language.test_file_path
        if test_file_path:
            file_path = self.repo_url_base + letter + "/" + language.name() + "/" + os.path.basename(test_file_path)
            file_path_link = InlineText("Here", url=file_path)
        else:
            file_path_link = InlineText("")
        return file_path_link

Ideally, I don't want the user poking at the underlying file structure anyway. Let's try to replicate the following line in a method:

file_path = self.repo_url_base + letter + "/" + language.name() + "/" + os.path.basename(test_file_path)

This looks like the link to the test file in GitHub.