Skip to content

Commit

Permalink
Merge remote-tracking branch 'selurvedu/buildout-1' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
selurvedu committed Dec 21, 2016
2 parents 5562462 + 48dfbf7 commit 6e45157
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 75 deletions.
9 changes: 0 additions & 9 deletions README.md

This file was deleted.

17 changes: 17 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
robot_tests
===========

User acceptance tests for `OpenProcurement <https://github.com/openprocurement>`__
----------------------------------------------------------------------------------

|Gitter|

This repository contains tests which are aimed to verify performance of
the central database and the brokers.

Please visit the
`Wiki <https://github.com/openprocurement/robot_tests/wiki>`__ for more
information.

.. |Gitter| image:: https://badges.gitter.im/Join%20Chat.svg
:target: https://gitter.im/openprocurement/robot_tests
11 changes: 9 additions & 2 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ recipe = zc.recipe.egg
eggs =
op_robot_tests
openprocurement_client
robotframework
robotframework-lint
robotframework-debuglibrary
robot_tests.broker.dzo
Expand Down Expand Up @@ -70,8 +71,14 @@ robot_tests.broker.uub = git ${remotes:gh}openprocurement/robot_tests.b
robot_tests.broker.aps = git ${remotes:gh}openprocurement/robot_tests.broker.aps.git

[versions]
fake-factory = 0.5.3
Faker = 0.7.7
mr.developer = 1.34
restkit = 4.2.2.op1
rfc6266 = 0.0.6.op1
robotframework = 3.0.0
robotframework-selenium2library = 1.7.4
robotframework-debuglibrary = 0.8
robotframework-lint = 0.7
robotframework-selenium2library = 1.8.0
setuptools = 18.3.2
zc.buildout = 2.5.3
zc.recipe.egg = 2.0.3
89 changes: 67 additions & 22 deletions ez_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"""
Setuptools bootstrapping installer.
Maintained at https://github.com/pypa/setuptools/tree/bootstrap.
Run this script to install or upgrade setuptools.
"""

Expand All @@ -16,24 +18,30 @@
import platform
import textwrap
import contextlib
import warnings
import json
import codecs

from distutils import log

try:
from urllib.request import urlopen
from urllib.parse import urljoin
except ImportError:
from urllib2 import urlopen
from urlparse import urljoin

try:
from site import USER_SITE
except ImportError:
USER_SITE = None

LATEST = object()
DEFAULT_VERSION = "18.3.2"
DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/"
DEFAULT_URL = "https://pypi.io/packages/source/s/setuptools/"
DEFAULT_SAVE_DIR = os.curdir

MEANINGFUL_INVALID_ZIP_ERR_MSG = 'Maybe {0} is corrupted, delete it and try again.'


def _python_cmd(*args):
"""
Expand Down Expand Up @@ -98,8 +106,16 @@ def archive_context(filename):
old_wd = os.getcwd()
try:
os.chdir(tmpdir)
with ContextualZipFile(filename) as archive:
archive.extractall()
try:
with ContextualZipFile(filename) as archive:
archive.extractall()
except zipfile.BadZipfile as err:
if not err.args:
err.args = ('', )
err.args = err.args + (
MEANINGFUL_INVALID_ZIP_ERR_MSG.format(filename),
)
raise

# going in the directory
subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
Expand All @@ -114,18 +130,19 @@ def archive_context(filename):

def _do_download(version, download_base, to_dir, download_delay):
"""Download Setuptools."""
egg = os.path.join(to_dir, 'setuptools-%s-py%d.%d.egg'
% (version, sys.version_info[0], sys.version_info[1]))
py_desig = 'py{sys.version_info[0]}.{sys.version_info[1]}'.format(sys=sys)
tp = 'setuptools-{version}-{py_desig}.egg'
egg = os.path.join(to_dir, tp.format(**locals()))
if not os.path.exists(egg):
archive = download_setuptools(version, download_base,
to_dir, download_delay)
to_dir, download_delay)
_build_egg(egg, archive, to_dir)
sys.path.insert(0, egg)

# Remove previously-imported pkg_resources if present (see
# https://bitbucket.org/pypa/setuptools/pull-request/7/ for details).
if 'pkg_resources' in sys.modules:
del sys.modules['pkg_resources']
_unload_pkg_resources()

import setuptools
setuptools.bootstrap_install_from = egg
Expand All @@ -140,6 +157,7 @@ def use_setuptools(
Return None. Raise SystemExit if the requested version
or later cannot be installed.
"""
version = _resolve_version(version)
to_dir = os.path.abspath(to_dir)

# prior to importing, capture the module state for
Expand Down Expand Up @@ -189,6 +207,11 @@ def _conflict_bail(VC_err, version):


