-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Group #2 #39
base: main
Are you sure you want to change the base?
Group #2 #39
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,41 +2,41 @@ | |
|
||
from fitnesse.context import SuiteResponder, PageCrawlerImpl, PageData, PathParser, WikiPage, WikiPagePath | ||
|
||
|
||
class TestType: | ||
SETUP: "SetUp" | ||
TEARDOWN: "TearDown" | ||
class HtmlUtil: | ||
|
||
@staticmethod | ||
def get_Path(page_name: str, wiki_page: WikiPage): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
inherit_Page: WikiPage = page_crawler.get_inherited_page(page_name, wiki_page) | ||
if inherit_Page is not None: | ||
path: wiki_page.get_page_crawler().get_full_path(setup) | ||
path_name: str = path_parser.render(page_path) | ||
Comment on lines
+14
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using error catching. In both steps sth. different can go wrong. |
||
return path_name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please consider not returning NULL in case the "inherit_Page" is None (this condition has not been taken care of). Alternatively, you need to account for this scenario when using the function. |
||
|
||
@staticmethod | ||
def testable_html(page_data: PageData, include_suite_setup: bool, page_crawler: PageCrawlerImpl, path_parser: PathParser) -> str: | ||
wiki_page: WikiPage = page_data.get_wiki_page() | ||
string_io: StringIO = StringIO() | ||
|
||
if page_data.has_attribute("Test"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could calculate |
||
if include_suite_setup: | ||
suite_setup: WikiPage = page_crawler.get_inherited_page(SuiteResponder.SUITE_SETUP_NAME, wiki_page) | ||
if suite_setup is not None: | ||
page_path: WikiPagePath = wiki_page.get_page_crawler().get_full_path(suite_setup) | ||
page_path_name: str = path_parser.render(page_path) | ||
string_io.writelines(["!include -setup .", page_path_name, "\n"]) | ||
|
||
setup: WikiPage = page_crawler.get_inherited_page("SetUp", wiki_page) | ||
if setup is not None: | ||
setup_path: WikiPagePath = wiki_page.get_page_crawler().get_full_path(setup) | ||
setup_path_name: str = path_parser.render(setup_path) | ||
string_io.writelines(["!include -setup .", setup_path_name, "\n"]) | ||
page_path_name = HtmlUtil.get_Path(wiki_page=wiki_page, page_name=SuiteResponder.SUITE_SETUP_NAME) | ||
string_io.writelines(["!include -setup .", page_path_name, "\n"]) | ||
|
||
setup_path_name = HtmlUtil.get_Path(wiki_page=wiki_page, page_name=TestType.SETUP) | ||
string_io.writelines(["!include -setup .", page_path_name, "\n"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please rework this copy + paste error: this line uses "page_path_name", while the line before declares "setup_path_name" |
||
|
||
string_io.writelines([page_data.get_content()]) | ||
if page_data.has_attribute("Test"): | ||
teardown: WikiPage = page_crawler.get_inherited_page("TearDown", wiki_page) | ||
if teardown is not None: | ||
tear_down_path: WikiPagePath = wiki_page.get_page_crawler().get_full_path(teardown) | ||
tear_down_path_name: str = path_parser.render(tear_down_path) | ||
string_io.writelines(["!include -teardown .", tear_down_path_name, "\n"]) | ||
tear_down_path_name: str = HtmlUtil.get_Path(wiki_page=wiki_page, page_name=TestType.TEARDOWN) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The arguments are switched. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same applies to the second |
||
string_io.writelines(["!include -teardown .", tear_down_path_name, "\n"]) | ||
if include_suite_setup: | ||
suite_teardown: WikiPage = page_crawler.get_inherited_page(SuiteResponder.SUITE_TEARDOWN_NAME, wiki_page) | ||
if suite_teardown is not None: | ||
page_path: WikiPagePath = wiki_page.get_page_crawler().get_full_path(suite_teardown) | ||
page_path_name: str = path_parser.render(page_path) | ||
string_io.writelines(["!include -teardown .", page_path_name, "\n"]) | ||
page_path_name: str = HtmlUtil.get_Path(wiki_page=wiki_page, page_name=SuiteResponder.SUITE_TEARDOWN_NAME) | ||
string_io.writelines(["!include -teardown .", page_path_name, "\n"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a suggestion: it might be reasonable to join the functionalities of finding a page name and adding it to the io string under one function "_add_pathname_to_io", as this combination is used 4 times. |
||
|
||
page_data.set_content(string_io.getvalue()) | ||
return page_data.get_html() | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add only one additional line at the end of the file. It might help to use a linter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strictly speaking, it is not wrong to present the different types of tests using a class. However, the use of a dictionary or an enumeration is more lightweight and appropriate in this context.