Skip to content

Commit

Permalink
Add test to ensure bug creation limits posted fields
Browse files Browse the repository at this point in the history
  • Loading branch information
pyoor committed Oct 13, 2020
1 parent b6e7c1a commit b9d8af8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions requirements.txt
@@ -1,5 +1,6 @@
six
pytest
pytest-mock
flake8
requests
responses
Expand Down
22 changes: 22 additions & 0 deletions tests/test_bugsy.py
Expand Up @@ -2,6 +2,7 @@

import responses

from bugsy.bugsy import ALLOWED_FIELDS
from bugsy import (Bugsy, Bug)
from bugsy.errors import (BugsyException, LoginException)
from . import rest_url
Expand Down Expand Up @@ -115,9 +116,30 @@ def test_we_can_create_a_new_remote_bug():
body=json.dumps(bug_dict), status=200,
content_type='application/json')
bugzilla = Bugsy("foo", "bar")

bugzilla.put(bug)
assert bug.id != None

@responses.activate
def test_bug_create_and_filter_invalid_fields(mocker, bug_return):
responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login',
body='{"token": "user"}', status=200,
content_type='application/json', match_querystring=True)
responses.add(responses.POST, 'https://bugzilla.mozilla.org/rest/bug',
body='{"id": 12345}', status=200,
content_type='application/json')

# Remove ID
bug_dict = bug_return['bugs'][0].copy()
del bug_dict["id"]
bug = Bug(**bug_dict)

bugzilla = Bugsy(username="user", password="pass")
spy = mocker.spy(bugzilla, "request")
bugzilla.put(bug)
request_args = spy.call_args_list[0].kwargs["json"].keys()
assert all(key in ALLOWED_FIELDS for key in request_args)

@responses.activate
def test_we_can_put_a_current_bug(bug_return):
responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login',
Expand Down

0 comments on commit b9d8af8

Please sign in to comment.