Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Group #2 #39

wants to merge 1 commit into from

Conversation

FadySalama
Copy link
Collaborator

Refactored code using a function

@alextsakpinis alextsakpinis changed the title refactor code Group #2 Nov 22, 2023
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"])
Copy link
Collaborator

Choose a reason for hiding this comment

The 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"

Comment on lines +5 to +7
class TestType:
SETUP: "SetUp"
TEARDOWN: "TearDown"
Copy link
Collaborator

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.

class HtmlUtil:

@staticmethod
def get_Path(page_name: str, wiki_page: WikiPage):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_Path seems to be private. Consider putting it beyond the publicly callable function and indicate the intended access-level by an underscore, i.e., _get_path.

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"])
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

path: wiki_page.get_page_crawler().get_full_path(setup)
path_name: str = path_parser.render(page_path)
return path_name

@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"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could calculate page_data.has_attribute("Test") on top of the function body, or in a separate function once, as the boolean information is needed a second time (cf. line 32).

if inherit_Page is not None:
path: wiki_page.get_page_crawler().get_full_path(setup)
path_name: str = path_parser.render(page_path)
return path_name
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

Comment on lines +14 to +15
path: wiki_page.get_page_crawler().get_full_path(setup)
path_name: str = path_parser.render(page_path)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using error catching. In both steps sth. different can go wrong.


page_data.set_content(string_io.getvalue())
return page_data.get_html()


Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arguments are switched. HtmlUtil.get_Path(page_name=TestType.TEARDOWN, wiki_page=wiki_page)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same applies to the second get_Path call (cf. line 36)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants