summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2016-09-20 17:04:39 -0400
committerKali Kaneko <kali@leap.se>2016-09-20 17:04:39 -0400
commit73f71ff59fa0787ea661b7d0c11ffa0261609d49 (patch)
treeb797e35d348af9cf577869f5e67ef1fc78ff22e2
parente05d61b662d0750f85579b74f033d5c4245ed92f (diff)
parent8e74ba115f32bdd56a212a4015b836c4ddd7a57a (diff)
Merge tag '0.5.2' into debian/experimental
0.5.2
-rw-r--r--.gitignore1
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--CHANGELOG.rst3
-rw-r--r--changes/next-changelog.rst2
-rw-r--r--pkg/requirements-testing.pip3
-rw-r--r--pkg/requirements.pip1
-rw-r--r--setup.cfg2
-rw-r--r--setup.py1
-rw-r--r--src/leap/common/__init__.py2
-rw-r--r--src/leap/common/config/__init__.py22
-rw-r--r--src/leap/common/events/tests/__init__.py0
-rw-r--r--src/leap/common/tests/__init__.py0
-rw-r--r--tests/config/test_baseconfig.py (renamed from src/leap/common/config/tests/test_baseconfig.py)18
-rw-r--r--tests/config/test_get_path_prefix.py (renamed from src/leap/common/config/tests/test_get_path_prefix.py)28
-rw-r--r--tests/events/test_auth.py (renamed from src/leap/common/events/tests/test_auth.py)3
-rw-r--r--tests/events/test_events.py (renamed from src/leap/common/events/tests/test_events.py)0
-rw-r--r--tests/events/test_zmq_components.py (renamed from src/leap/common/events/tests/test_zmq_components.py)0
-rw-r--r--tests/test_certs.py (renamed from src/leap/common/tests/test_certs.py)10
-rw-r--r--tests/test_check.py (renamed from src/leap/common/tests/test_check.py)0
-rw-r--r--tests/test_http.py (renamed from src/leap/common/tests/test_http.py)6
-rw-r--r--tests/test_memoize.py (renamed from src/leap/common/tests/test_memoize.py)0
-rw-r--r--tests/testing/test_basetest.py (renamed from src/leap/common/testing/test_basetest.py)4
-rw-r--r--tox.ini17
23 files changed, 80 insertions, 45 deletions
diff --git a/.gitignore b/.gitignore
index 0e26c09..7f9adc3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
*.egg-info
*.swp
*.swo
+.tox
dist/
build/
MANIFEST
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..bc95387
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,2 @@
+test:
+ script: tox
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 3c02982..3e5dd12 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -6,6 +6,9 @@ Changelog
====
2016
====
+0.5.2 Jul 11, 2016
+++++++++++++++++++
+- Remove dependency on dirspec
0.5.1 Apr 18, 2016
+++++++++++++++++++
diff --git a/changes/next-changelog.rst b/changes/next-changelog.rst
index 1371e2c..3b08499 100644
--- a/changes/next-changelog.rst
+++ b/changes/next-changelog.rst
@@ -1,4 +1,4 @@
-0.5.2
+0.5.x
+++++++++++++++++++
Please add lines to this file, they will be moved to the CHANGELOG.rst during
diff --git a/pkg/requirements-testing.pip b/pkg/requirements-testing.pip
deleted file mode 100644
index c5a3ad0..0000000
--- a/pkg/requirements-testing.pip
+++ /dev/null
@@ -1,3 +0,0 @@
-mock
-setuptools-trial
-pep8
diff --git a/pkg/requirements.pip b/pkg/requirements.pip
index b2be31f..b02c8b5 100644
--- a/pkg/requirements.pip
+++ b/pkg/requirements.pip
@@ -3,5 +3,4 @@ pyopenssl
python-dateutil
pyzmq>=14.4.1
txzmq>=0.7.3
-https://launchpad.net/dirspec/stable-13-10/13.10/+download/dirspec-13.10.tar.gz
-e .
diff --git a/setup.cfg b/setup.cfg
index fa30959..19fb54b 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -4,7 +4,7 @@ tag_date = 0
tag_svn_revision = 0
[aliases]
-test = trial
+test=pytest
[pep8]
exclude = versioneer.py,_version.py,*.egg,build,dist,docs
diff --git a/setup.py b/setup.py
index e23ca7d..4269718 100644
--- a/setup.py
+++ b/setup.py
@@ -30,7 +30,6 @@ dependency_links = [requirement for requirement
in requirements if requirement.startswith('http')]
requirements = [requirement for requirement
in requirements if requirement not in dependency_links]
-requirements.append('dirspec')
tests_requirements = [
'mock',
diff --git a/src/leap/common/__init__.py b/src/leap/common/__init__.py
index 3b07cf8..383e198 100644
--- a/src/leap/common/__init__.py
+++ b/src/leap/common/__init__.py
@@ -4,6 +4,7 @@ from leap.common import certs
from leap.common import check
from leap.common import files
from leap.common import events
+from ._version import get_versions
logger = logging.getLogger(__name__)
@@ -16,6 +17,5 @@ except ImportError:
__all__ = ["certs", "check", "files", "events"]
-from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
diff --git a/src/leap/common/config/__init__.py b/src/leap/common/config/__init__.py
index 68d92dc..15c6fea 100644
--- a/src/leap/common/config/__init__.py
+++ b/src/leap/common/config/__init__.py
@@ -18,8 +18,22 @@
Common configs
"""
import os
+import sys
-from dirspec.basedir import get_xdg_config_home
+
+def _get_xdg_config_home():
+ if sys.platform == 'win32':
+ from win32com.shell import shell, shellcon
+ get_path = lambda name: shell.SHGetFolderPath(
+ 0, getattr(shellcon, name), None, 0).encode('utf8')
+ path = get_path('CSIDL_LOCAL_APPDATA')
+ elif sys.platform == 'darwin':
+ user_home = os.path.expanduser('~')
+ path = os.path.join(user_home, 'Library', 'Preferences')
+ else:
+ user_home = os.path.expanduser('~')
+ path = os.path.join(user_home, '.config')
+ return path
def get_path_prefix(standalone=False):
@@ -32,8 +46,6 @@ def get_path_prefix(standalone=False):
configuration storage.
:type standalone: bool
"""
- config_home = get_xdg_config_home()
if standalone:
- config_home = os.path.join(os.getcwd(), "config")
-
- return config_home
+ return os.path.join(os.getcwd(), "config")
+ return _get_xdg_config_home()
diff --git a/src/leap/common/events/tests/__init__.py b/src/leap/common/events/tests/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/src/leap/common/events/tests/__init__.py
+++ /dev/null
diff --git a/src/leap/common/tests/__init__.py b/src/leap/common/tests/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/src/leap/common/tests/__init__.py
+++ /dev/null
diff --git a/src/leap/common/config/tests/test_baseconfig.py b/tests/config/test_baseconfig.py
index e17e82d..22358ec 100644
--- a/src/leap/common/config/tests/test_baseconfig.py
+++ b/tests/config/test_baseconfig.py
@@ -100,7 +100,7 @@ sample_spec = {
}
-class TestConfig(BaseConfig):
+class Config(BaseConfig):
"""
BaseConfig implementation for testing purposes only.
"""
@@ -149,16 +149,16 @@ class BaseConfigTest(BaseLeapTest):
def _get_config(self, fromfile=False, data=sample_config):
"""
- Helper that returns a TestConfig object using the data parameter
+ Helper that returns a Config object using the data parameter
or a sample data.
:param fromfile: sets if we should use a file or a string
:fromfile type: bool
- :param data: sets the data to be used to load in the TestConfig object
+ :param data: sets the data to be used to load in the Config object
:data type: dict (valid json)
- :rtype: TestConfig
+ :rtype: Config
"""
- config = TestConfig()
+ config = Config()
loaded = False
if fromfile:
@@ -198,7 +198,7 @@ class BaseConfigTest(BaseLeapTest):
self.assertEqual(config.get_gateways(), sample_config["gateways"])
def test_safe_get_value_no_config(self):
- config = TestConfig()
+ config = Config()
with self.assertRaises(AssertionError):
config.get_version()
@@ -213,7 +213,7 @@ class BaseConfigTest(BaseLeapTest):
self.assertTrue(config.loaded())
def test_not_loaded(self):
- config = TestConfig()
+ config = Config()
self.assertFalse(config.loaded())
def test_save_and_load(self):
@@ -222,7 +222,7 @@ class BaseConfigTest(BaseLeapTest):
config_file = 'test_config.json'
self.assertTrue(config.save([config_file]))
- config_saved = TestConfig()
+ config_saved = Config()
config_file_path = self.get_tempfile(config_file)
self.assertTrue(config_saved.load(config_file_path, relative=False))
@@ -243,7 +243,7 @@ class BaseConfigTest(BaseLeapTest):
conf = copy.deepcopy(sample_config)
conf['default_language'] = lang
json_string = json.dumps(conf)
- config = TestConfig()
+ config = Config()
config.load(data=json_string)
return config
diff --git a/src/leap/common/config/tests/test_get_path_prefix.py b/tests/config/test_get_path_prefix.py
index 27824fc..878e2fe 100644
--- a/src/leap/common/config/tests/test_get_path_prefix.py
+++ b/tests/config/test_get_path_prefix.py
@@ -19,11 +19,8 @@ Tests for get_path_prefix
"""
import os
import mock
-
-try:
- import unittest2 as unittest
-except ImportError:
- import unittest
+import pytest
+import sys
from leap.common.config import get_path_prefix
from leap.common.testing.basetest import BaseLeapTest
@@ -36,7 +33,7 @@ class GetPathPrefixTest(BaseLeapTest):
Note: we only are testing that the path is correctly returned and that if
we are not in a bundle (standalone=False) then the paths are different.
- dirspec calculates the correct path using different methods and dlls
+ xdg calculates the correct path using different methods and dlls
(in case of Windows) so we don't implement tests to check if the paths
are the correct ones.
"""
@@ -58,6 +55,21 @@ class GetPathPrefixTest(BaseLeapTest):
path = get_path_prefix(standalone=False)
self.assertNotEquals(path, standalone_path)
+homedir = os.environ.get('HOME')
+
-if __name__ == "__main__":
- unittest.main(verbosity=2)
+@pytest.mark.parametrize(
+ "scenario", [
+ # (platform, path_parts, standalone),
+ ('linux', [homedir, '.config'], False),
+ ('darwin', [homedir, 'Library/Preferences'], False),
+ ('win32', [homedir, 'xyz'], False),
+ ('standalone', [os.getcwd(), 'config'], True)])
+def test_get_path_prefix(scenario, monkeypatch):
+ platform, path_parts, standalone = scenario
+ if platform == 'win32':
+ pytest.skip() # TODO: find a way to add test for win32 platform
+ # set a custom temporary platform
+ monkeypatch.setattr(sys, 'platform', platform)
+ expected_prefix = os.path.join(*path_parts)
+ assert expected_prefix == get_path_prefix(standalone)
diff --git a/src/leap/common/events/tests/test_auth.py b/tests/events/test_auth.py
index 78ffd9f..5442ebd 100644
--- a/src/leap/common/events/tests/test_auth.py
+++ b/tests/events/test_auth.py
@@ -33,8 +33,6 @@ from txzmq.test import _wait
class ZmqAuthTestCase(unittest.TestCase, BaseLeapTest):
def setUp(self):
- self.setUpEnv(launch_events_server=False)
-
self.factory = ZmqFactory()
self._config_prefix = os.path.join(self.tempdir, "leap", "events")
@@ -47,7 +45,6 @@ class ZmqAuthTestCase(unittest.TestCase, BaseLeapTest):
def tearDown(self):
self.factory.shutdown()
- self.tearDownEnv()
def test_curve_auth(self):
self.auth_req.start()
diff --git a/src/leap/common/events/tests/test_events.py b/tests/events/test_events.py
index d8435c6..d8435c6 100644
--- a/src/leap/common/events/tests/test_events.py
+++ b/tests/events/test_events.py
diff --git a/src/leap/common/events/tests/test_zmq_components.py b/tests/events/test_zmq_components.py
index c51e37e..c51e37e 100644
--- a/src/leap/common/events/tests/test_zmq_components.py
+++ b/tests/events/test_zmq_components.py
diff --git a/src/leap/common/tests/test_certs.py b/tests/test_certs.py
index 8ebc0f4..b06fbf8 100644
--- a/src/leap/common/tests/test_certs.py
+++ b/tests/test_certs.py
@@ -18,7 +18,6 @@
Tests for:
* leap/common/certs.py
"""
-import os
import time
try:
@@ -28,10 +27,9 @@ except ImportError:
from leap.common import certs
from leap.common.testing.basetest import BaseLeapTest
+from leap.common.testing.https_server import where
-TEST_CERT_PEM = os.path.join(
- os.path.split(__file__)[0],
- '..', 'testing', "leaptest_combined_keycert.pem")
+TEST_CERT_PEM = where("leaptest_combined_keycert.pem")
# Values from the test cert file:
# Not Before: Sep 3 17:52:16 2013 GMT
@@ -43,10 +41,10 @@ CERT_NOT_AFTER = (2023, 9, 1, 17, 52, 16, 4, 244, 0)
class CertsTest(BaseLeapTest):
def setUp(self):
- self.setUpEnv()
+ pass
def tearDown(self):
- self.tearDownEnv()
+ pass
def test_should_redownload_if_no_cert(self):
self.assertTrue(certs.should_redownload(certfile=""))
diff --git a/src/leap/common/tests/test_check.py b/tests/test_check.py
index cd488ff..cd488ff 100644
--- a/src/leap/common/tests/test_check.py
+++ b/tests/test_check.py
diff --git a/src/leap/common/tests/test_http.py b/tests/test_http.py
index f44550f..d5526e6 100644
--- a/src/leap/common/tests/test_http.py
+++ b/tests/test_http.py
@@ -18,7 +18,6 @@
Tests for:
* leap/common/http.py
"""
-import os
try:
import unittest2 as unittest
except ImportError:
@@ -26,10 +25,9 @@ except ImportError:
from leap.common import http
from leap.common.testing.basetest import BaseLeapTest
+from leap.common.testing.https_server import where
-TEST_CERT_PEM = os.path.join(
- os.path.split(__file__)[0],
- '..', 'testing', "leaptest_combined_keycert.pem")
+TEST_CERT_PEM = where("leaptest_combined_keycert.pem")
class HTTPClientTest(BaseLeapTest):
diff --git a/src/leap/common/tests/test_memoize.py b/tests/test_memoize.py
index c923fc5..c923fc5 100644
--- a/src/leap/common/tests/test_memoize.py
+++ b/tests/test_memoize.py
diff --git a/src/leap/common/testing/test_basetest.py b/tests/testing/test_basetest.py
index ec42a62..8be7aba 100644
--- a/src/leap/common/testing/test_basetest.py
+++ b/tests/testing/test_basetest.py
@@ -83,10 +83,10 @@ class TestInitBaseLeapTest(BaseLeapTest):
"""
def setUp(self):
- self.setUpEnv()
+ pass
def tearDown(self):
- self.tearDownEnv()
+ pass
def test_path_is_changed(self):
"""tests whether we have changed the PATH env var"""
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..5ca1ca4
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,17 @@
+# Tox (http://tox.testrun.org/) is a tool for running tests
+# in multiple virtualenvs. This configuration file will run the
+# test suite on all supported python versions. To use it, "pip install tox"
+# and then run "tox" from this directory.
+
+[tox]
+envlist = py27
+
+[testenv]
+commands = py.test {posargs}
+deps =
+ pytest
+ mock
+ setuptools-trial
+ pep8
+setenv =
+ HOME=/tmp