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
a6c61a2b
Commit
a6c61a2b
authored
9 years ago
by
Mark Skipper
Browse files
Options
Downloads
Patches
Plain Diff
Add test for create api
parent
31d29815
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
django/website/transport/data_layer_transport.py
+5
-3
5 additions, 3 deletions
django/website/transport/data_layer_transport.py
django/website/transport/tests/item_create_tests.py
+18
-8
18 additions, 8 deletions
django/website/transport/tests/item_create_tests.py
with
23 additions
and
11 deletions
django/website/transport/data_layer_transport.py
+
5
−
3
View file @
a6c61a2b
from
rest_framework.test
import
APIRequestFactory
from
data_layer.handlers
import
Message
from
rest_api.views
import
ItemList
...
...
@@ -9,5 +8,8 @@ def get_messages(**kwargs): # TODO rename get_items
view
=
ItemList
.
as_view
()
return
view
(
request
).
data
def
create_message
(
message
):
# TODO rename create_item
Message
.
create
(
message
)
def
create_message
(
item
):
# TODO rename create_item
view
=
ItemList
.
as_view
()
request
=
APIRequestFactory
().
post
(
'
/items
'
,
item
)
return
view
(
request
)
This diff is collapsed.
Click to expand it.
django/website/transport/tests/item_create_tests.py
+
18
−
8
View file @
a6c61a2b
from
__future__
import
unicode_literals
,
absolute_import
import
pytest
from
transport
import
data_layer_transport
as
dl
from
django.utils
import
timezone
from
data_layer.models
import
Item
@pytest.mark.xfail
@pytest.mark.django_db
def
test_create_message_creates_item
():
# now = timezone.now().replace(
# microsecond=0 # MySQL discards microseconds
# )
# item = {'body': "Text", 'timestamp': now}
# dl.create_message(item)
# create.assert_called_with(message)
assert
False
now
=
timezone
.
now
().
replace
(
microsecond
=
0
# MySQL discards microseconds
)
item
=
{
'
body
'
:
"
Text
"
,
'
timestamp
'
:
now
}
old_count
=
Item
.
objects
.
count
()
response
=
dl
.
create_message
(
item
)
assert
response
.
status_code
==
201
assert
'
id
'
in
response
.
data
new_count
=
Item
.
objects
.
count
()
assert
new_count
>
old_count
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