-
Notifications
You must be signed in to change notification settings - Fork 5
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
#690 #498 #497 Make the check_purchase work #695
Conversation
bb3e0c5
to
d4c59ed
Compare
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.
one arch question, few moments about subtasks.
In a whole new design looks perfect!
return ''.join(filter(lambda c: c.isalnum(), text)) | ||
|
||
|
||
class AlnumPresentedInValue: |
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.
it's not good name because of not good semantic. is_presented_...
is action, method should implement it.
But element driver.find_element(*self.locator)
is object, it should have it's own class.
So, i suggest this design:
class Element:
def __init__(self, driver: SiteDriver, locator: typing.Tuple[str, str]):
self.driver = driver
self.locator = locator
class SafeInput(Element):
"""Handles only alphanumeric symbols."""
def contains(text: str) -> bool:
value = driver.find_element(*self.locator).get_attribute('value')
return alphanumeric(text) in alphanumeric(value)
class Button(Element):
def click(self):
self.driver.wait.until(EC.element_to_be_clickable(
self.locator
)).click()
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.
@duker33 ,
AlnumPresentedInValue
is an expected condition as conditions from selenium. And it may instantiate an object.
WebDriverWait
can't use provided SafeInput
, because it isn't a condition
AlnumInValueCondition
sounds better?
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.
@artemiy312 , imho selenium conditions have not the best arch in the world =)
Condition interface implementing may contain some problems, but we can resolve them.
Let's leave you code and class name (choose one). I'll try propose some changes in separated PR
|
||
def select_payment_type(self): | ||
raise NotImplementedError | ||
def make_order(self): |
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.
def make_order(self): | |
def order(self): |
Maybe it's taste, up to you
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.
It seems something went wrong and i can see the suggested change
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.
@artemiy312 , sorry, fixed my comment above
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.
order
may have too many means: some representation of an order, order of positions, order as an action. In other words, it may looks both like a command and a query, so i'd like to leave it as the explicit command
shopelectro/models.py
Outdated
return settings.PAYMENT_OPTIONS[0][0] | ||
class PairIterEnum(enum.EnumMeta): | ||
|
||
def __iter__(self): |
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.
leave plz comment about this logic.
Metaclasses is not widely used feature, so it's quite hard to understand what happens there
shopelectro/models.py
Outdated
|
||
def __repr__(self): | ||
keys = ', '.join(next(zip(*PaymentOptions))) | ||
return f"<enum '{self.__name__}: {names}'>" |
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.
you define keys
, but here use undefined names
. Is it right?
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.
No, it is typo
# Handle errors. Report failed attempts. | ||
# Schedule it in the celery beat. | ||
# @todo #690:60m Handle errors in check_purchase. | ||
# Report failed attempts. Schedule it in the celery beat. |
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.
# Report failed attempts. Schedule it in the celery beat. | |
# Report failed attempts with asyncio. |
Maybe we'll write new functionality throw asyncio? This will allow us to move all functionality to asyncio bit by bit.
Up to you
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.
this code is too low related to check_purchase, i suppose.
But it's strongly related to "Implement OrderPage" and some sort of "Implement CategoryPage".
So, let's close and reopen these tasks instead of check_purchase?
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.
So, let's close and reopen these tasks instead of check_purchase?
I believe, this PR is related to check_purchase
implementation, because check_purchase
wouldn't work without this PR. Each change from this PR has brought check_purchase
to its final state.
May be Implement check_purchase.
isn't the most accurate description of the issue, but if it is important, then i can edit the original description to make the check_purchase work
. Is it sound ok?
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.
@artemiy312 , seems interesting case here =)
You resolved issue "check purchase", and i agree with that.
But to solve it you created code of selenium.OrderPage, selenium.CategoryPage classes and it's elements.
So, we should rename your PR to some sort of Implement base selenium page elements
and leave your @todo
cases fixes. PR name is not so necessary, it's up to you
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.
I just have renamed names of issue and PR. Now it looks fine
yield i.name, i.value | ||
https://docs.python.org/3/library/enum.html#enum-classes | ||
""" | ||
def items(self): |
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.
so, let's implement keys()
and values()
?
Up to you
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.
Right now these methods aren't needed anywhere, so it will be redundant
Closes #690 #498 #497