Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
internewshid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aptivate
client-projects
internewshid
Commits
746ab50d
Commit
746ab50d
authored
9 years ago
by
Mark Skipper
Browse files
Options
Downloads
Patches
Plain Diff
Use mock to test transport
parent
86060dcf
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
deploy/pip_packages.txt
+1
-1
1 addition, 1 deletion
deploy/pip_packages.txt
django/website/transport/tests/message_tests.py
+10
-20
10 additions, 20 deletions
django/website/transport/tests/message_tests.py
with
11 additions
and
21 deletions
deploy/pip_packages.txt
+
1
−
1
View file @
746ab50d
...
...
@@ -12,7 +12,7 @@ MySQL-python==1.2.5
# testing
pytest-django==2.8.0
mock
django-jenkins==0.17.0
...
...
This diff is collapsed.
Click to expand it.
django/website/transport/tests/message_tests.py
+
10
−
20
View file @
746ab50d
from
__future__
import
unicode_literals
,
absolute_import
from
mock
import
patch
from
django.test
import
TestCase
from
django.utils
import
timezone
from
transport
import
data_layer_transport
as
dl
# TODO use mock here to verify the handler methods are being called instead of
# verifying the store behaviour
class
TransportLayerMessageTests
(
TestCase
):
def
test_get_messages_exists
(
self
):
@patch
(
'
data_layer.handlers.Message.list
'
)
def
test_get_messages_uses_list
(
self
,
list
):
list
.
return_value
=
[]
messages
=
dl
.
get_messages
()
self
.
assertEqual
(
len
(
list
(
messages
)),
0
)
self
.
assertEqual
(
messages
,
[])
list
.
assert_called_with
()
def
test_store_messages_exists
(
self
):
message
=
dict
()
@patch
(
'
data_layer.handlers.Message.create
'
)
def
test_store_message_uses_create
(
self
,
create
):
message
=
{}
dl
.
store_message
(
message
)
def
test_stored_messages_can_be_gotten
(
self
):
now
=
timezone
.
now
().
replace
(
microsecond
=
0
# MySQL discards microseconds
)
message
=
dict
(
body
=
"
Text
"
,
timestamp
=
now
)
dl
.
store_message
(
message
)
messagelist
=
list
(
dl
.
get_messages
())
[
outmessage
]
=
messagelist
self
.
assertEqual
(
outmessage
[
'
body
'
],
"
Text
"
)
self
.
assertEqual
(
outmessage
[
'
timestamp
'
],
now
)
create
.
assert_called_with
(
message
)
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