Skip to content

chore: Fix iOS app management functional tests#575

Merged
ki4070ma merged 16 commits intoappium:masterfrom
ki4070ma:fix-app-mgmt-tc
Feb 3, 2021
Merged

chore: Fix iOS app management functional tests#575
ki4070ma merged 16 commits intoappium:masterfrom
ki4070ma:fix-app-mgmt-tc

Conversation

@ki4070ma
Copy link
Copy Markdown
Collaborator

@ki4070ma ki4070ma commented Jan 31, 2021

Background

  • It's failing after upgrading to iOS 14.3.

@ki4070ma ki4070ma changed the title chore: Fix app mgmt tc [WIP] chore: Fix app mgmt tc Jan 31, 2021
@ki4070ma ki4070ma changed the title [WIP] chore: Fix app mgmt tc [WIP] chore: Fix app mgmt tc and android test with SDK v30 Jan 31, 2021
@ki4070ma
Copy link
Copy Markdown
Collaborator Author

ki4070ma commented Feb 1, 2021

Will handle failed android tests with SDK 30 by #576 since it will take more time .

@ki4070ma ki4070ma changed the title [WIP] chore: Fix app mgmt tc and android test with SDK v30 [WIP] chore: Fix app mgmt tc Feb 1, 2021
@ki4070ma ki4070ma changed the title [WIP] chore: Fix app mgmt tc chore: Fix iOS app management functional tests Feb 1, 2021
@ki4070ma ki4070ma marked this pull request as ready for review February 1, 2021 12:43
self.driver.start_activity(APIDEMO_PKG_NAME, ".ApiDemos")
self._assert_activity_contains('Demos')

self.driver.start_activity("com.android.calculator2", ".Calculator")
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

(note) Here is one of #576.

"""
for i in range(timeout + 1):
if method():
return True
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would rather return the result of the method itself. this should not necessarily be a boolean value

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@mykola-mokhnach

Humm, in my understanding, I'm not sure how it can wait for target Callable if it isn't boolean.
Would you give more details?

return os.getenv('CI', 'false') == 'true'


def wait_for(method: Callable, timeout: int) -> bool:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I usually prefer to explicitly mention the time unit for variables (e.g. timeout -> timeout_sec). Also, it makes sense to have a default value (e.g. 5) for it and make it float, so we could provide timeouts lesser than one seconds. It also makes sense to make the interval configurable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sure:

result = callable()
if result:
    return result

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we could even use

if result := callable():
    return result

if we drop the support of py37 :-P

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@mykola-mokhnach
Thanks for details.
Ah, yes, actually it popped into my head,
but as my thoughts, it could extend this method usage, but extended usage is limited for "user".

But it's ok since "user" is developer. I'll change it to suggestion. 👍

"""
result = method()
for i in range(int(timeout_sec / interval)):
if i != 0:
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤔


"""
result = method()
for i in range(int(timeout_sec / interval)):
Copy link
Copy Markdown
Contributor

@mykola-mokhnach mykola-mokhnach Feb 2, 2021

Choose a reason for hiding this comment

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

I would rather use while loop and compare with the time.time() value:

    started = time.time()
    while time.time() - started <= timeout_sec:
....

for i in range(int(timeout_sec / interval)):
if i != 0:
result = method()
if interval <= 0:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

zero interval is also fine

result = method()
if result:
break
sleep(interval)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

interval_sec

@ki4070ma ki4070ma merged commit 74f599d into appium:master Feb 3, 2021
@ki4070ma ki4070ma deleted the fix-app-mgmt-tc branch February 3, 2021 04:00
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