示例#1
0
    def test_remove_catalog_with_products(self):
        catalog = Catalog(self.driver)
        catalog.create()
        catalog.open()

        for i in xrange(self.NUMBER_OF_PRODUCTS):
            Product(self.driver).create()

        catalog.remove_with_products()
        self.driver.refresh()

        market_page = self.shop.market_page

        # check stubs
        catalog_stub = market_page.catalog_stub
        is_exist_catalog_stub = catalog_stub.is_exist()
        self.assertTrue(is_exist_catalog_stub)

        product_stub = market_page.product_stub
        is_exist_product_stub = product_stub.is_exist()
        self.assertTrue(is_exist_product_stub)

        # check counters
        catalog_counter = market_page.catalog_counter
        is_exist_catalog_counter = catalog_counter.is_exist()
        self.assertFalse(is_exist_catalog_counter)

        product_counter = market_page.product_counter
        is_exist_product_counter = product_counter.is_exist()
        self.assertFalse(is_exist_product_counter)
示例#2
0
    def test_remove_catalog_saving_products(self):
        catalog = Catalog(self.driver)
        catalog.create()
        catalog.open()

        for i in xrange(self.NUMBER_OF_PRODUCTS):
            Product(self.driver).create()

        catalog.remove_saving_products()
        self.driver.refresh()

        market_page = self.shop.market_page

        # check catalog stub
        catalog_stub = market_page.catalog_stub
        is_exist_catalog_stub = catalog_stub.is_exist()
        self.assertTrue(is_exist_catalog_stub)

        # check product widget
        product_widget = market_page.product_widget
        is_exist_product_widget = product_widget.is_exist()
        self.assertTrue(is_exist_product_widget)

        # check counters
        catalog_counter = market_page.catalog_counter
        is_exist_catalog_counter = catalog_counter.is_exist()
        self.assertFalse(is_exist_catalog_counter)

        product_counter = market_page.product_counter
        number_of_products = product_counter.get_number_of_all_products()
        self.assertEqual(self.NUMBER_OF_PRODUCTS, number_of_products)
示例#3
0
    def test_remove_empty_catalog(self):
        market_page = self.shop.market_page

        # check stub
        catalog_stub = market_page.catalog_stub
        is_exist_catalog_stub = catalog_stub.is_exist()
        self.assertTrue(is_exist_catalog_stub)

        catalog = Catalog(self.driver)
        catalog.create()

        # check widget
        catalog_widget = market_page.catalog_widget
        is_exist_catalog_widget = catalog_widget.is_exist()
        self.assertTrue(is_exist_catalog_widget)

        # check counter
        catalog_counter = market_page.catalog_counter
        number_of_catalogs = catalog_counter.get_number_of_catalogs()
        self.assertEqual(1, number_of_catalogs)

        catalog.open()
        catalog.remove_saving_products()

        # check stub
        is_exist_catalog_stub = catalog_stub.is_exist()
        self.assertTrue(is_exist_catalog_stub)

        # check counter
        is_exist_counter = catalog_counter.is_exist()
        self.assertFalse(is_exist_counter)
示例#4
0
    def test_edit_catalog_name(self):
        catalog = Catalog(self.driver)
        catalog.create()
        catalog.open()

        catalog.reset_name(self.OTHER_CATALOG_NAME)

        catalog_name = catalog.get_name()
        self.assertEquals(self.OTHER_CATALOG_NAME, catalog_name)
示例#5
0
    def test_remove_catalog_after_creating_later(self):
        catalog_stub = self.market_page.catalog_stub
        catalog_stub.create_catalog_later()

        catalog = Catalog(self.driver)
        catalog.create_from_catalog_product_panel()
        catalog.open()
        catalog.remove_saving_products()

        catalog_stub = self.market_page.catalog_stub
        is_exist_catalog_stub = catalog_stub.is_exist()
        self.assertFalse(is_exist_catalog_stub)

        is_exist_catalog_widget = self.catalog_widget.is_exist()
        self.assertFalse(is_exist_catalog_widget)
示例#6
0
    def test_edit_catalog_image(self):
        # creating catalog with image
        catalog = Catalog(self.driver)
        creating_image_src = catalog.create_with_image('image_64x64.jpg')

        # check image on widget
        widget_creating_image_src = self.catalog_widget.get_image_src()
        self.assertEqual(creating_image_src, widget_creating_image_src)

        # check image on panel
        catalog_page = catalog.open()
        catalog_panel = catalog_page.catalog_panel
        panel_creating_image_src = catalog_panel.get_image_src()
        self.assertEqual(creating_image_src, panel_creating_image_src)

        # upload other image
        editing_image_src = catalog.set_image('image_512x512.jpg')

        # check upload image
        panel_editing_image_src = catalog_panel.get_image_src()
        self.assertEqual(editing_image_src, panel_editing_image_src)
示例#7
0
    def test_upload_image_after_creating_catalog(self):
        # creating catalog without image
        catalog = Catalog(self.driver)
        catalog.create()

        # check image stub on widget
        is_exist_image_stub_on_widget = self.catalog_widget.is_exist_image_stub(
        )
        self.assertTrue(is_exist_image_stub_on_widget)

        # check image stub on panel
        catalog_page = catalog.open()
        catalog_panel = catalog_page.catalog_panel
        is_exist_image_stub_on_panel = catalog_panel.is_exist_image_stub()
        self.assertTrue(is_exist_image_stub_on_panel)

        # upload image
        upload_image_src = catalog.set_image()

        # check upload image
        panel_image_src = catalog_panel.get_image_src()
        self.assertEqual(upload_image_src, panel_image_src)
示例#8
0
class ProductsTests(unittest.TestCase):
    PRODUCT_NAME = u'Товар'
    PRODUCT_OUT_OF_STOCK = u'Нет в наличии'
    PRODUCT_PRICE = 100

    def setUp(self):
        self.driver = get_driver()

        Auth(self.driver).sign_in()
        Main(self.driver).open_groups_page()
        self.shop = Shop(self.driver)
        self.shop.create()

        self.catalog = Catalog(self.driver)
        self.catalog.create()
        self.catalog.open()

    def tearDown(self):
        self.shop.remove()
        self.driver.quit()

    def test_add_one_product(self):
        product = Product(self.driver)
        product.create(self.PRODUCT_NAME, self.PRODUCT_PRICE)

        product_name = product.get_name()
        self.assertEqual(self.PRODUCT_NAME, product_name)

        product_price = product.get_price()
        self.assertEqual(self.PRODUCT_PRICE, product_price)

        actual_number_of_products = self.catalog.get_number_of_products()
        self.assertEqual(1, actual_number_of_products)

    def test_add_several_products(self):
        NUMBER_OF_PRODUCTS = 10
        for i in xrange(NUMBER_OF_PRODUCTS):
            product = Product(self.driver)
            product.create()

        actual_number_of_products = self.catalog.get_number_of_products()
        self.assertEqual(NUMBER_OF_PRODUCTS, actual_number_of_products)

    def test_add_remove_one_product(self):
        number_of_products = self.catalog.get_number_of_products()
        self.assertEqual(0, number_of_products)

        product = Product(self.driver)
        product.create()

        number_of_products = self.catalog.get_number_of_products()
        self.assertEqual(1, number_of_products)

        product.remove()

        number_of_products = self.catalog.get_number_of_products()
        self.assertEqual(0, number_of_products)

    def test_mark_product_as_out_of_stock_and_return_on_sale(self):
        product = Product(self.driver)
        product.create(self.PRODUCT_NAME, self.PRODUCT_PRICE)

        product_price = product.get_price()
        self.assertEqual(self.PRODUCT_PRICE, product_price)

        product.mark_as_out_of_stock()

        product_price_text = product.get_price_text()
        self.assertEqual(self.PRODUCT_OUT_OF_STOCK, product_price_text)

        product.return_on_sale()

        product_price = product.get_price()
        self.assertEqual(self.PRODUCT_PRICE, product_price)

    def test_pin_unpin_product(self):
        NAMES = {
            0: '0',
            1: '1',
            2: '2',
            3: '3',
        }

        Product(self.driver).create(NAMES[0])

        catalog_page = CatalogPage(self.driver)
        first_product_widget_on_panel = catalog_page.product_widget

        first_product_name_on_panel = first_product_widget_on_panel.get_name()
        self.assertEqual(NAMES[0], first_product_name_on_panel)

        pined_product = Product(self.driver)
        pined_product.create(NAMES[1])
        pined_product.pin()

        first_product_name_on_panel = first_product_widget_on_panel.get_name()
        self.assertEqual(NAMES[1], first_product_name_on_panel)

        Product(self.driver).create(NAMES[2])

        first_product_name_on_panel = first_product_widget_on_panel.get_name()
        self.assertEqual(NAMES[1], first_product_name_on_panel)

        pined_product.unpin()

        first_product_name_on_panel = first_product_widget_on_panel.get_name()
        self.assertEqual(NAMES[1], first_product_name_on_panel)

        Product(self.driver).create(NAMES[3])

        first_product_name_on_panel = first_product_widget_on_panel.get_name()
        self.assertEqual(NAMES[3], first_product_name_on_panel)