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
25810c1d
Commit
25810c1d
authored
5 years ago
by
msb
Browse files
Options
Downloads
Patches
Plain Diff
added a couple of missing tests
parent
4a62c84e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!15
The tests require a connection to the live lookup server
Pipeline
#2258
passed with warnings
5 years ago
Stage: build
Stage: test
Stage: dast
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ucamlookup/tests.py
+19
-4
19 additions, 4 deletions
ucamlookup/tests.py
with
19 additions
and
4 deletions
ucamlookup/tests.py
+
19
−
4
View file @
25810c1d
...
...
@@ -12,7 +12,7 @@ from django.test import TestCase, override_settings
from
ucamlookup.models
import
LookupGroup
from
ucamlookup.utils
import
user_in_groups
,
get_users_from_query
,
return_visibleName_by_crsid
,
get_groups_from_query
,
\
return_title_by_groupid
,
get_group_ids_of_a_user_in_lookup
,
get_institutions
,
get_institution_name_by_id
,
\
validate_crsid_list
,
validate_groupid_list
,
get_connection
validate_crsid_list
,
validate_groupid_list
,
get_connection
,
get_user_lookupgroups
,
get_users_of_a_group
class
UcamLookupOptionsTests
(
TestCase
):
...
...
@@ -34,7 +34,7 @@ class UcamLookupTests(TestCase):
def
setUp
(
self
):
# fixture for group 101888
mock_101888
=
Mock
(
groupid
=
'
101888
'
,
title
=
'
CS Information Systems team
'
)
self
.
mock_101888
=
Mock
(
groupid
=
'
101888
'
,
title
=
'
CS Information Systems team
'
)
# fixture for institution UIS
mock_uis
=
Mock
(
instid
=
'
UIS
'
)
mock_uis
.
name
=
'
University Information Services
'
...
...
@@ -86,9 +86,11 @@ class UcamLookupTests(TestCase):
elif
path
==
'
api/v1/inst/UIS
'
:
mock_result
.
institution
.
name
=
mock_uis
.
name
elif
path
==
'
api/v1/group/search
'
:
mock_result
.
groups
=
[
mock_101888
]
mock_result
.
groups
=
[
self
.
mock_101888
]
elif
path
==
'
api/v1/person/crsid/amc203/groups
'
:
mock_result
.
groups
=
[
mock_101888
]
mock_result
.
groups
=
[
self
.
mock_101888
]
elif
path
==
'
api/v1/group/101888/members
'
:
mock_result
.
people
=
[
Mock
(
visibleName
=
'
Dr Abraham Martin
'
,
identifier
=
'
amc203
'
)]
else
:
self
.
fail
(
"
%s hasn
'
t been mocked
"
%
path
)
return
mock_result
...
...
@@ -265,5 +267,18 @@ class UcamLookupTests(TestCase):
with
self
.
assertRaises
(
ValidationError
):
validate_groupid_list
([
"
kaskvdkam20e9mciasmdimadf
"
])
def
test_get_user_lookupgroups
(
self
):
amc203
=
User
.
objects
.
create_user
(
username
=
"
amc203
"
)
groups
=
get_user_lookupgroups
(
amc203
)
# check
group
=
next
(
group
for
group
in
groups
if
group
.
lookup_id
==
'
101888
'
)
self
.
assertEqual
(
group
.
name
,
'
CS Information Systems team
'
)
def
test_get_users_of_a_group
(
self
):
users
=
get_users_of_a_group
(
self
.
mock_101888
)
# check
user
=
next
(
user
for
user
in
users
if
user
.
username
==
'
amc203
'
)
self
.
assertEqual
(
user
.
last_name
,
'
Dr Abraham Martin
'
)
def
tearDown
(
self
):
self
.
patcher
.
stop
()
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