def _unload_pkg_resources():
sys.meta_path = [
importer
for importer in sys.meta_path
if importer.__class__.__module__ != 'pkg_resources.extern'
]
del_modules = [
name for name in sys.modules
if name.startswith('pkg_resources')
Expand Down Expand Up @@ -222,8 +245,8 @@ def download_file_powershell(url, target):
ps_cmd = (
"[System.Net.WebRequest]::DefaultWebProxy.Credentials = "
"[System.Net.CredentialCache]::DefaultCredentials; "
"(new-object System.Net.WebClient).DownloadFile(%(url)r, %(target)r)"
% vars()
'(new-object System.Net.WebClient).DownloadFile("%(url)s", "%(target)s")'
% locals()
)
cmd = [
'powershell',
Expand All @@ -248,7 +271,7 @@ def has_powershell():


def download_file_curl(url, target):
cmd = ['curl', url, '--silent', '--output', target]
cmd = ['curl', url, '--location', '--silent', '--output', target]
_clean_check(cmd, target)


Expand Down Expand Up @@ -321,6 +344,7 @@ def download_setuptools(
``downloader_factory`` should be a function taking no arguments and
returning a function for downloading a URL to a target.
"""
version = _resolve_version(version)
# making sure we use the absolute path
to_dir = os.path.abspath(to_dir)
zip_name = "setuptools-%s.zip" % version
Expand All @@ -333,6 +357,27 @@ def download_setuptools(
return os.path.realpath(saveto)


def _resolve_version(version):
"""
Resolve LATEST version
"""
if version is not LATEST:
return version

meta_url = urljoin(DEFAULT_URL, '/pypi/setuptools/json')
resp = urlopen(meta_url)
with contextlib.closing(resp):
try:
charset = resp.info().get_content_charset()
except Exception:
# Python 2 compat; assume UTF-8
charset = 'UTF-8'
reader = codecs.getreader(charset)
doc = json.load(reader(resp))

return str(doc['info']['version'])


def _build_install_args(options):
"""
Build the arguments to 'python setup.py install' on the setuptools package.
Expand All @@ -347,7 +392,7 @@ def _parse_args():
parser = optparse.OptionParser()
parser.add_option(
'--user', dest='user_install', action='store_true', default=False,
help='install in user site package (requires Python 2.6 or later)')
help='install in user site package')
parser.add_option(
'--download-base', dest='download_base', metavar="URL",
default=DEFAULT_URL,
Expand All @@ -362,23 +407,23 @@ def _parse_args():
default=DEFAULT_VERSION,
)
parser.add_option(
'--to-dir',
help="Directory to save (and re-use) package",
default=DEFAULT_SAVE_DIR,
'--to-dir',
help="Directory to save (and re-use) package",
default=DEFAULT_SAVE_DIR,
)
options, args = parser.parse_args()
# positional arguments are ignored
return options


def _download_args(options):
"""Return args for download_setuptools function from cmdline args."""
return dict(
version=options.version,
download_base=options.download_base,
downloader_factory=options.downloader_factory,
to_dir=options.to_dir,
)
"""Return args for download_setuptools function from cmdline args."""
return dict(
version=options.version,
download_base=options.download_base,
downloader_factory=options.downloader_factory,
to_dir=options.to_dir,
)


def main():
Expand Down
5 changes: 0 additions & 5 deletions op_robot_tests/rebot.py

This file was deleted.

10 changes: 5 additions & 5 deletions op_robot_tests/tests_files/data/brokers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ Quinta:
tender_owner: Tender_Owner
viewer: Tender_Viewer
timeout_on_wait: 15
E-tender:
Etender:
intervals:
default:
enquiry: [0, 5]
keywords_file: etender
roles:
provider: E-tender_Provider1
provider1: E-tender_Provider2
tender_owner: E-tender_Owner
viewer: E-tender_Viewer
provider: Etender_Provider1
provider1: Etender_Provider2
tender_owner: Etender_Owner
viewer: Etender_Viewer
timeout_on_wait: 600
DZO:
intervals:
Expand Down
28 changes: 14 additions & 14 deletions op_robot_tests/tests_files/data/users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,36 @@ users:
api_key: ""
broker: Quinta
browser: firefox
E-tender_Owner:
broker: E-tender
Etender_Owner:
broker: Etender
homepage: "http://bid.uat.e-tender.biz/#/"
login: Misha2
password: Password1
browser: chrome
position: [0, 0]
size: [800, 800]
E-tender_Provider1:
broker: E-tender
size: [1366, 800]
Etender_Provider1:
broker: Etender
homepage: "http://bid.uat.e-tender.biz/#/"
login: st_org
password: 12345678
browser: chrome
position: [700, 0]
size: [700, 800]
E-tender_Provider2:
broker: E-tender
position: [0, 0]
size: [1366, 800]
Etender_Provider2:
broker: Etender
homepage: "http://bid.uat.e-tender.biz/#/"
login: provider2
password: Qa123456
browser: chrome
position: [700, 0]
size: [640, 450]
E-tender_Viewer:
broker: E-tender
position: [0, 0]
size: [1366, 800]
Etender_Viewer:
broker: Etender
homepage: "http://bid.uat.e-tender.biz/#/"
browser: chrome
position: [0, 0]
size: [640, 450]
size: [1366, 800]
DZO_Owner:
broker: DZO
homepage: "http://dz2.byustudio.in.ua"
Expand Down
16 changes: 12 additions & 4 deletions op_robot_tests/tests_files/initial_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -
from datetime import timedelta
from faker import Factory
from faker.providers.company.en_US import Provider as CompanyProviderEnUs
from faker.providers.company.ru_RU import Provider as CompanyProviderRuRu
from munch import munchify
from uuid import uuid4
from tempfile import NamedTemporaryFile
Expand All @@ -10,10 +12,16 @@
import random


fake = Factory.create('uk_UA')
fake_ru = Factory.create('ru')
fake_en = Factory.create()
fake.add_provider(OP_Provider)
fake_en = Factory.create(locale='en_US')
fake_ru = Factory.create(locale='ru_RU')
fake_uk = Factory.create(locale='uk_UA')
fake_uk.add_provider(OP_Provider)
fake = fake_uk

# This workaround fixes an error caused by missing "catch_phrase" class method
# for the "ru_RU" locale in Faker >= 0.7.4
fake_ru.add_provider(CompanyProviderEnUs)
fake_ru.add_provider(CompanyProviderRuRu)


def create_fake_sentence():
Expand Down
Loading

0 comments on commit 6e45157

Please sign in to comment.