FAQ
| This is a
LIVE
service |
Changelog
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Lookup
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Information Services
DevOps
Django Libraries
Lookup
Commits
827acd82
Commit
827acd82
authored
10 years ago
by
Dr Abraham Martin
Browse files
Options
Downloads
Patches
Plain Diff
added first tests
parent
759cbfac
Branches
run-pipeline
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.travis.yml
+15
-0
15 additions, 0 deletions
.travis.yml
runtests.py
+47
-0
47 additions, 0 deletions
runtests.py
setup.py
+27
-0
27 additions, 0 deletions
setup.py
ucamlookup/tests.py
+26
-0
26 additions, 0 deletions
ucamlookup/tests.py
with
115 additions
and
0 deletions
.travis.yml
0 → 100644
+
15
−
0
View file @
827acd82
language
:
python
python
:
-
2.7
-
3.3
-
3.4
env
:
-
DJANGO=django==1.6.5
-
DJANGO=https://www.djangoproject.com/download/1.7c2/tarball/
install
:
-
pip install $DJANGO
-
pip install requests
-
python setup.py -q install
script
:
python runtests.py
notifications
:
email
:
false
\ No newline at end of file
This diff is collapsed.
Click to expand it.
runtests.py
0 → 100755
+
47
−
0
View file @
827acd82
import
logging
import
os
,
sys
import
django
DIRNAME
=
os
.
path
.
dirname
(
__file__
)
from
django.conf
import
settings
settings
.
configure
(
DEBUG
=
False
,
DATABASES
=
{
'
default
'
:
{
'
ENGINE
'
:
'
django.db.backends.sqlite3
'
,
'
NAME
'
:
'
test.db
'
,
}},
TIME_ZONE
=
'
Europe/London
'
,
USE_TZ
=
True
,
ROOT_URLCONF
=
'
ucamlookup.urls
'
,
INSTALLED_APPS
=
(
'
django.contrib.auth
'
,
'
django.contrib.contenttypes
'
,
'
django.contrib.sessions
'
,
'
django.contrib.sites
'
,
'
django.contrib.messages
'
,
'
django.contrib.staticfiles
'
,
'
ucamlookup
'
,
),
MIDDLEWARE_CLASSES
=
(
'
django.contrib.sessions.middleware.SessionMiddleware
'
,
'
django.middleware.common.CommonMiddleware
'
,
'
django.middleware.csrf.CsrfViewMiddleware
'
,
'
django.contrib.auth.middleware.AuthenticationMiddleware
'
,
'
django.contrib.messages.middleware.MessageMiddleware
'
,
'
django.middleware.clickjacking.XFrameOptionsMiddleware
'
,
),
)
logging
.
basicConfig
()
if
django
.
get_version
().
startswith
(
'
1.7
'
):
django
.
setup
()
from
django.test.runner
import
DiscoverRunner
test_runner
=
DiscoverRunner
()
elif
django
.
get_version
().
startswith
(
'
1.6
'
):
from
django.test.runner
import
DiscoverRunner
test_runner
=
DiscoverRunner
()
else
:
from
django.test.simple
import
DjangoTestSuiteRunner
test_runner
=
DjangoTestSuiteRunner
(
verbosity
=
1
)
failures
=
test_runner
.
run_tests
([
'
ucamlookup
'
,
])
if
failures
:
sys
.
exit
(
failures
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
setup.py
0 → 100755
+
27
−
0
View file @
827acd82
#!/usr/bin/env python
from
distutils.core
import
setup
from
setuptools
import
find_packages
setup
(
name
=
'
django-ucamlookup
'
,
description
=
'
A Django module for the University of Cambridge Lookup service
'
,
long_description
=
open
(
'
README.rst
'
).
read
(),
url
=
'
https://git.csx.cam.ac.uk/x/ucs/u/amc203/django-ucamlookup.git
'
,
version
=
'
1.0
'
,
license
=
'
MIT
'
,
author
=
'
Information Systems Group, University Information Services, University of Cambridge
'
,
author_email
=
'
information-systems@ucs.cam.ac.uk
'
,
packages
=
find_packages
(),
include_package_data
=
True
,
install_requires
=
[
'
django
'
],
classifiers
=
[
'
Development Status :: 5 - Production/Stable
'
,
'
Environment :: Web Environment
'
,
'
Framework :: Django
'
,
'
Intended Audience :: Developers
'
,
'
License :: OSI Approved :: MIT License
'
,
'
Operating System :: OS Independent
'
,
'
Programming Language :: Python
'
,
],
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ucamlookup/tests.py
+
26
−
0
View file @
827acd82
from
django.contrib.auth.models
import
User
,
Group
from
django.test
import
TestCase
from
ucamlookup
import
user_in_groups
class
UcamLookupTests
(
TestCase
):
def
test_get_or_create_user_or_group
(
self
):
with
self
.
assertRaises
(
User
.
DoesNotExist
):
User
.
objects
.
get
(
username
=
"
amc203
"
)
user1
=
User
.
objects
.
create_user
(
username
=
"
amc203
"
)
user2
=
User
.
objects
.
get
(
username
=
"
amc203
"
)
self
.
assertEqual
(
user1
.
id
,
user2
.
id
)
with
self
.
assertRaises
(
Group
.
DoesNotExist
):
Group
.
objects
.
get
(
pk
=
101888
)
group1
=
Group
.
objects
.
create
(
pk
=
101888
)
group2
=
Group
.
objects
.
get
(
pk
=
101888
)
self
.
assertEqual
(
group1
.
id
,
group2
.
id
)
def
test_user_in_groups
(
self
):
amc203
=
User
.
objects
.
create_user
(
username
=
"
amc203
"
)
information_systems_group
=
Group
.
objects
.
create
(
pk
=
101888
)
self
.
assertTrue
(
user_in_groups
(
amc203
,
[
information_systems_group
]))
finance_group
=
Group
.
objects
.
create
(
pk
=
101923
)
self
.
assertFalse
(
user_in_groups
(
amc203
,
[
finance_group
]))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment