summaryrefslogtreecommitdiffstats
path: root/testapi
diff options
context:
space:
mode:
Diffstat (limited to 'testapi')
-rw-r--r--testapi/MANIFEST.in1
-rwxr-xr-xtestapi/docker/prepare-env.sh2
-rw-r--r--testapi/etc/config.ini3
-rw-r--r--testapi/opnfv_testapi/cmd/server.py2
-rw-r--r--testapi/opnfv_testapi/common/config.py19
-rw-r--r--testapi/opnfv_testapi/router/url_mappings.py2
-rw-r--r--testapi/opnfv_testapi/tests/unit/common/noparam.ini16
-rw-r--r--testapi/opnfv_testapi/tests/unit/common/normal.ini17
-rw-r--r--testapi/opnfv_testapi/tests/unit/common/nosection.ini11
-rw-r--r--testapi/opnfv_testapi/tests/unit/common/notboolean.ini17
-rw-r--r--testapi/opnfv_testapi/tests/unit/common/notint.ini17
-rw-r--r--testapi/opnfv_testapi/tests/unit/conftest.py2
-rw-r--r--testapi/opnfv_testapi/tests/unit/resources/test_base.py6
-rw-r--r--testapi/opnfv_testapi/ui/root.py2
-rw-r--r--testapi/setup.cfg15
-rw-r--r--testapi/setup.py9
16 files changed, 17 insertions, 124 deletions
diff --git a/testapi/MANIFEST.in b/testapi/MANIFEST.in
new file mode 100644
index 0000000..0ba1808
--- /dev/null
+++ b/testapi/MANIFEST.in
@@ -0,0 +1 @@
+recursive-include 3rd_party \ No newline at end of file
diff --git a/testapi/docker/prepare-env.sh b/testapi/docker/prepare-env.sh
index b14bc24..92a0c9f 100755
--- a/testapi/docker/prepare-env.sh
+++ b/testapi/docker/prepare-env.sh
@@ -10,5 +10,5 @@ if [ "$base_url" != "" ]; then
sudo crudini --set --existing $FILE api url $base_url/api/v1
sudo crudini --set --existing $FILE ui url $base_url
sudo echo "{\"testapiApiUrl\": \"$base_url/api/v1\"}" > \
- /usr/local/lib/python2.7/dist-packages/opnfv_testapi/static/testapi-ui/config.json
+ /usr/local/share/opnfv_testapi/testapi-ui/config.json
fi
diff --git a/testapi/etc/config.ini b/testapi/etc/config.ini
index db0e191..a7d8da6 100644
--- a/testapi/etc/config.ini
+++ b/testapi/etc/config.ini
@@ -21,6 +21,9 @@ authenticate = False
[ui]
url = http://localhost:8000
+# this path should be the seem with data_files installation path
+static_path = /usr/local/share/opnfv_testapi
+
[lfid]
# Linux Foundation cas URL
cas_url = https://identity.linuxfoundation.org/cas/
diff --git a/testapi/opnfv_testapi/cmd/server.py b/testapi/opnfv_testapi/cmd/server.py
index 50ac049..b7d3caa 100644
--- a/testapi/opnfv_testapi/cmd/server.py
+++ b/testapi/opnfv_testapi/cmd/server.py
@@ -38,7 +38,7 @@ from opnfv_testapi.tornado_swagger import swagger
def make_app():
swagger.docs(base_url=CONF.ui_url,
- static_path=CONF.static_path)
+ static_path=CONF.ui_static_path)
return swagger.Application(
url_mappings.mappings,
debug=CONF.api_debug,
diff --git a/testapi/opnfv_testapi/common/config.py b/testapi/opnfv_testapi/common/config.py
index 4cd53c6..140e492 100644
--- a/testapi/opnfv_testapi/common/config.py
+++ b/testapi/opnfv_testapi/common/config.py
@@ -16,14 +16,10 @@ import sys
class Config(object):
def __init__(self):
- self.config_file = None
+ self.config_file = '/etc/opnfv_testapi/config.ini'
self._set_config_file()
self._parse()
self._parse_per_page()
- self.static_path = os.path.join(
- os.path.dirname(os.path.normpath(__file__)),
- os.pardir,
- 'static')
def _parse(self):
if not os.path.exists(self.config_file):
@@ -56,23 +52,12 @@ class Config(object):
return value
def _set_config_file(self):
- if not self._set_sys_config_file():
- self._set_default_config_file()
-
- def _set_sys_config_file(self):
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--config-file", dest='config_file',
help="Config file location", metavar="FILE")
args, _ = parser.parse_known_args(sys.argv)
- try:
+ if hasattr(args, 'config_file') and args.config_file:
self.config_file = args.config_file
- finally:
- return self.config_file is not None
-
- def _set_default_config_file(self):
- is_venv = os.getenv('VIRTUAL_ENV')
- self.config_file = os.path.join('/' if not is_venv else is_venv,
- 'etc/opnfv_testapi/config.ini')
CONF = Config()
diff --git a/testapi/opnfv_testapi/router/url_mappings.py b/testapi/opnfv_testapi/router/url_mappings.py
index be6240e..c038e88 100644
--- a/testapi/opnfv_testapi/router/url_mappings.py
+++ b/testapi/opnfv_testapi/router/url_mappings.py
@@ -72,7 +72,7 @@ mappings = [
# static path
(r'/(.*\.(css|png|gif|js|html|json|map|woff2|woff|ttf))',
tornado.web.StaticFileHandler,
- {'path': CONF.static_path}),
+ {'path': CONF.ui_static_path}),
(r'/', root.RootHandler),
(r'/api/v1/auth/signin', sign.SigninHandler),
diff --git a/testapi/opnfv_testapi/tests/unit/common/noparam.ini b/testapi/opnfv_testapi/tests/unit/common/noparam.ini
deleted file mode 100644
index be7f2b9..0000000
--- a/testapi/opnfv_testapi/tests/unit/common/noparam.ini
+++ /dev/null
@@ -1,16 +0,0 @@
-# to add a new parameter in the config file,
-# the CONF object in config.ini must be updated
-[mongo]
-# URL of the mongo DB
-# Mongo auth url => mongodb://user1:pwd1@host1/?authSource=db1
-url = mongodb://127.0.0.1:27017/
-
-[api]
-# Listening port
-port = 8000
-# With debug_on set to true, error traces will be shown in HTTP responses
-debug = True
-authenticate = False
-
-[ui]
-url = http://localhost:8000
diff --git a/testapi/opnfv_testapi/tests/unit/common/normal.ini b/testapi/opnfv_testapi/tests/unit/common/normal.ini
deleted file mode 100644
index c81c6c5..0000000
--- a/testapi/opnfv_testapi/tests/unit/common/normal.ini
+++ /dev/null
@@ -1,17 +0,0 @@
-# to add a new parameter in the config file,
-# the CONF object in config.ini must be updated
-[mongo]
-# URL of the mongo DB
-# Mongo auth url => mongodb://user1:pwd1@host1/?authSource=db1
-url = mongodb://127.0.0.1:27017/
-dbname = test_results_collection
-
-[api]
-# Listening port
-port = 8000
-# With debug_on set to true, error traces will be shown in HTTP responses
-debug = True
-authenticate = False
-
-[ui]
-url = http://localhost:8000
diff --git a/testapi/opnfv_testapi/tests/unit/common/nosection.ini b/testapi/opnfv_testapi/tests/unit/common/nosection.ini
deleted file mode 100644
index a9ed49c..0000000
--- a/testapi/opnfv_testapi/tests/unit/common/nosection.ini
+++ /dev/null
@@ -1,11 +0,0 @@
-# to add a new parameter in the config file,
-# the CONF object in config.ini must be updated
-[api]
-# Listening port
-port = 8000
-# With debug_on set to true, error traces will be shown in HTTP responses
-debug = True
-authenticate = False
-
-[ui]
-url = http://localhost:8000
diff --git a/testapi/opnfv_testapi/tests/unit/common/notboolean.ini b/testapi/opnfv_testapi/tests/unit/common/notboolean.ini
deleted file mode 100644
index 3a11f9d..0000000
--- a/testapi/opnfv_testapi/tests/unit/common/notboolean.ini
+++ /dev/null
@@ -1,17 +0,0 @@
-# to add a new parameter in the config file,
-# the CONF object in config.ini must be updated
-[mongo]
-# URL of the mongo DB
-# Mongo auth url => mongodb://user1:pwd1@host1/?authSource=db1
-url = mongodb://127.0.0.1:27017/
-dbname = test_results_collection
-
-[api]
-# Listening port
-port = 8000
-# With debug_on set to true, error traces will be shown in HTTP responses
-debug = True
-authenticate = notboolean
-
-[ui]
-url = http://localhost:8000
diff --git a/testapi/opnfv_testapi/tests/unit/common/notint.ini b/testapi/opnfv_testapi/tests/unit/common/notint.ini
deleted file mode 100644
index 8180719..0000000
--- a/testapi/opnfv_testapi/tests/unit/common/notint.ini
+++ /dev/null
@@ -1,17 +0,0 @@
-# to add a new parameter in the config file,
-# the CONF object in config.ini must be updated
-[mongo]
-# URL of the mongo DB
-# Mongo auth url => mongodb://user1:pwd1@host1/?authSource=db1
-url = mongodb://127.0.0.1:27017/
-dbname = test_results_collection
-
-[api]
-# Listening port
-port = notint
-# With debug_on set to true, error traces will be shown in HTTP responses
-debug = True
-authenticate = False
-
-[ui]
-url = http://localhost:8000
diff --git a/testapi/opnfv_testapi/tests/unit/conftest.py b/testapi/opnfv_testapi/tests/unit/conftest.py
index feff1da..75e621d 100644
--- a/testapi/opnfv_testapi/tests/unit/conftest.py
+++ b/testapi/opnfv_testapi/tests/unit/conftest.py
@@ -5,4 +5,4 @@ import pytest
@pytest.fixture
def config_normal():
- return path.join(path.dirname(__file__), 'common/normal.ini')
+ return path.join(path.dirname(__file__), '../../../etc/config.ini')
diff --git a/testapi/opnfv_testapi/tests/unit/resources/test_base.py b/testapi/opnfv_testapi/tests/unit/resources/test_base.py
index 77a8d18..39633e5 100644
--- a/testapi/opnfv_testapi/tests/unit/resources/test_base.py
+++ b/testapi/opnfv_testapi/tests/unit/resources/test_base.py
@@ -37,7 +37,8 @@ class TestBase(testing.AsyncHTTPTestCase):
def _patch_server(self):
import argparse
- config = path.join(path.dirname(__file__), '../common/normal.ini')
+ config = path.join(path.dirname(__file__),
+ '../../../../etc/config.ini')
self.config_patcher = mock.patch(
'argparse.ArgumentParser.parse_known_args',
return_value=(argparse.Namespace(config_file=config), None))
@@ -46,9 +47,6 @@ class TestBase(testing.AsyncHTTPTestCase):
self.config_patcher.start()
self.db_patcher.start()
- def set_config_file(self):
- self.config_file = 'normal.ini'
-
def get_app(self):
from opnfv_testapi.cmd import server
return server.make_app()
diff --git a/testapi/opnfv_testapi/ui/root.py b/testapi/opnfv_testapi/ui/root.py
index 069ad5e..576cbdd 100644
--- a/testapi/opnfv_testapi/ui/root.py
+++ b/testapi/opnfv_testapi/ui/root.py
@@ -5,7 +5,7 @@ from opnfv_testapi.resources import handlers
class RootHandler(handlers.GenericApiHandler):
def get_template_path(self):
- return CONF.static_path
+ return CONF.ui_static_path
@check.login
def get(self):
diff --git a/testapi/setup.cfg b/testapi/setup.cfg
index ab1ef55..d9aa676 100644
--- a/testapi/setup.cfg
+++ b/testapi/setup.cfg
@@ -23,18 +23,10 @@ setup-hooks =
[files]
packages =
opnfv_testapi
-package_data =
- opnfv_testapi =
- static/*.*
- static/*/*.*
- static/*/*/*.*
- static/*/*/*/*.*
- static/*/*/*/*/*.*
- static/*/*/*/*/*/*.*
- static/*/*/*/*/*/*/*.*
+
data_files =
- /etc/opnfv_testapi =
- etc/config.ini
+ /etc/opnfv_testapi = etc/config.ini
+ /usr/local/share/opnfv_testapi = 3rd_party/static/*
[entry_points]
console_scripts =
@@ -44,4 +36,3 @@ console_scripts =
tag_build =
tag_date = 0
tag_svn_revision = 0
-
diff --git a/testapi/setup.py b/testapi/setup.py
index dd52373..f9d95a3 100644
--- a/testapi/setup.py
+++ b/testapi/setup.py
@@ -1,6 +1,3 @@
-import os
-import subprocess
-
import setuptools
__author__ = 'serena'
@@ -10,11 +7,7 @@ try:
except ImportError:
pass
-dirpath = os.path.dirname(os.path.abspath(__file__))
-subprocess.call(['ln', '-s',
- '{}/3rd_party/static'.format(dirpath),
- '{}/opnfv_testapi/static'.format(dirpath)])
setuptools.setup(
- setup_requires=['pbr==2.0.0'],
+ setup_requires=['pbr>=2.0.0'],
pbr=True)