Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
go
Commits
b84a1e57
Unverified
Commit
b84a1e57
authored
Mar 13, 2017
by
David Haynes
Browse files
Test the URL target field
- that it accepts valid URLs and rejects long ones
parent
68518b7a
Pipeline
#1087
passed with stage
in 56 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
go/go/test_models.py
View file @
b84a1e57
...
...
@@ -234,11 +234,13 @@ class URLTest(TestCase):
testing methods
"""
# Setup a blank URL object with an owner
User
.
objects
.
create
(
username
=
'dhaynes'
,
password
=
'password'
)
get_user
=
User
.
objects
.
get
(
username
=
'dhaynes'
)
get_registered_user
=
RegisteredUser
.
objects
.
get
(
user
=
get_user
)
URL
.
objects
.
create
(
owner
=
get_registered_user
)
# Create a dummy User object
User
.
objects
.
create
(
username
=
'evildhaynes'
,
password
=
'password'
)
# owner --------------------------------------------------------------------
...
...
@@ -269,12 +271,15 @@ class URLTest(TestCase):
Test that the timedate is set properly on URL creation
"""
# Get a date
now
=
timezone
.
now
# Get the URL to apply it to
get_user
=
User
.
objects
.
get
(
username
=
'dhaynes'
)
get_registered_user
=
RegisteredUser
.
objects
.
get
(
user
=
get_user
)
current_url
=
URL
.
objects
.
get
(
owner
=
get_registered_user
)
# Apply the date
current_url
.
date_created
=
now
self
.
assertEqual
(
current_url
.
date_created
,
now
)
...
...
@@ -282,6 +287,46 @@ class URLTest(TestCase):
# target -------------------------------------------------------------------
def
test_target
(
self
):
"""
Test that the target field properly accepts a URL
"""
# Get a URL
test_url
=
"https://dhaynes.xyz"
# Get the URL to apply it to
get_user
=
User
.
objects
.
get
(
username
=
'dhaynes'
)
get_registered_user
=
RegisteredUser
.
objects
.
get
(
user
=
get_user
)
current_url
=
URL
.
objects
.
get
(
owner
=
get_registered_user
)
# Apply the URL
current_url
.
target
=
test_url
self
.
assertEqual
(
current_url
.
target
,
test_url
)
def
test_target_length
(
self
):
"""
Test that we can't input a URL longer than 1000 chars
"""
# Get a URL
test_url
=
"https://ymzvakaamyamelmshikymeodyqogjbmrxfgjsjowjjluzbhmgaahkoflhftnicprokfsmkwzoczfowboagwvarbtozszvumruvjlnmxcyhzltgijfatiacihrnbennvvuiwpjpredeyrqdqvkhyjixohrhpyrhrzaptzfeacvkopzkvxcxapknoelcfapjiwlvwnhulmsadiuzhvjevywwvkjordyhyrqntfueycgasyantpcnartxappzmmhbhtyplatqylunvdfkpcrvjjuvpnprxrgcxzbatfcvipvhetoiuknlnwscrgtwruatjazkrmsbyvrkxjiggejxormncbrxwajhhmuvsmzaclaehievayhtjbublhrljdfrudxcmnmokmlpdvhbgkicbfezdjyxhhspdnnufevvcncdbqkmqbubvrtaeiniowpjuqyuvxpjqfuejubjbphempwgvhlrvmtjuqafsopppjqujpinphyslfyyoiysoozblpjtigjaaqiwwoggjspbotzgwzzjvhgeztcnkzwjeejjzrjrhiqvjurrncoluwmcxmfmhngaqovpxocishflcfklyoowqlgnjsmagadlpgaphptpeoojqkyhsfcyhoxjnfwczhnunyhvlnzcdauydaipefedqalakkfexbkddcyjxofxgvrhriryrjzrnvoudkvuehbrhfwudgsrxktflglkqdqptxeadlhpvgwobwrbyrynbljuzjrogjgpkgfkhaawcykwzpqeahkigkmldxkrzavoqhivlebfhkmwvxgfgveaqdkgxtaixzdlhbdgcygeuwqfquqaojutlrybdrlfvxitectjyfdjtsinsuahnxsfovecymnuswkrcptpkgjreccmhznbxngzhzarmaxenhkfncmmzqyqpiccugfnxdiyifzyjawykpgheayboekztyitvajbwgrnmhrpprmuteofemxtcfqcekwbkqgggggggggggggggg.xyz"
# Get the URL to apply it to
get_user
=
User
.
objects
.
get
(
username
=
'dhaynes'
)
get_registered_user
=
RegisteredUser
.
objects
.
get
(
user
=
get_user
)
current_url
=
URL
.
objects
.
get
(
owner
=
get_registered_user
)
# Apply the URL
current_url
.
target
=
test_url
try
:
current_url
.
save
()
except
DataError
as
ex
:
self
.
assertTrue
(
ex
)
# short --------------------------------------------------------------------
# clicks -------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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