exclude unused modules

This commit is contained in:
Churikova Tetiana 2018-04-09 13:07:41 +03:00 committed by Tetiana Churikova
parent 2822362a80
commit c1158a187f
10 changed files with 59 additions and 64 deletions

View File

@ -6,7 +6,6 @@ from selenium.webdriver.support import expected_conditions
class BaseElement(object):
class Locator(object):
def __init__(self, by, value):

View File

@ -15,4 +15,3 @@ class BasePageObject(object):
@property
def time_now(self):
return datetime.now().strftime('%-m%-d%-H%-M%-S')

View File

@ -9,7 +9,7 @@ class ActivityDescription(BaseText):
def __init__(self, driver, status, issue_title):
super(ActivityDescription, self).__init__(driver)
self.locator = self.Locator.xpath_selector(
'//div[@class="description"]/div[contains(.,"' + status + '")]/a[contains(.,"' + issue_title + '")]')
'//div[@class="description"]/div[contains(.,"%s")]/a[contains(.,"%s")]' % (status, issue_title))
class ActivityPage(BasePageObject):
@ -17,12 +17,9 @@ class ActivityPage(BasePageObject):
super(ActivityPage, self).__init__(driver)
self.driver = driver
def get_activity_page(self):
self.driver.get(test_data.config['Common']['url'] + 'app#/activity')
def check_activity_is_presented(self, status, issue_title):
logging.info('Check that activity "' + status + issue_title + '" is displayed')
logging.info('Check that activity "%s %s" is displayed' % (status, issue_title))
ActivityDescription(self.driver, status, issue_title).find_element()

View File

@ -1,7 +1,9 @@
import logging
from pages.base_page import BasePageObject
from pages.base_element import *
from pages.base_element import BaseText
from tests import test_data
class BountiesHeader(BaseText):
def __init__(self, driver):
@ -15,6 +17,7 @@ class TopHuntersHeader(BaseText):
super(TopHuntersHeader, self).__init__(driver)
self.locator = self.Locator.css_selector('.top-hunters-header')
class BountyTitles(BaseText):
def __init__(self, driver):
@ -28,6 +31,7 @@ class BountyItemRows(BaseText):
super(BountyItemRows, self).__init__(driver)
self.locator = self.Locator.css_selector('.open-bounty-item-content .bounty-item-row')
class BountyFooters(BaseText):
def __init__(self, driver):
@ -40,7 +44,7 @@ class BountyClaimsAmount(BaseText):
def __init__(self, driver, issue_title, claims_text):
super(BaseText, self).__init__(driver)
self.locator = self.Locator.xpath_selector(
'//div[@class="header"]/a[contains(.,"' + issue_title +'")]/../../div[@class="footer-row"]/span[contains(.,"' + claims_text + '")]')
'//div[@class="header"]/a[contains(.,"%s")]/../../div[@class="footer-row"]/span[contains(.,"%s")]' % (issue_title, claims_text))
class BountiesPage(BasePageObject):
@ -59,6 +63,5 @@ class BountiesPage(BasePageObject):
self.driver.get(test_data.config['Common']['url'] + 'app')
def check_bounty_claims_amount(self, issue_title, claims_text):
logging.info('Check that bounty "' + issue_title + '" has "' + claims_text + '"')
logging.info('Check that bounty "%s" has "%s"' % (issue_title, claims_text))
BountyClaimsAmount(self.driver, issue_title, claims_text).find_element()

View File

@ -1,5 +1,5 @@
from pages.base_page import BasePageObject
from pages.base_element import *
from pages.base_element import BaseButton
from tests import test_data

View File

