зеркало из https://github.com/mozilla/treeherder.git
test fixes for auth changes on notes
This commit is contained in:
Родитель
fcbccc2f14
Коммит
0e773dca02
|
@ -120,7 +120,7 @@ def test_note_detail_bad_project(webapp, jm):
|
|||
|
||||
def test_create_note(webapp, eleven_jobs_processed, mock_message_broker, jm):
|
||||
"""
|
||||
test creating a single note via endpoint
|
||||
test creating a single note via endpoint as staff
|
||||
"""
|
||||
client = APIClient()
|
||||
user = User.objects.create(username="MyName", is_staff=True)
|
||||
|
@ -136,9 +136,9 @@ def test_create_note(webapp, eleven_jobs_processed, mock_message_broker, jm):
|
|||
"note": "you look like a man-o-lantern"
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
user.delete()
|
||||
|
||||
|
||||
assert resp.status_code == 200
|
||||
|
||||
content = json.loads(resp.content)
|
||||
|
@ -160,9 +160,11 @@ def test_create_note(webapp, eleven_jobs_processed, mock_message_broker, jm):
|
|||
|
||||
def test_create_note_no_auth(eleven_jobs_processed, jm):
|
||||
"""
|
||||
test creating a single note via endpoint
|
||||
test creating a single note via endpoint when not staff: still succeeds
|
||||
"""
|
||||
client = APIClient()
|
||||
user = User.objects.create(username="MyName", is_staff=False)
|
||||
client.force_authenticate(user=user)
|
||||
|
||||
job = jm.get_job_list(0, 1)[0]
|
||||
resp = client.post(
|
||||
|
@ -175,7 +177,24 @@ def test_create_note_no_auth(eleven_jobs_processed, jm):
|
|||
}
|
||||
)
|
||||
|
||||
assert resp.status_code == 403
|
||||
user.delete()
|
||||
|
||||
assert resp.status_code == 200
|
||||
|
||||
content = json.loads(resp.content)
|
||||
assert content['message'] == 'note stored for job 1'
|
||||
|
||||
note_list = jm.get_job_note_list(job_id=job["id"])
|
||||
del(note_list[0]["note_timestamp"])
|
||||
|
||||
assert note_list[0] == {
|
||||
u'job_id': 1,
|
||||
u'who': u'kelly clarkson',
|
||||
u'failure_classification_id': 2,
|
||||
u'note': u'you look like a man-o-lantern',
|
||||
u'active_status': u'active',
|
||||
u'id': 1
|
||||
}
|
||||
|
||||
jm.disconnect()
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче