Skip to content

Commit

Permalink
Create file with exceptions for elements
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemijRodionov committed Apr 1, 2019
1 parent ec4d935 commit aace71d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
3 changes: 2 additions & 1 deletion shopelectro/selenium/elements/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .input import Input
from .button import Button
from .exceptions import Unavailable
from .input import Input
from .product import CatalogProduct, CartPosition
20 changes: 14 additions & 6 deletions shopelectro/selenium/elements/cart.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
from shopelectro.selenium.elements import Unavailable

# @todo #799:120m Reuse shopelectro.selenium.elements.cart.Cart for selenium tests.


class Cart:
""""Represent the cart at the site."""

def __init__(self, driver: SiteDriver):
self.driver = driver

def positions(self):
pass
def positions(self):
raise Unavailable('to get positions.')

def clear(self):
raise Unavailable('to get positions.')

def clear(self):
pass
def total(self):
raise Unavailable('to get positions.')

def total(self):
pass
def is_empty(self):
raise Unavailable('to get positions.')
4 changes: 4 additions & 0 deletions shopelectro/selenium/elements/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Unavailable(NotImplementedError):

def __init__(self, msg, *args, **kwargs):
super().__init__(f'The element doesn\'t provide ability to {msg}', *args, **kwargs)
8 changes: 1 addition & 7 deletions shopelectro/selenium/elements/product.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import abc

from shopelectro.selenium.elements import Button
from shopelectro.selenium.elements import Button, Unavailable
from shopelectro.selenium.driver import SiteDriver

from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC


class Unavailable(NotImplementedError):

def __init__(self, msg, *args, **kwargs):
super().__init__(f'The element doesn\'t provide ability to {msg}', *args, **kwargs)


class Product(abc.ABC):
""""Represent a product at the site."""

Expand Down
3 changes: 0 additions & 3 deletions shopelectro/tests/tests_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
from pages.models import FlatPage, CustomPage
from pages.urls import reverse_custom_page

# @todo #783:60m Create Cart class for tests.
# The class should replace batch of methods from this file.


def add_to_cart(browser):
browser.get(Product.objects.first().url)
Expand Down

0 comments on commit aace71d

Please sign in to comment.