Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from michaelmior/fix-tests
Browse files Browse the repository at this point in the history
Fix vanilla and tox tests
  • Loading branch information
craigbruce committed Jan 10, 2013
2 parents 2be5f08 + 0997de1 commit c90f60a
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 28 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
*.pyc
*.sqlite
docs/build
docs/build
.tox
build/
django_oauth.egg-info/
6 changes: 3 additions & 3 deletions oauth/fixtures/test_entries.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"client_key": 1,
"key": "0QSpixu2mFe-DhJBavQhYz2iCdGS8xYwUegfSUHF",
"secret": "z5HYNBKZWedsvgtaZUVaQhHmpYeJjb",
"timestamp": "2012-06-12T22:01:23.000663-06:00"
"timestamp": "2012-06-12 22:01:23.000663"
}
},
{
Expand All @@ -68,7 +68,7 @@
"client_key": 1,
"key": "0QSpixu2mFe-DhJBavQhYz2iCdGS8xYwUegfSUHF",
"secret": "z5HYNBKZWedsvgtaZUVaQhHmpYeJjb",
"timestamp": "2012-06-12T22:01:23.000663-06:00"
"timestamp": "2012-06-12 22:01:23.000663"
}
},
{
Expand Down Expand Up @@ -98,4 +98,4 @@

}
}
]
]
20 changes: 20 additions & 0 deletions oauth/fixtures/test_user.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"pk": 1,
"model": "auth.user",
"fields": {
"username": "testuser",
"first_name": "",
"last_name": "",
"is_active": true,
"is_superuser": true,
"is_staff": true,
"last_login": "1980-01-01 00:00",
"groups": [],
"user_permissions": [],
"password": "pbkdf2_sha256$10000$T6FFzJNPKkLe$O15V3Z3/MxzBCUDsBCB2/YietIDjtMBwhjj+5JY3JPQ=",
"email": "testuser@example.com",
"date_joined": "1980-01-01 00:00"
}
}
]
33 changes: 15 additions & 18 deletions oauth/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@


class OAuthServerTest(TestCase):
fixtures = ['test_entries.json']
fixtures = ['test_user.json', 'test_entries.json']

def setUp(self):
super(OAuthServerTest, self).setUp()

# Credentials
self.username = 'testuser'
self.password = 'pass'
self.user = User.objects.create_user(
self.username, 'test@example.com', self.password)
self.user = User.objects.get(pk=1)

# Object to test on
self.clientcredentials = ClientCredential.objects.get(pk=1)
Expand Down Expand Up @@ -279,19 +276,19 @@ def test_get_access_token_secret(self):
#
# uri, headers, body = c.sign(u'http://127.0.0.1:8001/initiate/')

#TODO nonce/timestamp/signature will change
self.assertEqual(
headers,
{
u'Authorization': u'OAuth oauth_nonce='
u'"110880830699442379541341263567",'
u'oauth_timestamp="1341263567", oauth_version="1.0",'
u'oauth_signature_method="HMAC-SHA1",'
u'oauth_consumer_key=self.clientcredentials.key,'
u'oauth_callback=self.clientcredentials.callback,'
u'oauth_signature="1emEeMqMx1vgjKEwdwyrz57%2FyTE%3D"',
}
)
# #TODO nonce/timestamp/signature will change
# self.assertEqual(
# headers,
# {
# u'Authorization': u'OAuth oauth_nonce='
# u'"110880830699442379541341263567",'
# u'oauth_timestamp="1341263567", oauth_version="1.0",'
# u'oauth_signature_method="HMAC-SHA1",'
# u'oauth_consumer_key=self.clientcredentials.key,'
# u'oauth_callback=self.clientcredentials.callback,'
# u'oauth_signature="1emEeMqMx1vgjKEwdwyrz57%2FyTE%3D"',
# }
# )

# s = OAuthServer()
# self.assertTrue(s.verify_request(uri, body=body, headers=headers))
Expand Down
8 changes: 6 additions & 2 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
}
},
INSTALLED_APPS=(
'{{ app_name }}',
'django.contrib.auth',
'django.contrib.contenttypes',

'oauth',
),
SITE_ID=1,
SECRET_KEY='this-is-just-for-tests-so-not-that-secret',
USE_TZ=True,
)


Expand All @@ -26,7 +30,7 @@
def runtests():
TestRunner = get_runner(settings)
test_runner = TestRunner(verbosity=1, interactive=True, failfast=False)
failures = test_runner.run_tests(['{{ app_name }}', ])
failures = test_runner.run_tests(['oauth', ])
sys.exit(failures)


Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ def read_file(filename):
return ''

setup(
name='django-{{ app_name }}',
version=__import__('{{ app_name }}').__version__,
name='django-oauth',
version=__import__('oauth').__version__,
author='Craig Bruce',
author_email='craigbruce@gmail.com',
description=u' '.join(__import__('{{ app_name }}').__doc__.splitlines()).strip(),
description=u' '.join(__import__('oauth').__doc__.splitlines()).strip(),
license='BSD',
keywords='django oauth provider',
url='https://github.com/craigbruce/django-oauthlib',
Expand Down
8 changes: 7 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,29 @@ commands = {envpython} runtests.py
[testenv:py27-master]
basepython = python2.7
deps = https://github.com/django/django/zipball/master
oauthlib>=0.3.0

[testenv:py27-1.4.X]
basepython = python2.7
deps = django>=1.4,<1.5
oauthlib>=0.3.0

[testenv:py27-1.3.X]
basepython = python2.7
deps = django>=1.3,<1.4
oauthlib>=0.3.0

[testenv:py26-master]
basepython = python2.6
deps = https://github.com/django/django/zipball/master
oauthlib>=0.3.0

[testenv:py26-1.4.X]
basepython = python2.6
deps = django>=1.4,<1.5
oauthlib>=0.3.0

[testenv:py26-1.3.X]
basepython = python2.6
deps = django>=1.3,<1.4
deps = django>=1.3,<1.4
oauthlib>=0.3.0

0 comments on commit c90f60a

Please sign in to comment.