[Python-modules-commits] [keyrings.alt] 01/04: Import keyrings.alt_1.1.1.orig.tar.gz
Dmitry Shachnev
mitya57 at moszumanska.debian.org
Wed Mar 2 06:48:03 UTC 2016
This is an automated email from the git hooks/post-receive script.
mitya57 pushed a commit to branch master
in repository keyrings.alt.
commit 7557b527ff033785a35151b9221cf5c0851aa845
Author: Dmitry Shachnev <mitya57 at gmail.com>
Date: Wed Mar 2 09:39:24 2016 +0300
Import keyrings.alt_1.1.1.orig.tar.gz
---
.gitignore | 6 +
.hgtags | 1 +
CHANGES.rst | 8 +-
PKG-INFO | 2 +-
keyrings.alt.egg-info/PKG-INFO | 2 +-
keyrings.alt.egg-info/SOURCES.txt | 1 +
keyrings.alt.egg-info/top_level.txt | 1 -
keyrings/alt/_win_crypto.py | 2 +-
setup.cfg | 4 +-
setup.py | 2 +-
tests/mocks.py | 227 ++++++++++++++++++++++++++++++++++++
tests/test_Google.py | 2 +-
tests/test_Windows.py | 2 +-
tests/test_keyczar.py | 9 +-
tests/test_pyfs.py | 16 +--
15 files changed, 260 insertions(+), 25 deletions(-)
diff --git a/.gitignore b/.gitignore
index e69de29..f9c1e1d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1,6 @@
+dist/
+build/
+.eggs/
+*.pyc
+*.egg-info/
+.cache/
diff --git a/.hgtags b/.hgtags
index fb6f4b7..d67a6f5 100644
--- a/.hgtags
+++ b/.hgtags
@@ -1,3 +1,4 @@
b3173ad03e2b87d50ab31eecc5e6e57e9963785d 1.0
f9defd8cbdfabaeb1739fd02929f272ba7e4be73 1.0.1
acdefb2c6c473bf6460004dbbe1f62280fcdeac8 1.1
+43b2bf00ab0477d3734932feb05ce6d533df255a 1.1.1
diff --git a/CHANGES.rst b/CHANGES.rst
index b8a1c5a..e224b85 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,9 +1,15 @@
+1.1.1
+=====
+
+Test cleanup.
+
+Exclude tests during install.
+
1.1
===
FileBacked backends now have a ``repr`` that includes the file path.
-
1.0
===
diff --git a/PKG-INFO b/PKG-INFO
index 5ba33cf..b397cee 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: keyrings.alt
-Version: 1.1
+Version: 1.1.1
Summary: Alternate keyring implementations
Home-page: https://github.com/jaraco/keyrings.alt
Author: Jason R. Coombs
diff --git a/keyrings.alt.egg-info/PKG-INFO b/keyrings.alt.egg-info/PKG-INFO
index 5ba33cf..b397cee 100644
--- a/keyrings.alt.egg-info/PKG-INFO
+++ b/keyrings.alt.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: keyrings.alt
-Version: 1.1
+Version: 1.1.1
Summary: Alternate keyring implementations
Home-page: https://github.com/jaraco/keyrings.alt
Author: Jason R. Coombs
diff --git a/keyrings.alt.egg-info/SOURCES.txt b/keyrings.alt.egg-info/SOURCES.txt
index bf82f11..96b57bb 100644
--- a/keyrings.alt.egg-info/SOURCES.txt
+++ b/keyrings.alt.egg-info/SOURCES.txt
@@ -28,6 +28,7 @@ keyrings/alt/kwallet.py
keyrings/alt/multi.py
keyrings/alt/pyfs.py
tests/__init__.py
+tests/mocks.py
tests/test_Gnome.py
tests/test_Google.py
tests/test_Windows.py
diff --git a/keyrings.alt.egg-info/top_level.txt b/keyrings.alt.egg-info/top_level.txt
index a664fbf..3814a76 100644
--- a/keyrings.alt.egg-info/top_level.txt
+++ b/keyrings.alt.egg-info/top_level.txt
@@ -1,2 +1 @@
keyrings
-tests
diff --git a/keyrings/alt/_win_crypto.py b/keyrings/alt/_win_crypto.py
index b23d636..fb7f927 100644
--- a/keyrings/alt/_win_crypto.py
+++ b/keyrings/alt/_win_crypto.py
@@ -8,7 +8,7 @@ except ValueError:
# see http://bugs.python.org/issue16396
raise ImportError("wintypes")
-from ..util.escape import u
+from keyring.util.escape import u
# Crypto API ctypes bindings
diff --git a/setup.cfg b/setup.cfg
index 5b8e187..a880e96 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -6,7 +6,7 @@ test = pytest
universal = 1
[egg_info]
-tag_date = 0
-tag_build =
tag_svn_revision = 0
+tag_build =
+tag_date = 0
diff --git a/setup.py b/setup.py
index d9f6099..ecb810b 100644
--- a/setup.py
+++ b/setup.py
@@ -42,7 +42,7 @@ setup_params = dict(
description="Alternate keyring implementations",
long_description=long_description,
url="https://github.com/jaraco/keyrings.alt",
- packages=setuptools.find_packages(),
+ packages=setuptools.find_packages(exclude=['tests']),
include_package_data=True,
namespace_packages=['keyrings'],
install_requires=[
diff --git a/tests/mocks.py b/tests/mocks.py
new file mode 100644
index 0000000..38d95c5
--- /dev/null
+++ b/tests/mocks.py
@@ -0,0 +1,227 @@
+"""
+Various mock objects for testing
+"""
+
+import base64
+import io
+
+from keyring.py27compat import pickle, unicode_str
+
+
+class MockAtom(object):
+ """ Mocks an atom in the GData service. """
+ def __init__(self, value):
+ self.text = value
+
+
+class MockEntry(object):
+ """ Mocks and entry returned from the GData service. """
+ def __init__(self, title, ID):
+ self.title = MockAtom(title)
+ self.id = MockAtom('http://mock.example.com/%s' % ID)
+ self.ID = ID # simpler lookup for key value
+
+ def GetEditMediaLink(self):
+ return MockLink()
+
+
+class MockHTTPClient(object):
+ """ Mocks the functionality of an http client. """
+ def request(*args, **kwargs):
+ pass
+
+
+class MockGDataService(object):
+ """ Provides the common functionality of a Google Service. """
+ http_client = MockHTTPClient()
+ def __init__(self, email=None, password=None,
+ account_type='HOSTED_OR_GOOGLE', service=None,
+ auth_service_url=None, source=None, server=None,
+ additional_headers=None, handler=None, tokens=None,
+ http_client=None, token_store=None):
+ """ Create the Service with the default parameters. """
+ self.email = email
+ self.password = password
+ self.account_type = account_type
+ self.service = service
+ self.auth_service_url = auth_service_url
+ self.server = server
+ self.login_token = None
+
+ def GetClientLoginToken(self):
+ return self.login_token
+
+ def SetClientLoginToken(self, token):
+ self.login_token = token
+
+ def ClientLogin(self, username, password, account_type=None, service=None,
+ auth_service_url=None, source=None, captcha_token=None,
+ captcha_response=None):
+
+ """ Client side login to the service. """
+ if hasattr(self, '_login_err'):
+ raise self._login_err()
+
+
+class MockDocumentService(MockGDataService):
+ """
+ Implements the minimum functionality of the Google Document service.
+ """
+
+ def Upload(self, media_source, title, folder_or_uri=None, label=None):
+ """
+ Upload a document.
+ """
+ if hasattr(self, '_upload_err'):
+ raise self._upload_err()
+ if not hasattr(self, '_upload_count'):
+ self._upload_count = 0
+ # save the data for asserting against
+ self._upload_data = dict(media_source=media_source, title=title,
+ folder_or_uri=folder_or_uri, label=label)
+ self._upload_count += 1
+ return MockEntry(title, 'mockentry%3A' + title)
+
+ def QueryDocumentListFeed(self, uri):
+ if hasattr(self, '_listfeed'):
+ return self._listfeed
+ return MockListFeed()
+
+ def CreateFolder(self, title, folder_or_uri=None):
+ if hasattr(self, '_create_folder_err'):
+ raise self._create_folder_err()
+ if hasattr(self, '_create_folder'):
+ return self._create_folder
+ return MockListEntry()
+
+ def Put(self, data, uri, extra_headers=None, url_params=None,
+ escape_params=True, redirects_remaining=3, media_source=None,
+ converter=None):
+ self._put_data = None
+ if not hasattr(self, '_put_count'):
+ self._put_count = 0
+ if hasattr(self, '_put_err'):
+ # allow for a list of errors
+ if type(self._put_err) == list:
+ put_err = self._put_err.pop(0)
+ if not len(self._put_err):
+ delattr(self, '_put_err')
+ else:
+ put_err = self._put_err
+ if type(put_err) == tuple:
+ raise put_err[0](put_err[1])
+ else:
+ raise put_err()
+ # save the data for asserting against
+ assert isinstance(data, str) or isinstance(data, unicode_str), \
+ 'Should be a string'
+ self._put_data = pickle.loads(base64.urlsafe_b64decode(data))
+ self._put_count += 1
+ return MockEntry('', 'mockentry%3A' + '')
+
+ def Export(self, entry_or_id_or_url, file_path, gid=None, extra_params=None):
+ if hasattr(self, '_export_err'):
+ raise self._export_err()
+ if hasattr(self, '_export_data'):
+ export_file = open(file_path, 'wb')
+ export_file.write(self._export_data)
+ export_file.close()
+
+ def request(self, data, uri):
+ if hasattr(self, '_request_err'):
+ if type(self._request_err) == tuple:
+ raise self._request_err[0](self._request_err[1])
+ else:
+ raise self._request_err()
+ if hasattr(self, '_request_response'):
+ return MockHttpResponse(self._request_response)
+
+
+class MockHttpResponse(io.BytesIO, object):
+
+ def __init__(self, response_dict):
+ super(MockHttpResponse, self).__init__(response_dict.get('data', ''))
+ self.status = response_dict.get('status', 200)
+ self.reason = response_dict.get('reason', '')
+
+
+class MockListFeed(object):
+
+ @property
+ def entry(self):
+ if hasattr(self, '_entry'):
+ return self._entry
+ return []
+
+
+class MockListEntry(object):
+ pass
+
+
+class MockLink(object):
+
+ @property
+ def href(self):
+ return ''
+
+
+class MockContent(object):
+
+ @property
+ def src(self):
+ return 'src'
+
+
+class MockDocumentListEntry(object):
+
+ @property
+ def content(self):
+ return MockContent()
+
+ def GetEditMediaLink(self):
+ return MockLink()
+
+
+class MockKeyczarReader(object):
+
+ def __init__(self, location):
+ self.location = location
+
+
+class MockKeyczarEncryptedReader(object):
+
+ def __init__(self, reader, crypter):
+ self._reader = reader
+ self._crypter = crypter
+
+
+class MockKeyczarReaders(object):
+
+ @staticmethod
+ def CreateReader(location):
+ return MockKeyczarReader(location)
+
+ @staticmethod
+ def EncryptedReader(reader, crypter):
+ return MockKeyczarEncryptedReader(reader, crypter)
+
+
+class MockKeyczarCrypter(object):
+
+ def __init__(self, reader):
+ self.reader = reader
+
+ @staticmethod
+ def Read(location):
+ return MockKeyczarCrypter(MockKeyczarReader(location))
+
+
+class MockKeyczar(object):
+
+ @property
+ def readers(self):
+ return MockKeyczarReaders
+
+ @property
+ def Crypter(self):
+ return MockKeyczarCrypter
diff --git a/tests/test_Google.py b/tests/test_Google.py
index 339c191..bd5760b 100644
--- a/tests/test_Google.py
+++ b/tests/test_Google.py
@@ -8,7 +8,7 @@ from keyring.credentials import SimpleCredential
from keyring.backend import NullCrypter
from keyring import errors
from keyring.py27compat import input, pickle
-from keyring.tests import mocks
+from . import mocks
def is_gdata_supported():
try:
diff --git a/tests/test_Windows.py b/tests/test_Windows.py
index c93c3e2..52f65ed 100644
--- a/tests/test_Windows.py
+++ b/tests/test_Windows.py
@@ -9,7 +9,7 @@ from .test_file import FileKeyringTests
def is_win32_crypto_supported():
try:
- __import__('keyring.backends._win_crypto')
+ __import__('keyrings.alt._win_crypto')
except ImportError:
return False
return sys.platform in ['win32'] and sys.getwindowsversion()[-2] == 2
diff --git a/tests/test_keyczar.py b/tests/test_keyczar.py
index d8e1bda..ee72548 100644
--- a/tests/test_keyczar.py
+++ b/tests/test_keyczar.py
@@ -2,19 +2,14 @@ import os
import unittest
from keyrings.alt import keyczar
-from keyring.tests import mocks
+from . import mocks
-def is_keyczar_supported():
- return hasattr(keyczar, 'keyczar')
-
- at unittest.skipUnless(is_keyczar_supported(),
- "Need Keyczar")
class KeyczarCrypterTestCase(unittest.TestCase):
"""Test the keyczar crypter"""
def setUp(self):
- self._orig_keyczar = keyczar.keyczar
+ self._orig_keyczar = keyczar.keyczar if hasattr(keyczar, 'keyczar') else None
keyczar.keyczar = mocks.MockKeyczar()
def tearDown(self):
diff --git a/tests/test_pyfs.py b/tests/test_pyfs.py
index 361c4d7..5b5c95c 100644
--- a/tests/test_pyfs.py
+++ b/tests/test_pyfs.py
@@ -44,7 +44,7 @@ class UnencryptedMemoryPyfilesystemKeyringNoSubDirTestCase(
keyring_filename = 'mem://unencrypted'
def init_keyring(self):
- return keyring.backends.pyfs.PlaintextKeyring(
+ return pyfs.PlaintextKeyring(
filename=self.keyring_filename)
@@ -56,7 +56,7 @@ class UnencryptedMemoryPyfilesystemKeyringSubDirTestCase(
keyring_filename = 'mem://some/sub/dir/unencrypted'
def init_keyring(self):
- return keyring.backends.pyfs.PlaintextKeyring(
+ return pyfs.PlaintextKeyring(
filename=self.keyring_filename)
@@ -68,7 +68,7 @@ class UnencryptedLocalPyfilesystemKeyringNoSubDirTestCase(
keyring_filename = '%s/keyring.cfg' %tempfile.mkdtemp()
def init_keyring(self):
- return keyring.backends.pyfs.PlaintextKeyring(
+ return pyfs.PlaintextKeyring(
filename=self.keyring_filename)
def test_handles_preexisting_keyring(self):
@@ -81,7 +81,7 @@ class UnencryptedLocalPyfilesystemKeyringNoSubDirTestCase(
""").lstrip()
keyring_file.write(file_data)
keyring_file.close()
- pyf_keyring = keyring.backends.pyfs.PlaintextKeyring(
+ pyf_keyring = pyfs.PlaintextKeyring(
filename=self.keyring_filename)
self.assertEquals('pwd1', pyf_keyring.get_password('svc1', 'user1'))
@@ -102,7 +102,7 @@ class UnencryptedLocalPyfilesystemKeyringSubDirTestCase(
if not os.path.exists(self.keyring_dir):
os.makedirs(self.keyring_dir)
- return keyring.backends.pyfs.PlaintextKeyring(
+ return pyfs.PlaintextKeyring(
filename=self.keyring_filename)
@unittest.skipUnless(pyfs.BasicKeyring.viable, "Need Pyfilesystem")
@@ -111,7 +111,7 @@ class EncryptedMemoryPyfilesystemKeyringTestCase(PyfilesystemKeyringTests,
"""Test in memory with encryption"""
def init_keyring(self):
- return keyring.backends.pyfs.EncryptedKeyring(
+ return pyfs.EncryptedKeyring(
ReverseCrypter(),
filename='mem://encrypted/keyring.cfg')
@@ -121,7 +121,7 @@ class EncryptedLocalPyfilesystemKeyringNoSubDirTestCase(
"""Test using local temp files with encryption"""
def init_keyring(self):
- return keyring.backends.pyfs.EncryptedKeyring(
+ return pyfs.EncryptedKeyring(
ReverseCrypter(),
filename='temp://keyring.cfg')
@@ -131,6 +131,6 @@ class EncryptedLocalPyfilesystemKeyringSubDirTestCase(
"""Test using local temp files with encryption"""
def init_keyring(self):
- return keyring.backends.pyfs.EncryptedKeyring(
+ return pyfs.EncryptedKeyring(
ReverseCrypter(),
filename='temp://a/sub/dir/hierarchy/keyring.cfg')
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/keyrings.alt.git
More information about the Python-modules-commits
mailing list