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

#690 #498 #497 Make the check_purchase work #695

Merged
merged 16 commits into from
Jan 20, 2019
Merged

Conversation

ArtemijRodionov
Copy link
Contributor

@ArtemijRodionov ArtemijRodionov commented Jan 17, 2019

Closes #690 #498 #497

@ArtemijRodionov ArtemijRodionov self-assigned this Jan 17, 2019
@ArtemijRodionov ArtemijRodionov changed the title #690 check purchase #690 #498 check purchase Jan 17, 2019
@ArtemijRodionov ArtemijRodionov changed the title #690 #498 check purchase #690 #498 #497 check purchase Jan 18, 2019
Copy link
Contributor

@duker33 duker33 left a 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:
Copy link
Contributor

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()

Copy link
Contributor Author

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?

Copy link
Contributor

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):
Copy link
Contributor

@duker33 duker33 Jan 19, 2019

Choose a reason for hiding this comment

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

Suggested change
def make_order(self):
def order(self):

Maybe it's taste, up to you

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor Author

@ArtemijRodionov ArtemijRodionov Jan 20, 2019

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

return settings.PAYMENT_OPTIONS[0][0]
class PairIterEnum(enum.EnumMeta):

def __iter__(self):
Copy link
Contributor

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


def __repr__(self):
keys = ', '.join(next(zip(*PaymentOptions)))
return f"<enum '{self.__name__}: {names}'>"
Copy link
Contributor

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?

Copy link
Contributor Author

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# 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

Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor Author

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):
Copy link
Contributor

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

Copy link
Contributor Author

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

@ArtemijRodionov ArtemijRodionov changed the title #690 #498 #497 check purchase #690 #498 #497 Make the check_purchase work Jan 20, 2019
@ArtemijRodionov ArtemijRodionov merged commit ce492b1 into master Jan 20, 2019
@ArtemijRodionov ArtemijRodionov deleted the 690-check-purchase branch January 20, 2019 13:54
@duker33 duker33 mentioned this pull request Jan 26, 2019
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.

None yet

2 participants