Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp
Manage
Activity
Members
Labels
Plan
Issues
99
Issue boards
Milestones
Wiki
Code
Merge requests
5
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
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
djangoldp-packages
djangoldp
Commits
b4b018fc
Commit
b4b018fc
authored
6 years ago
by
Jean-Baptiste
Browse files
Options
Downloads
Patches
Plain Diff
bugfix: default lookup_field should be \'pk\'
parent
301a00d5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!49
bugfix: default lookup_field should be pk
Pipeline
#858
passed with stage
in 1 minute and 22 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
djangoldp/tests/runner.py
+1
-0
1 addition, 0 deletions
djangoldp/tests/runner.py
djangoldp/tests/tests_get.py
+24
-0
24 additions, 0 deletions
djangoldp/tests/tests_get.py
djangoldp/urls.py
+8
-4
8 additions, 4 deletions
djangoldp/urls.py
with
33 additions
and
4 deletions
djangoldp/tests/runner.py
+
1
−
0
View file @
b4b018fc
...
...
@@ -59,6 +59,7 @@ failures = test_runner.run_tests([
'
djangoldp.tests.tests_anonymous_permissions
'
,
'
djangoldp.tests.tests_update
'
,
'
djangoldp.tests.tests_auto_author
'
,
'
djangoldp.tests.tests_get
'
,
])
if
failures
:
sys
.
exit
(
failures
)
...
...
This diff is collapsed.
Click to expand it.
djangoldp/tests/tests_get.py
0 → 100644
+
24
−
0
View file @
b4b018fc
import
json
from
django.contrib.auth.models
import
User
from
rest_framework.test
import
APIRequestFactory
,
APIClient
,
APITestCase
from
djangoldp.tests.models
import
Post
class
TestGET
(
APITestCase
):
def
setUp
(
self
):
self
.
factory
=
APIRequestFactory
()
self
.
client
=
APIClient
()
self
.
user
=
User
.
objects
.
create_user
(
username
=
'
john
'
,
email
=
'
jlennon@beatles.com
'
,
password
=
'
glass onion
'
)
def
tearDown
(
self
):
self
.
user
.
delete
()
def
test_get
(
self
):
post
=
Post
.
objects
.
create
(
content
=
"
content
"
)
response
=
self
.
client
.
get
(
'
/posts/{}/
'
.
format
(
post
.
pk
),
content_type
=
'
application/ld+json
'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEquals
(
response
.
data
[
'
content
'
],
"
content
"
)
self
.
assertIn
(
'
author
'
,
response
.
data
)
This diff is collapsed.
Click to expand it.
djangoldp/urls.py
+
8
−
4
View file @
b4b018fc
...
...
@@ -30,7 +30,11 @@ for class_name in model_classes:
urls_fct
=
model_class
.
get_view_set
().
urls
urlpatterns
.
append
(
url
(
r
'
^
'
+
path
,
include
(
urls_fct
(
model
=
model_class
,
lookup_field
=
getattr
(
model_class
.
_meta
,
'
lookup_field
'
,
getattr
(
model_class
.
Meta
,
'
lookup_field
'
,
[])),
permission_classes
=
getattr
(
model_class
.
_meta
,
'
permission_classes
'
,
getattr
(
model_class
.
Meta
,
'
permission_classes
'
,
[])),
fields
=
getattr
(
model_class
.
_meta
,
'
serializer_fields
'
,
getattr
(
model_class
.
Meta
,
'
serializer_fields
'
,
[])),
nested_fields
=
getattr
(
model_class
.
_meta
,
'
nested_fields
'
,
getattr
(
model_class
.
Meta
,
'
nested_fields
'
,
[]))))))
lookup_field
=
getattr
(
model_class
.
_meta
,
'
lookup_field
'
,
getattr
(
model_class
.
Meta
,
'
lookup_field
'
,
'
pk
'
)),
permission_classes
=
getattr
(
model_class
.
_meta
,
'
permission_classes
'
,
getattr
(
model_class
.
Meta
,
'
permission_classes
'
,
[])),
fields
=
getattr
(
model_class
.
_meta
,
'
serializer_fields
'
,
getattr
(
model_class
.
Meta
,
'
serializer_fields
'
,
[])),
nested_fields
=
getattr
(
model_class
.
_meta
,
'
nested_fields
'
,
getattr
(
model_class
.
Meta
,
'
nested_fields
'
,
[]))))))
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