Added beginging of root logger, modifed setup.py to support python setup.py test.

Added a few todos.
This commit is contained in:
Chris Austin
2011-03-15 19:49:04 -04:00
parent 8023394219
commit c36a9a7d3e
8 changed files with 2181 additions and 16 deletions

10
.bzrignore Normal file
View File

@@ -0,0 +1,10 @@
.idea
build
python_saml2.egg-info
dist
.coverage
htmlcov
*.bak
*.dat
*.dir
*.log

2105
runtests.py Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -17,11 +17,24 @@
# #
# #
from distutils.core import Command
from setuptools import setup, find_packages from setuptools import setup, find_packages
class PyTest(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
import sys,subprocess
errno = subprocess.call([sys.executable, 'runtests.py'])
raise SystemExit(errno)
setup( setup(
name='pysaml2', name='python-saml2',
version='0.2.0', version='0.2.0',
description='Python implementation of SAML Version 2 to be used with WSGI applications', description='Python implementation of SAML Version 2 to be used with WSGI applications',
# long_description = read("README"), # long_description = read("README"),
@@ -29,14 +42,20 @@ setup(
author_email='roland.hedberg@adm.umu.se', author_email='roland.hedberg@adm.umu.se',
license='Apache 2.0', license='Apache 2.0',
url='https://code.launchpad.net/~roland-hedberg/pysaml2/main', url='https://code.launchpad.net/~roland-hedberg/pysaml2/main',
packages=find_packages('src'),
package_dir={'': 'src'}, packages=['saml2', 'xmldsig', 'xmlenc', 's2repoze',
classifiers=[ 's2repoze.plugins'],
"Development Status :: 4 - Beta",
package_dir = {'saml2':'src/saml2', 'xmldsig':'src/xmldsig',
'xmlenc': 'src/xmlenc',
's2repoze': 'src/s2repoze'},
classifiers = ["Development Status :: 4 - Beta",
"License :: OSI Approved :: Apache Software License", "License :: OSI Approved :: Apache Software License",
"Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Libraries :: Python Modules"],
],
scripts=["tools/parse_xsd2.py", "tools/make_metadata.py"], scripts=["tools/parse_xsd2.py", "tools/make_metadata.py"],
install_requires=[ install_requires=[
# core dependencies # core dependencies
'decorator', 'decorator',
@@ -44,10 +63,14 @@ setup(
# for the tests: # for the tests:
'pyasn1', 'pyasn1',
'python-memcached', 'python-memcached',
"pytest",
"pytest-coverage",
# for s2repoze: # for s2repoze:
'paste', 'paste',
'zope.interface', 'zope.interface',
'repoze.who<2.0', 'repoze.who<2.0',
], ],
zip_safe=False, zip_safe=False,
cmdclass = {'test': PyTest},
) )

View File

@@ -47,6 +47,8 @@
# +"see http://codespeak.net/lxml "\ # +"see http://codespeak.net/lxml "\
# +"or http://effbot.org/zone/element-index.htm" # +"or http://effbot.org/zone/element-index.htm"
import logging
try: try:
from xml.etree import cElementTree as ElementTree from xml.etree import cElementTree as ElementTree
except ImportError: except ImportError:
@@ -55,6 +57,9 @@ except ImportError:
except ImportError: except ImportError:
from elementtree import ElementTree from elementtree import ElementTree
root_logger = logging.getLogger("pySAML2")
root_logger.level = logging.NOTSET
NAMESPACE = 'urn:oasis:names:tc:SAML:2.0:assertion' NAMESPACE = 'urn:oasis:names:tc:SAML:2.0:assertion'
#TEMPLATE = '{urn:oasis:names:tc:SAML:2.0:assertion}%s' #TEMPLATE = '{urn:oasis:names:tc:SAML:2.0:assertion}%s'
#XSI_NAMESPACE = 'http://www.w3.org/2001/XMLSchema-instance' #XSI_NAMESPACE = 'http://www.w3.org/2001/XMLSchema-instance'

View File

@@ -83,6 +83,17 @@ class Config(dict):
return self return self
def log_level(self):
"""Pass
"""
# The assumption that I am currently working on is that the app should
# be capable of specifying a logger of any manner as long as it
# follows the logging idiom found in the python standard lib.
if "logging" in self.keys():
log_level = self["logging"]
def xmlsec(self): def xmlsec(self):
return self["xmlsec_binary"] return self["xmlsec_binary"]
@@ -122,6 +133,9 @@ class Config(dict):
def attribute_converters(self): def attribute_converters(self):
return self["attrconverters"] return self["attrconverters"]
def set_logger(self):
pass
def debug(self): def debug(self):
try: try:
return self["debug"] return self["debug"]

View File

@@ -1,5 +1,6 @@
import os import os
#TODO: On my system this function seems to be returning an incorrect location
def pytest_funcarg__xmlsec(request): def pytest_funcarg__xmlsec(request):
for path in os.environ["PATH"].split(":"): for path in os.environ["PATH"].split(":"):
fil = os.path.join(path, "xmlsec1") fil = os.path.join(path, "xmlsec1")

View File

@@ -68,8 +68,14 @@ def test_add_duration_2():
assert t.tm_sec == 0 assert t.tm_sec == 0
def test_str_to_time(): def test_str_to_time():
t = time.mktime(str_to_time("2000-01-12T00:00:00Z")) import calendar
assert t == 947631600.0 t = calendar.timegm(str_to_time("2000-01-12T00:00:00Z"))
#TODO: Find all instances of time.mktime(.....)
#t = time.mktime(str_to_time("2000-01-12T00:00:00Z"))
#assert t == 947631600.0
#TODO: add something to show how this time was arrived at
# do this as an external method in the
assert t == 947635200
def test_instant(): def test_instant():
inst = str_to_time(instant()) inst = str_to_time(instant())

View File

@@ -54,7 +54,8 @@ class TestIdentifier():
assert nameid.text.strip() != nameid2.text.strip() assert nameid.text.strip() != nameid2.text.strip()
def teardown_class(self): def teardown_class(self):
os.unlink("foobar.db") if os.path.exists("foobar.db"):
os.unlink("foobar.db")
class TestServer1(): class TestServer1():
def setup_class(self): def setup_class(self):