-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Create SiteDriver.delete_session method * Create Goals interface for selenium tests * Use the YandexEcommerceGoals in tests * Review fixes * Make rebase to master * Apply linter rules
- Loading branch information
1 parent
3aa1b47
commit 63a1de7
Showing
5 changed files
with
63 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ | |
|
||
from .driver import SiteDriver | ||
from .pages import * | ||
from .analytics_goals import Goals, YandexEcommerceGoals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import abc | ||
|
||
from shopelectro.selenium import SiteDriver | ||
|
||
# @todo #929:30m Implement GoogleEcommerceGoals and YandexMetrikaGoals and use them in tests. | ||
|
||
|
||
class Goals(abc.ABC): | ||
"""Front-end reached goals.""" | ||
|
||
def __init__(self, driver: SiteDriver): | ||
self.driver = driver | ||
|
||
@abc.abstractmethod | ||
def fetch(self): | ||
raise NotImplementedError | ||
|
||
@abc.abstractmethod | ||
def __iter__(self): | ||
raise NotImplementedError | ||
|
||
@abc.abstractmethod | ||
def __getitem__(self, index: int): | ||
raise NotImplementedError | ||
|
||
|
||
class YandexEcommerceGoals(Goals): # Ignore PyDocStyleBear | ||
""" | ||
Unwrap an excess nesting level common for every goal: | ||
[{"ecommerce": ...}] -> ... | ||
Structure docs: https://yandex.com/support/metrica/data/e-commerce.html | ||
""" | ||
|
||
def __init__(self, driver: SiteDriver): | ||
super().__init__(driver) | ||
self.goals = [] | ||
|
||
def fetch(self): | ||
self.goals = self.driver.execute_script('return window.dataLayer.results;') | ||
|
||
def __getitem__(self, index: int): | ||
return self.goals[index][0]['ecommerce'] | ||
|
||
def __iter__(self): | ||
for g in self.goals: | ||
yield g[0]['ecommerce'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63a1de7
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.
Puzzle
808-f72e84e8
disappeared fromshopelectro/tests/tests_js_analytics.py
, that's why I closed #929. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.63a1de7
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.
Puzzle
929-26614c74
discovered inshopelectro/selenium/analytics_goals.py
and submitted as #940. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.