Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Debian New Member Process
nm.debian.org
Commits
6210b2d5
Verified
Commit
6210b2d5
authored
May 25, 2021
by
Mattia Rizzolo
Browse files
dsa: refactor test flow
Signed-off-by:
Mattia Rizzolo
<
mattia@debian.org
>
parent
250d1ac9
Changes
1
Hide whitespace changes
Inline
Side-by-side
dsa/tests/test_models.py
View file @
6210b2d5
...
...
@@ -7,35 +7,30 @@ import django.db
class
TestLDAPFields
(
TestCase
):
def
test_uid
(
self
):
person
=
Person
.
objects
.
create_user
(
fullname
=
"Test"
,
email
=
"test@example.org"
,
audit_skip
=
True
)
person
=
Person
.
objects
.
create_user
(
fullname
=
"Test"
,
email
=
"test@example.org"
,
audit_skip
=
True
)
f
=
LDAPFields
.
objects
.
create
(
person
=
person
,
cn
=
"Test"
,
audit_skip
=
True
)
f
.
uid
=
"foo"
f
.
full_clean
()
f
.
save
(
audit_skip
=
True
)
f
.
uid
=
"foo-guest"
with
self
.
assertRaises
(
ValidationError
):
f
.
full_clean
()
f
.
uid
=
"bo"
with
self
.
assertRaises
(
ValidationError
):
f
.
full_clean
()
f
.
uid
=
"fooBar"
with
self
.
assertRaises
(
ValidationError
):
f
.
full_clean
()
f
.
uid
=
"foo.bar"
with
self
.
assertRaises
(
ValidationError
):
f
.
full_clean
()
f
.
uid
=
"root"
with
self
.
assertRaises
(
ValidationError
):
f
.
full_clean
()
for
u
in
(
"foo-guest"
,
"bo"
,
"fooBar"
,
"foo.bar"
,
"root"
,
):
f
.
uid
=
u
with
self
.
assertRaises
(
ValidationError
):
f
.
full_clean
()
# Test duplicate checks on uid
self
.
assertEqual
(
LDAPFields
.
objects
.
filter
(
uid
=
"foo"
).
count
(),
1
)
person1
=
Person
.
objects
.
create_user
(
fullname
=
"Test1"
,
email
=
"test1@example.org"
,
audit_skip
=
True
)
person1
=
Person
.
objects
.
create_user
(
fullname
=
"Test1"
,
email
=
"test1@example.org"
,
audit_skip
=
True
)
f1
=
LDAPFields
.
objects
.
create
(
person
=
person1
,
cn
=
"Test1"
,
audit_skip
=
True
)
f1
.
uid
=
"foo"
with
self
.
assertRaises
(
ValidationError
):
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment