本文整理汇总了Python中bugsy.Bugsy类的典型用法代码示例。如果您正苦于以下问题:Python Bugsy类的具体用法?Python Bugsy怎么用?Python Bugsy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Bugsy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_that_we_can_add_a_comment_to_an_existing_bug
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
示例2: test_comment_retrieval
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_we_can_update_a_bug_from_bugzilla
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"
示例4: test_that_we_can_add_a_comment_to_a_bug_before_it_is_put
def test_that_we_can_add_a_comment_to_a_bug_before_it_is_put():
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 = Bug()
bug.summary = "I like cheese"
bug.add_comment("I like sausages")
bug_dict = bug.to_dict().copy()
bug_dict["id"] = 123123
responses.add(
responses.POST,
"https://bugzilla.mozilla.org/rest/bug?token=foobar",
body=json.dumps(bug_dict),
status=200,
content_type="application/json",
match_querystring=True,
)
bugzilla.put(bug)
示例5: test_we_cant_post_without_a_username_or_password
def test_we_cant_post_without_a_username_or_password():
bugzilla = Bugsy()
try:
bugzilla.put("foo")
assert 1 == 0, "Should have thrown when calling put"
except BugsyException as e:
assert str(e) == "Message: Unfortunately you can't put bugs in Bugzilla without credentials"
示例6: test_an_exception_is_raised_when_we_hit_an_error
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"
示例7: test_bugsyexception_raised_for_http_502_when_retrieving_bugs
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"
示例8: test_we_can_get_a_bug
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'
示例9: test_we_cant_post_without_passing_a_bug_object
def test_we_cant_post_without_passing_a_bug_object():
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)
bugzilla = Bugsy("foo", "bar")
try:
bugzilla.put("foo")
assert 1 == 0, "Should have thrown an error about type when calling put"
except BugsyException as e:
assert str(e) == "Message: Please pass in a Bug object when posting to Bugzilla"
示例10: test_we_can_get_a_bug_with_login_token
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'
示例11: test_we_can_get_a_bug_with_login_token
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'
示例12: test_we_can_create_a_new_remote_bug
def test_we_can_create_a_new_remote_bug():
bug = Bug()
bug.summary = "I like foo"
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)
bug_dict = bug.to_dict().copy()
bug_dict['id'] = 123123
responses.add(responses.POST, 'https://bugzilla.mozilla.org/rest/bug',
body=json.dumps(bug_dict), status=200,
content_type='application/json')
bugzilla = Bugsy("foo", "bar")
bugzilla.put(bug)
assert bug.id != None
示例13: test_we_handle_errors_from_bugzilla_when_posting
def test_we_handle_errors_from_bugzilla_when_posting():
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.POST, 'https://bugzilla.mozilla.org/rest/bug',
body='{"error":true,"code":50,"message":"You must select/enter a component."}', status=200,
content_type='application/json')
bugzilla = Bugsy("foo", "bar")
bug = Bug()
try:
bugzilla.put(bug)
assert 1 == 0, "Put should have raised an error"
except BugsyException as e:
assert str(e) == "Message: You must select/enter a component."
示例14: test_we_can_update_a_bug_from_bugzilla
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'
示例15: test_we_can_put_a_current_bug
def test_we_can_put_a_current_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)
bug_dict = example_return.copy()
bug_dict['summary'] = 'I love foo but hate bar'
responses.add(responses.POST, 'https://bugzilla.mozilla.org/rest/bug/1017315',
body=json.dumps(bug_dict), status=200,
content_type='application/json')
bugzilla = Bugsy("foo", "bar")
bug = Bug(**example_return['bugs'][0])
bug.summary = 'I love foo but hate bar'
bugzilla.put(bug)
assert bug.summary == 'I love foo but hate bar'