Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.51 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. from uaprom.tests.se.test_case import WebDriverTestCase
  3. from uaprom.tests.se.services import fake
  4. from uaprom.tests.se.purchase.urls import sign_in_url, secure_url, case_url
  5. from uaprom.tests.se.elements.base import (
  6.     wait_for_page_loaded,
  7.     wait_for_ajax,
  8.     wait_for_animation,
  9.     scroll_to_element
  10. )
  11.  
  12. from uaprom.tests.se.state.user import UserFactory
  13. from uaprom.tests.se.state.purchase.create_access_item import AccessItemFactory
  14. from uaprom.tests.se.state.purchase.employee import EmployeeFactory
  15. from uaprom.tests.se.state.purchase.merchant import MerchantFactory
  16. from uaprom.tests.se.state.purchase.merchant_group import MerchantGroupFactory
  17.  
  18. from uaprom.tests.se.training_test.pages.company_profile import CompanyProfile
  19.  
  20.  
  21. class TestProfileComapny(WebDriverTestCase):
  22.  
  23.     def test_company_profile_validation(self):
  24.         user = UserFactory.create_user()
  25.         employee = EmployeeFactory.create_employee(user)
  26.         merchant_group = MerchantGroupFactory.create_merchant_group()
  27.         merchant = MerchantFactory.create_merchant(
  28.             merchant_group,
  29.             employee,
  30.             merchant_type=1,
  31.             state_merchant=False,
  32.             verified=False
  33.         )
  34.         AccessItemFactory.create_access_item_for_merchant(employee, merchant)
  35.         AccessItemFactory.create_access_item_for_merchant_group(
  36.             employee, merchant_group
  37.         )
  38.         url = sign_in_url(user.id)
  39.         self.driver.get(url)
  40.         company_profile = CompanyProfile(self.driver)
  41.         self.driver.get(company_profile.url)
  42.         company_profile.company_profile_block.edit_icon.click()
  43.         company_profile.company_profile_popup.close_popup_button.click()
  44.         company_profile.company_profile_popup.close_popup_button.wait_to_disappear()
  45.         company_profile.company_profile_block.edit_icon.click()
  46.         company_profile.company_profile_popup.wait_to_display()
  47.         company_profile.company_profile_popup.name_input.clear()
  48.         company_profile.company_profile_popup.name_en_input.clear()
  49.         company_profile.company_profile_popup.srn_input.clear()
  50.         company_profile.company_profile_popup.web_site_input.clear()
  51.         company_profile.company_profile_popup.web_site_input.send_keys("3123123")
  52.         company_profile.company_profile_popup.phone_input.clear()
  53.         company_profile.company_profile_popup.phone_input.send_keys("+3806546546546546")
  54.         company_profile.company_profile_popup.zip_code.clear()
  55.         company_profile.company_profile_popup.city_name_input.clear()
  56.         company_profile.company_profile_popup.company_adress_input.clear()
  57.         company_profile.company_profile_popup.submit_button.click()
  58.         self.soft_assert_equals(
  59.             company_profile.company_profile_popup.name_error_alert.text,
  60.             u"Це поле обов'язкове",
  61.             "No name alert present"
  62.         )
  63.         self.soft_assert_equals(
  64.             company_profile.company_profile_popup.name_en_error.text,
  65.             u"Це поле обов'язкове",
  66.             "No en_name alert present"
  67.         )
  68.         self.soft_assert_equals(
  69.             company_profile.company_profile_popup.srn_error_alert.text,
  70.             u"Це поле обов'язкове",
  71.             "No srn alert present"
  72.         )
  73.         self.soft_assert_equals(
  74.             company_profile.company_profile_popup.phone_error_alert.text,
  75.             u"Телефон повинен складатися не менше 5 і не більше 15 символів",
  76.             "No phone alert present"
  77.         )
  78.         self.soft_assert_equals(
  79.             company_profile.company_profile_popup.zip_error_alert.text,
  80.             u"Це поле обов'язкове",
  81.         "No zip_code alert present"
  82.         )
  83.         self.soft_assert_equals(
  84.             company_profile.company_profile_popup.address_error_alert.text,
  85.             u"Це поле обов'язкове",
  86.             "No adress alert present"
  87.         )
  88.         self.soft_assert_equals_text_with_ignore_spaces_and_register(
  89.             company_profile.company_profile_popup.url_error_alert.text,
  90.             u"Невірний URL",
  91.             "No url alert present"
  92.         )
  93.  
  94.     def test_company_profile(self):
  95.         user = UserFactory.create_user()
  96.         employee = EmployeeFactory.create_employee(user)
  97.         merchant_group = MerchantGroupFactory.create_merchant_group()
  98.         merchant = MerchantFactory.create_merchant(
  99.             merchant_group,
  100.             employee,
  101.             merchant_type=1,
  102.             state_merchant=False,
  103.             verified=False
  104.         )
  105.         AccessItemFactory.create_access_item_for_merchant(employee, merchant)
  106.         AccessItemFactory.create_access_item_for_merchant_group(
  107.             employee, merchant_group
  108.         )
  109.         url = sign_in_url(user.id)
  110.         self.driver.get(url)
  111.         company_profile = CompanyProfile(self.driver)
  112.         self.driver.get(company_profile.url)
  113.         company_profile.company_profile_block.edit_icon.click()
  114.         company_profile.company_profile_popup.wait_to_display()
  115.         company_profile.company_profile_popup.name_input.clear()
  116.         company_profile.company_profile_popup.name_input.send_keys(fake.name())
  117.         company_profile.company_profile_popup.name_en_input.clear()
  118.         company_profile.company_profile_popup.name_en_input.send_keys(fake.name())
  119.         company_profile.company_profile_popup.srn_input.send_keys("123456789101213")
  120.         company_profile.company_profile_popup.ownership_dropdown.select_random_options()
  121.         company_profile.company_profile_popup.web_site_input.send_keys(fake.url())
  122.         company_profile.company_profile_popup.phone_input.clear()
  123.         company_profile.company_profile_popup.phone_input.send_keys(fake.phone_number())
  124.         company_profile.company_profile_popup.more_phones_link.click()
  125.         company_profile.company_profile_popup.second_phone_number.clear()
  126.         company_profile.company_profile_popup.second_phone_number.send_keys(fake.phone_number())
  127.         company_profile.company_profile_popup.third_phone_number.clear()
  128.         company_profile.company_profile_popup.third_phone_number.send_keys(fake.phone_number())
  129.         company_profile.company_profile_popup.fourth_phone_number.clear()
  130.         company_profile.company_profile_popup.fourth_phone_number.send_keys(fake.phone_number())
  131.         company_profile.company_profile_popup.fifth_phone_number.clear()
  132.         company_profile.company_profile_popup.fifth_phone_number.send_keys(fake.phone_number())
  133.         company_profile.company_profile_popup.country_dropdown.select_random_options()
  134.         company_profile.company_profile_popup.country_dropdown.select_option_by_text(u"Украина")
  135.         company_profile.company_profile_popup.zip_code.send_keys("123456")
  136.         if len(company_profile.company_profile_popup.zip_code.text) > 6:
  137.             self.soft_assert_equals(
  138.                 company_profile.company_profile_popup.zip_error_alert.text,
  139.                 u"Поле не может содержать больше 6 символов.",
  140.                 "Not zip_error alert present"
  141.             )
  142.         company_profile.company_profile_popup.location_dropdown.select_random_options()
  143.         company_profile.company_profile_popup.city_name_input.clear()
  144.         company_profile.company_profile_popup.city_name_input.send_keys(fake.name())
  145.         company_profile.company_profile_popup.company_adress_input.clear()
  146.         company_profile.company_profile_popup.company_adress_input.send_keys(fake.name())
  147.         company_profile.company_profile_popup.physic_adress_dropdown.select_random_options()
  148.         company_profile.company_profile_popup.physic_zip_code_input.clear()
  149.         company_profile.company_profile_popup.physic_zip_code_input.send_keys("123456")
  150.         company_profile.company_profile_popup.physic_city_name_input.clear()
  151.         company_profile.company_profile_popup.physic_city_name_input.send_keys(fake.name())
  152.         company_profile.company_profile_popup.physic_company_adress_input.clear()
  153.         company_profile.company_profile_popup.physic_company_adress_input.send_keys(fake.name())
  154.         company_profile.company_profile_popup.add_file_button.upload_file()
  155.         company_profile.company_profile_popup.submit_button.click()
  156.         self.soft_assert_equals(
  157.             company_profile.company_profile_block.merchant_profile.text,
  158.             u"Структура компанії",
  159.             "Company profile doesn't save"
  160.         )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement