Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-notes-api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-notes-api
Commits
54091d2e
Commit
54091d2e
authored
Dec 03, 2014
by
Tim Babych
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove unused test mocks
parent
164535be
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
33 deletions
+10
-33
notesapi/v1/tests/helpers.py
+0
-23
notesapi/v1/tests/test_views.py
+10
-10
No files found.
notesapi/v1/tests/helpers.py
View file @
54091d2e
...
...
@@ -4,29 +4,6 @@ from datetime import datetime, timedelta
from
django.conf
import
settings
class
MockConsumer
(
object
):
def
__init__
(
self
,
key
=
'mockconsumer'
):
self
.
key
=
key
self
.
secret
=
'top-secret'
self
.
ttl
=
86400
class
MockUser
(
object
):
def
__init__
(
self
,
id
=
'alice'
,
consumer
=
None
):
self
.
id
=
id
self
.
consumer
=
MockConsumer
(
consumer
if
consumer
is
not
None
else
'mockconsumer'
)
self
.
is_admin
=
False
class
MockAuthenticator
(
object
):
def
request_user
(
self
,
request
):
return
MockUser
()
def
mock_authorizer
(
*
args
,
**
kwargs
):
return
True
def
get_id_token
(
user
):
now
=
datetime
.
utcnow
()
return
jwt
.
encode
({
...
...
notesapi/v1/tests/test_views.py
View file @
54091d2e
...
...
@@ -12,8 +12,9 @@ from rest_framework.test import APITestCase
from
annotator
import
annotation
,
es
,
auth
from
annotator.annotation
import
Annotation
from
.helpers
import
MockUser
,
get_id_token
from
.helpers
import
get_id_token
TEST_USER
=
"test-user-id"
class
BaseAnnotationViewTests
(
APITestCase
):
"""
...
...
@@ -26,13 +27,12 @@ class BaseAnnotationViewTests(APITestCase):
annotation
.
Annotation
.
create_all
()
es
.
conn
.
cluster
.
health
(
wait_for_status
=
'yellow'
)
self
.
user
=
MockUser
(
id
=
"test-user-id"
)
token
=
get_id_token
(
"test-user-id"
)
token
=
get_id_token
(
TEST_USER
)
self
.
client
.
credentials
(
HTTP_X_ANNOTATOR_AUTH_TOKEN
=
token
)
self
.
headers
=
{
"user"
:
"test-user-id"
}
self
.
headers
=
{
"user"
:
TEST_USER
}
self
.
payload
=
{
"user"
:
"test-user-id"
,
"user"
:
TEST_USER
,
"usage_id"
:
"test-usage-id"
,
"course_id"
:
"test-course-id"
,
"text"
:
"test note text"
,
...
...
@@ -50,7 +50,7 @@ class BaseAnnotationViewTests(APITestCase):
self
.
expected_note
=
{
"created"
:
"2014-11-26T00:00:00+00:00"
,
"updated"
:
"2014-11-26T00:00:00+00:00"
,
"user"
:
"test-user-id"
,
"user"
:
TEST_USER
,
"usage_id"
:
"test-usage-id"
,
"course_id"
:
"test-course-id"
,
"text"
:
"test note text"
,
...
...
@@ -74,7 +74,7 @@ class BaseAnnotationViewTests(APITestCase):
Create annotation directly in elasticsearch.
"""
opts
=
{
'user'
:
"test-user-id"
,
'user'
:
TEST_USER
,
}
opts
.
update
(
kwargs
)
annotation
=
Annotation
(
**
opts
)
...
...
@@ -91,7 +91,7 @@ class BaseAnnotationViewTests(APITestCase):
"""
Helper for search method.
"""
url
=
reverse
(
'api:v1:annotations_search'
)
+
'?user=
test-user-id
&{}'
.
format
(
qs
)
url
=
reverse
(
'api:v1:annotations_search'
)
+
'?user=
'
+
TEST_USER
+
'
&{}'
.
format
(
qs
)
result
=
self
.
client
.
get
(
url
)
return
result
.
data
...
...
@@ -124,7 +124,7 @@ class AnnotationViewTests(BaseAnnotationViewTests):
"the response should have a Location header with the URL to read the annotation that was created"
)
self
.
assertEqual
(
self
.
user
.
id
,
response
.
data
[
'user'
]
)
self
.
assertEqual
(
response
.
data
[
'user'
],
TEST_USER
)
def
test_create_ignore_created
(
self
):
"""
...
...
@@ -407,7 +407,7 @@ class TokenTests(BaseAnnotationViewTests):
url
=
reverse
(
'api:v1:annotations'
)
token_data
=
{
'aud'
:
settings
.
CLIENT_ID
,
'sub'
:
"test-user-id"
,
'sub'
:
TEST_USER
,
'iat'
:
timegm
(
datetime
.
utcnow
()
.
utctimetuple
()),
'exp'
:
timegm
((
datetime
.
utcnow
()
+
timedelta
(
seconds
=
300
))
.
utctimetuple
()),
}
...
...
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