-
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 #5 #36
base: main
Are you sure you want to change the base?
Group #5 #36
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 |
---|---|---|
|
@@ -3,3 +3,5 @@ | |
.DS_Store | ||
*/target/ | ||
*.iml | ||
*.pyc | ||
Python/.codeseminar |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,86 @@ | ||
from io import StringIO | ||
|
||
from fitnesse.context import SuiteResponder, PageCrawlerImpl, PageData, PathParser, WikiPage, WikiPagePath | ||
from fitnesse.context import ( | ||
SuiteResponder, | ||
PageCrawlerImpl, | ||
PageData, | ||
PathParser, | ||
WikiPage, | ||
WikiPagePath, | ||
) | ||
|
||
|
||
class HtmlProcessData: | ||
page_data: PageData | ||
page_crawler: PageCrawlerImpl | ||
path_parser: PathParser | ||
|
||
|
||
class HtmlUtil: | ||
@staticmethod | ||
def _suite_action( | ||
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. This name may not be proper to understand what the function is doing 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. Overall, I would say that this refactor does not necessarily improve the readability, it only gets rid of the code duplication |
||
wiki_page: WikiPage, | ||
string_io: StringIO, | ||
html_data: HtmlProcessData, | ||
action="SetUp", | ||
): | ||
actions = { | ||
SuiteResponder.SUITE_TEARDOWN_NAME: "teardown", | ||
SuiteResponder.SUITE_SETUP_NAME: "setup", | ||
"SetUp": "setup", | ||
"TearDown": "teardown", | ||
} | ||
|
||
action_performed = actions[action] | ||
|
||
suite_action: WikiPage = html_data.page_crawler.get_inherited_page( | ||
action_performed, wiki_page | ||
) | ||
|
||
if suite_action is not None: | ||
page_path: WikiPagePath = wiki_page.get_page_crawler().get_full_path( | ||
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. Maybe factor out these few lines into their own function to improve readability, for example "write_page" or similar |
||
suite_action | ||
) | ||
page_path_name: str = html_data.path_parser.render(page_path) | ||
string_io.writelines( | ||
[f"!include -{action_performed} .", page_path_name, "\n"] | ||
) | ||
|
||
@staticmethod | ||
def testable_html(html_data: HtmlProcessData, include_suite_setup: bool = True): | ||
wiki_page: WikiPage = html_data.page_data.get_wiki_page() | ||
string_io: StringIO = StringIO() | ||
|
||
if html_data.page_data.has_attribute("Test"): | ||
if include_suite_setup: | ||
HtmlUtil._suite_action( | ||
wiki_page, | ||
string_io, | ||
html_data, | ||
action=SuiteResponder.SUITE_SETUP_NAME, | ||
) | ||
|
||
HtmlUtil._suite_action(wiki_page, string_io, html_data, action="SetUp") | ||
|
||
string_io.writelines([html_data.page_data.get_content()]) | ||
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. Unsure if this |
||
|
||
if html_data.page_data.has_attribute("Test"): | ||
HtmlUtil._suite_action( | ||
wiki_page, | ||
string_io, | ||
html_data, | ||
action=SuiteResponder.SUITE_TEARDOWN_NAME, | ||
) | ||
|
||
if include_suite_setup: | ||
HtmlUtil._suite_action( | ||
wiki_page, string_io, html_data, action="TearDown" | ||
) | ||
|
||
html_data.page_data.set_content(string_io.getvalue()) | ||
return html_data.page_data.get_html() | ||
|
||
""" | ||
@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() | ||
|
@@ -40,3 +116,7 @@ def testable_html(page_data: PageData, include_suite_setup: bool, page_crawler: | |
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
An additional class of HTML parameters may not be necessary