@ -1,10 +1,10 @@
import time, pytest, git, os, shutil, logging
from pages.base_element import *
from selenium.common.exceptions import TimeoutException
from pages.base_element import BaseEditBox, BaseButton, BaseText
from pages.base_page import BasePageObject
from tests import test_data
class EmailEditbox(BaseEditBox):
def __init__(self, driver):
@ -107,25 +107,30 @@ class ContractBody(BaseText):
super(ContractBody, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//tbody//p[contains(text(), "
"'Current balance: 0.000000 ETH')]")
class IssueId(BaseText):
def __init__(self, driver):
super(IssueId, self).__init__(driver)
self.locator = self.Locator.css_selector(".gh-header-number")
class ForkButton(BaseButton):
def __init__(self, driver):
super(ForkButton, self).__init__(driver)
self.locator = self.Locator.css_selector("[href='#fork-destination-box']")
class HeaderInForkPopup(BaseText):
def __init__(self, driver):
super(HeaderInForkPopup, self).__init__(driver)
self.locator = self.Locator.css_selector("#facebox-header")
class UserAccountInForkPopup(BaseButton):
def __init__(self, driver):
super(UserAccountInForkPopup, self).__init__(driver)
self.locator = self.Locator.css_selector("[value=%s]"%test_data.config['DEV']['gh_username'])
self.locator = self.Locator.css_selector("[value=%s]" % test_data.config['DEV']['gh_username'])
class ForkedRepoText(BaseText):
@ -133,31 +138,39 @@ class ForkedRepoText(BaseText):
super(ForkedRepoText, self).__init__(driver)
self.locator = self.Locator.css_selector(".commit-tease")
class DeleteRepo(BaseButton):
def __init__(self, driver):
super(DeleteRepo, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//button[text()[contains(.,' Delete this repository')]]")
class RepoNameBoxInPopup(BaseEditBox):
def __init__(self, driver):
super(RepoNameBoxInPopup, self).__init__(driver)
self.locator = self.Locator.css_selector("input[aria-label='Type in the name of the repository to confirm that you want to delete this repository.']")
self.locator = self.Locator.css_selector(
"input[aria-label='Type in the name of the repository to confirm that you want to delete this repository.']")
class ConfirmDeleteButton(BaseButton):
def __init__(self, driver):
super(ConfirmDeleteButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//button[text()[contains(.,'I understand the consequences, delete')]]")
self.locator = self.Locator.xpath_selector(
"//button[text()[contains(.,'I understand the consequences, delete')]]")
class CompareAndPullRequest(BaseButton):
def __init__(self, driver):
super(CompareAndPullRequest, self).__init__(driver)
self.locator = self.Locator.css_selector(".RecentBranches a")
class PrTitleEditBox(BaseEditBox):
def __init__(self, driver):
super(PrTitleEditBox, self).__init__(driver)
self.locator = self.Locator.id("pull_request_body")
class SubmitNewPrButton(BaseButton):
def __init__(self, driver):
super(SubmitNewPrButton, self).__init__(driver)
@ -208,12 +221,11 @@ class GithubPage(BasePageObject):
self.pr_body = PrTitleEditBox(self.driver)
self.submit_new_pr_button = SubmitNewPrButton(self.driver)
def get_issues_page(self):
self.driver.get(test_data.config['ORG']['gh_repo'] + 'issues')
self.driver.get('%sissues' % test_data.config['ORG']['gh_repo'])
def get_issue_page(self, issue_id):
self.driver.get(test_data.config['ORG']['gh_repo'] + 'issues/' + issue_id)
self.driver.get('%sissues/%s' % (test_data.config['ORG']['gh_repo'], issue_id))
def get_sob_plugin_page(self):
self.driver.get(test_data.config['Common']['sob_test_app'])
@ -223,7 +235,6 @@ class GithubPage(BasePageObject):
self.password_input.send_keys(password)
self.sign_in_button.click()
def install_sob_plugin(self):
initial_url = self.driver.current_url
self.get_sob_plugin_page()
@ -244,7 +255,7 @@ class GithubPage(BasePageObject):
self.cross_button.click()
self.submit_new_issue_button.click()
test_data.issue['id'] = self.issue_id.text[1:]
logging.info("Issue title is %s" % test_data.issue['title'])
logging.info("Issue title is %s" % test_data.issue['title'])
def fork_repo(self, initial_repo, wait=60):
self.driver.get(initial_repo)
@ -264,9 +275,9 @@ class GithubPage(BasePageObject):
except TimeoutException:
time.sleep(10)
pass
pytest.fail('Contract is not deployed in %s minutes!' % str(wait/60))
pytest.fail('Contract is not deployed in %s minutes!' % str(wait / 60))
#cloning via HTTPS
# cloning via HTTPS
def clone_repo(self, initial_repo=None, username=None, repo_name=None, repo_folder='test_repo'):
os.mkdir(repo_folder)
os.chdir(repo_folder)
@ -275,20 +286,19 @@ class GithubPage(BasePageObject):
logging.info(('Cloning from %s to %s' % (fork, self.local_repo_path)))
repo = git.Repo.clone_from(fork, self.local_repo_path)
logging.info(('Successefully cloned to: %s' % self.local_repo_path))
logging.info('Set upstream to %s'% initial_repo)
logging.info('Set upstream to %s' % initial_repo)
upstream = repo.create_remote('upstream', initial_repo)
upstream.fetch()
assert upstream.exists()
repo.heads.master.checkout()
def create_pr_git(self, branch, file_to_modify = 'test'):
def create_pr_git(self, branch, file_to_modify='test'):
repo = git.Repo(self.local_repo_path)
logging.info(repo.git.status())
logging.info(repo.git.pull('upstream', 'master'))
logging.info(repo.git.push('origin', 'master'))
logging.info(repo.git.fetch('--all'))
repo.git.checkout('-b',branch)
repo.git.checkout('-b', branch)
file = open(os.path.join(self.local_repo_path, file_to_modify), 'w')
file.write("Autotest change: %s \r \n" % test_data.date_time)
logging.info(repo.git.add('test'))
@ -298,7 +308,7 @@ class GithubPage(BasePageObject):
def open_pr_github(self, keyword_comment):
self.get_url(test_data.config['DEV']['gh_forked_repo'])
self.compare_and_pull_request.click()
self.pr_body.send_keys(keyword_comment + ' #%s' % test_data.issue['id'])
self.pr_body.send_keys('%s #%s' % (keyword_comment, test_data.issue['id']))
self.submit_new_pr_button.click()
def clean_repo_local_folder(self):
@ -311,5 +321,3 @@ class GithubPage(BasePageObject):
self.delete_repo.click()
self.repo_name_confirm_delete.send_keys(test_data.config['ORG']['gh_repo_name'])
self.confirm_delete.click()

View File

@ -1,6 +1,6 @@
import time
from pages.base_page import BasePageObject
from pages.base_element import *
from pages.base_element import BaseButton, BaseText, BaseEditBox
from selenium.webdriver import ActionChains
@ -74,7 +74,6 @@ class MetaMaskPlugin(BasePageObject):
self.ok_button = OkButton(self.driver)
def recover_access(self, passphrase, password, confirm_password):
self.get_url('chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/popup.html')
self.accept_button.click()
ActionChains(self.driver).move_to_element(self.privacy_text.find_element()).perform()
@ -85,4 +84,3 @@ class MetaMaskPlugin(BasePageObject):
self.password_edit_box.send_keys(password)
self.password_box_confirm.send_keys(confirm_password)
self.ok_button.click()

View File

@ -1,9 +1,9 @@
import configparser, time, datetime, os
class TestData(object):
def __init__(self):
self.test_name = None
self.config = configparser.ConfigParser()
@ -11,7 +11,7 @@ class TestData(object):
self.tests_path = os.path.abspath(os.path.dirname(__file__))
self.config.read(os.path.join(self.tests_path, 'config.ini'))
#create unique identificator for PRs, issues ect
# create unique identificator for PRs, issues ect
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
self.date_time = st
@ -20,6 +20,4 @@ class TestData(object):
# self.issue['id'] is set in GithubPage::create_new_bounty
test_data = TestData()

View File

@ -2,18 +2,19 @@ import pytest, sys, os
from selenium import webdriver
from selenium.common.exceptions import WebDriverException
from tests.postconditions import remove_application, remove_installation
from os import environ, path
from os import environ
from tests import test_data
from pages.thirdparty.github import GithubPage
from pages.openbounty.landing import LandingPage
class BaseTestCase:
class BaseTestCase:
def print_sauce_lab_info(self, driver):
sys.stdout = sys.stderr
print("SauceOnDemandSessionID=%s job-name=%s" % (driver.session_id,
pytest.config.getoption('build')))
def get_remote_caps(self):
sauce_lab_cap = dict()
sauce_lab_cap['name'] = test_data.test_name
@ -36,11 +37,11 @@ class BaseTestCase:
@classmethod
def setup_class(cls):
cls.errors = []
cls.environment = pytest.config.getoption('env')
cls.environment = pytest.config.getoption('env')
###################################################################################################################
######### Drivers setup
###################################################################################################################
################################################################################################################
######### Drivers setup
################################################################################################################
#
# Dev Chrome options
@ -52,13 +53,14 @@ class BaseTestCase:
# Org Chrome options
#
cls.capabilities_org = webdriver.ChromeOptions()
cls.capabilities_org.add_extension(os.path.join(test_data.tests_path, os.pardir, 'resources', 'metamask3_12_0.crx'))
cls.capabilities_org.add_extension(
os.path.join(test_data.tests_path, os.pardir, 'resources', 'metamask3_12_0.crx'))
#
# SauceLab capabilities
#
cls.executor_sauce_lab = 'http://%s:%s@ondemand.saucelabs.com:80/wd/hub' % (
environ.get('SAUCE_USERNAME'), environ.get('SAUCE_ACCESS_KEY'))
environ.get('SAUCE_USERNAME'), environ.get('SAUCE_ACCESS_KEY'))
cls.drivers = []
if cls.environment == 'local':
@ -78,23 +80,21 @@ class BaseTestCase:
cls.driver_dev = cls.drivers[0]
cls.driver_org = cls.drivers[1]
for driver in cls.drivers:
driver.implicitly_wait(10)
driver.implicitly_wait(10)
###################################################################################################################
######### Actions for each driver before class
###################################################################################################################
################################################################################################################
######### Actions for each driver before class
################################################################################################################
######ORG
landing = LandingPage(cls.driver_org)
landing.get_landing_page()
# Sign Up to SOB
# Sign Up to SOB
cls.github_org = landing.login_button.click()
cls.github_org.sign_in(test_data.config['ORG']['gh_login'],
test_data.config['ORG']['gh_password'])
test_data.config['ORG']['gh_password'])
assert cls.github_org.permission_type.text == 'Personal user data'
bounties_page = cls.github_org.authorize_sob.click()
@ -108,20 +108,17 @@ class BaseTestCase:
# Sign In to GH as Developer
cls.github_dev.get_login_page()
cls.github_dev.sign_in(test_data.config['DEV']['gh_login'],
test_data.config['DEV']['gh_password'])
test_data.config['DEV']['gh_password'])
# Fork repo as Developer from Organization
# Fork repo as Developer from Organization
cls.github_dev.fork_repo(test_data.config['ORG']['gh_repo'])
# Cloning repo to local git as Developer and set upstream to Organization (via HTTPS)
# Cloning repo to local git as Developer and set upstream to Organization (via HTTPS)
cls.github_dev.clone_repo(test_data.config['ORG']['gh_repo'],
test_data.config['DEV']['gh_username'],
test_data.config['ORG']['gh_repo_name'])
cls.verify_no_errors(cls)
@classmethod
def teardown_class(cls):
@ -142,6 +139,3 @@ class BaseTestCase:
except WebDriverException:
pass

View File

@ -20,4 +20,3 @@ def remove_installation(driver):
driver.find_element(By.CSS_SELECTOR, '.facebox-popup .btn-danger').click()
except NoSuchElementException:
pass