本文整理汇总了Python中bugsy.Bugsy.get方法的典型用法代码示例。如果您正苦于以下问题:Python Bugsy.get方法的具体用法?Python Bugsy.get怎么用?Python Bugsy.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bugsy.Bugsy
的用法示例。
在下文中一共展示了Bugsy.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_an_exception_is_raised_when_we_hit_an_error
# 需要导入模块: from bugsy import Bugsy [as 别名]
# 或者: from bugsy.Bugsy import get [as 别名]
def test_an_exception_is_raised_when_we_hit_an_error():
responses.add(responses.GET, rest_url('bug', 1017315),
body="It's all broken", status=500,
content_type='application/json', match_querystring=True)
bugzilla = Bugsy()
with pytest.raises(BugsyException) as e:
bugzilla.get(1017315)
assert str(e.value) == "Message: We received a 500 error with the following: It's all broken"
示例2: test_comment_retrieval
# 需要导入模块: from bugsy import Bugsy [as 别名]
# 或者: from bugsy.Bugsy import get [as 别名]
def test_comment_retrieval():
responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login?login=foo&password=bar',
body='{"token": "foobar"}', status=200,
content_type='application/json', match_querystring=True)
responses.add(responses.GET, rest_url('bug', 1017315, token='foobar'),
body=json.dumps(example_return), status=200,
content_type='application/json', match_querystring=True)
responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug/1017315/comment?token=foobar',
body=json.dumps(comments_return), status=200,
content_type='application/json', match_querystring=True)
bugzilla = Bugsy("foo", "bar")
bug = bugzilla.get(1017315)
comments = bug.get_comments()
assert len(comments) == 2
c1 = comments[0]
assert c1.attachment_id is None
assert c1.author == u'[email protected]'
assert c1.bug_id == 1017315
assert c1.creation_time == datetime.datetime(2014, 03, 27, 23, 47, 45)
assert c1.creator == u'[email protected]'
assert c1.id == 8589785
assert c1.is_private is False
assert c1.text == u'text 1'
assert c1.tags == set([u'tag1', u'tag2'])
assert c1.time == datetime.datetime(2014, 03, 27, 23, 47, 45)
示例3: test_that_we_can_add_a_comment_to_an_existing_bug
# 需要导入模块: from bugsy import Bugsy [as 别名]
# 或者: from bugsy.Bugsy import get [as 别名]
def test_that_we_can_add_a_comment_to_an_existing_bug():
responses.add(
responses.GET,
"https://bugzilla.mozilla.org/rest/login?login=foo&password=bar",
body='{"token": "foobar"}',
status=200,
content_type="application/json",
match_querystring=True,
)
responses.add(
responses.GET,
rest_url("bug", 1017315, token="foobar"),
body=json.dumps(example_return),
status=200,
content_type="application/json",
match_querystring=True,
)
bugzilla = Bugsy("foo", "bar")
bug = bugzilla.get(1017315)
responses.add(
responses.POST,
"https://bugzilla.mozilla.org/rest/bug/1017315/comment?token=foobar",
body=json.dumps({}),
status=200,
content_type="application/json",
match_querystring=True,
)
bug.add_comment("I like sausages")
assert len(responses.calls) == 3
示例4: test_we_can_update_a_bug_from_bugzilla
# 需要导入模块: from bugsy import Bugsy [as 别名]
# 或者: from bugsy.Bugsy import get [as 别名]
def test_we_can_update_a_bug_from_bugzilla():
responses.add(
responses.GET,
rest_url("bug", 1017315),
body=json.dumps(example_return),
status=200,
content_type="application/json",
match_querystring=True,
)
bugzilla = Bugsy()
bug = bugzilla.get(1017315)
import copy
bug_dict = copy.deepcopy(example_return)
bug_dict["bugs"][0]["status"] = "REOPENED"
responses.reset()
responses.add(
responses.GET,
"https://bugzilla.mozilla.org/rest/bug/1017315",
body=json.dumps(bug_dict),
status=200,
content_type="application/json",
)
bug.update()
assert bug.status == "REOPENED"
示例5: test_bugsyexception_raised_for_http_502_when_retrieving_bugs
# 需要导入模块: from bugsy import Bugsy [as 别名]
# 或者: from bugsy.Bugsy import get [as 别名]
def test_bugsyexception_raised_for_http_502_when_retrieving_bugs():
responses.add(responses.GET, rest_url('bug', 123456),
body='Bad Gateway', status=502,
content_type='text/html', match_querystring=True)
bugzilla = Bugsy()
with pytest.raises(BugsyException) as e:
r = bugzilla.get(123456)
assert str(e.value) == "Message: We received a 502 error with the following: Bad Gateway"
示例6: test_we_can_get_a_bug
# 需要导入模块: from bugsy import Bugsy [as 别名]
# 或者: from bugsy.Bugsy import get [as 别名]
def test_we_can_get_a_bug():
responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug/1017315?include_fields=version&include_fields=id&include_fields=summary&include_fields=status&include_fields=op_sys&include_fields=resolution&include_fields=product&include_fields=component&include_fields=platform',
body=json.dumps(example_return), status=200,
content_type='application/json', match_querystring=True)
bugzilla = Bugsy()
bug = bugzilla.get(1017315)
assert bug.id == 1017315
assert bug.status == 'RESOLVED'
assert bug.summary == 'Schedule Mn tests on opt Linux builds on cedar'
示例7: test_we_can_get_a_bug_with_login_token
# 需要导入模块: from bugsy import Bugsy [as 别名]
# 或者: from bugsy.Bugsy import get [as 别名]
def test_we_can_get_a_bug_with_login_token():
responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login?login=foo&password=bar',
body='{"token": "foobar"}', status=200,
content_type='application/json', match_querystring=True)
responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug/1017315?token=foobar',
body=json.dumps(example_return), status=200,
content_type='application/json', match_querystring=True)
bugzilla = Bugsy("foo", "bar")
bug = bugzilla.get(1017315)
assert bug.id == 1017315
assert bug.status == 'RESOLVED'
assert bug.summary == 'Schedule Mn tests on opt Linux builds on cedar'
示例8: test_we_can_get_a_bug_with_login_token
# 需要导入模块: from bugsy import Bugsy [as 别名]
# 或者: from bugsy.Bugsy import get [as 别名]
def test_we_can_get_a_bug_with_login_token():
responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login',
body='{"token": "foobar"}', status=200,
content_type='application/json', match_querystring=True)
responses.add(responses.GET, rest_url('bug', 1017315),
body=json.dumps(example_return), status=200,
content_type='application/json', match_querystring=True)
bugzilla = Bugsy("foo", "bar")
bug = bugzilla.get(1017315)
assert bug.id == 1017315
assert bug.status == 'RESOLVED'
assert bug.summary == 'Schedule Mn tests on opt Linux builds on cedar'
assert responses.calls[1].request.headers['X-Bugzilla-Token'] == 'foobar'
示例9: test_we_can_update_a_bug_from_bugzilla
# 需要导入模块: from bugsy import Bugsy [as 别名]
# 或者: from bugsy.Bugsy import get [as 别名]
def test_we_can_update_a_bug_from_bugzilla():
responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug/1017315',
body=json.dumps(example_return), status=200,
content_type='application/json', match_querystring=True)
bugzilla = Bugsy()
bug = bugzilla.get(1017315)
import copy
bug_dict = copy.deepcopy(example_return)
bug_dict['bugs'][0]['status'] = "REOPENED"
responses.reset()
responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug/1017315',
body=json.dumps(bug_dict), status=200,
content_type='application/json')
bug.update()
assert bug.status == 'REOPENED'
示例10: test_that_we_can_add_a_comment_to_a_bug
# 需要导入模块: from bugsy import Bugsy [as 别名]
# 或者: from bugsy.Bugsy import get [as 别名]
def test_that_we_can_add_a_comment_to_a_bug():
responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login?login=foo&password=bar',
body='{"token": "foobar"}', status=200,
content_type='application/json', match_querystring=True)
responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug/1017315?token=foobar',
body=json.dumps(example_return), status=200,
content_type='application/json', match_querystring=True)
bugzilla = Bugsy("foo", "bar")
bug = bugzilla.get(1017315)
bug.add_comment("I like sausages")
responses.add(responses.POST, 'https://bugzilla.mozilla.org/rest/bug/1017315?token=foobar',
body=json.dumps(example_return), status=200,
content_type='application/json', match_querystring=True)
bugzilla.put(bug)
示例11: test_bugsyexception_raised_for_http_500_when_commenting_on_a_bug
# 需要导入模块: from bugsy import Bugsy [as 别名]
# 或者: from bugsy.Bugsy import get [as 别名]
def test_bugsyexception_raised_for_http_500_when_commenting_on_a_bug():
responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login?login=foo&password=bar',
body='{"token": "foobar"}', status=200,
content_type='application/json', match_querystring=True)
responses.add(responses.GET, rest_url('bug', 1017315, token='foobar'),
body=json.dumps(example_return), status=200,
content_type='application/json', match_querystring=True)
bugzilla = Bugsy("foo", "bar")
bug = bugzilla.get(1017315)
responses.add(responses.POST, 'https://bugzilla.mozilla.org/rest/bug/1017315/comment?token=foobar',
body='Internal Server Error', status=500,
content_type='text/html', match_querystring=True)
with pytest.raises(BugsyException) as e:
bug.add_comment("I like sausages")
assert str(e.value) == "Message: We received a 500 error with the following: Internal Server Error"
示例12: test_we_can_handle_errors_when_retrieving_bugs
# 需要导入模块: from bugsy import Bugsy [as 别名]
# 或者: from bugsy.Bugsy import get [as 别名]
def test_we_can_handle_errors_when_retrieving_bugs():
error_response = {
"code" : 101,
"documentation" : "http://www.bugzilla.org/docs/tip/en/html/api/",
"error" : True,
"message" : "Bug 111111111111 does not exist."
}
responses.add(responses.GET, rest_url('bug', 111111111),
body=json.dumps(error_response), status=404,
content_type='application/json', match_querystring=True)
bugzilla = Bugsy()
try:
bug = bugzilla.get(111111111)
assert False, "A BugsyException should have been thrown"
except BugsyException as e:
assert str(e) == "Message: Bug 111111111111 does not exist."
except Exception as e:
assert False, "Wrong type of exception was thrown"
示例13: test_that_we_can_add_a_comment_to_an_existing_bug
# 需要导入模块: from bugsy import Bugsy [as 别名]
# 或者: from bugsy.Bugsy import get [as 别名]
def test_that_we_can_add_a_comment_to_an_existing_bug():
responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login?login=foo&password=bar',
body='{"token": "foobar"}', status=200,
content_type='application/json', match_querystring=True)
responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug/1017315?token=foobar&include_fields=version&include_fields=id&include_fields=summary&include_fields=status&include_fields=op_sys&include_fields=resolution&include_fields=product&include_fields=component&include_fields=platform',
body=json.dumps(example_return), status=200,
content_type='application/json', match_querystring=True)
bugzilla = Bugsy("foo", "bar")
bug = bugzilla.get(1017315)
responses.add(responses.POST, 'https://bugzilla.mozilla.org/rest/bug/1017315/comment?token=foobar',
body=json.dumps({}), status=200,
content_type='application/json', match_querystring=True)
bug.add_comment("I like sausages")
assert len(responses.calls) == 3
示例14: test_we_raise_an_exception_if_commenting_on_a_bug_that_returns_an_error
# 需要导入模块: from bugsy import Bugsy [as 别名]
# 或者: from bugsy.Bugsy import get [as 别名]
def test_we_raise_an_exception_if_commenting_on_a_bug_that_returns_an_error():
responses.add(
responses.GET,
"https://bugzilla.mozilla.org/rest/login?login=foo&password=bar",
body='{"token": "foobar"}',
status=200,
content_type="application/json",
match_querystring=True,
)
responses.add(
responses.GET,
rest_url("bug", 1017315, token="foobar"),
body=json.dumps(example_return),
status=200,
content_type="application/json",
match_querystring=True,
)
bugzilla = Bugsy("foo", "bar")
bug = bugzilla.get(1017315)
# will now return the following error. This could happen if the bug was open
# when we did a `get()` but is now hidden
error_response = {
"code": 101,
"message": "Bug 1017315 does not exist.",
"documentation": "http://www.bugzilla.org/docs/tip/en/html/api/",
"error": True,
}
responses.add(
responses.POST,
"https://bugzilla.mozilla.org/rest/bug/1017315/comment?token=foobar",
body=json.dumps(error_response),
status=404,
content_type="application/json",
match_querystring=True,
)
try:
bug.add_comment("I like sausages")
assert False, "Should have raised an BugException for the bug not existing"
except BugsyException as e:
assert str(e) == "Message: Bug 1017315 does not exist. Code: 101"
assert len(responses.calls) == 3
示例15: test_we_can_remove_tags_to_bug_comments
# 需要导入模块: from bugsy import Bugsy [as 别名]
# 或者: from bugsy.Bugsy import get [as 别名]
def test_we_can_remove_tags_to_bug_comments():
responses.add(
responses.GET,
"https://bugzilla.mozilla.org/rest/login?login=foo&password=bar",
body='{"token": "foobar"}',
status=200,
content_type="application/json",
match_querystring=True,
)
responses.add(
responses.GET,
rest_url("bug", 1017315, token="foobar"),
body=json.dumps(example_return),
status=200,
content_type="application/json",
match_querystring=True,
)
bugzilla = Bugsy("foo", "bar")
bug = bugzilla.get(1017315)
responses.add(
responses.GET,
"https://bugzilla.mozilla.org/rest/bug/1017315/comment?token=foobar",
body=json.dumps(comments_return),
status=200,
content_type="application/json",
match_querystring=True,
)
comments = bug.get_comments()
responses.add(
responses.PUT,
"https://bugzilla.mozilla.org/rest/bug/comment/8589785/tags?token=foobar",
body=json.dumps(["spam", "foo"]),
status=200,
content_type="application/json",
match_querystring=True,
)
comments[0].remove_tags("foo")
assert len(responses.calls) == 4