示例#1
0
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',
                  body='{"token": "foobar"}',
                  status=200,
                  content_type='application/json',
                  match_querystring=True)

    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("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',
                  body=json.dumps(bug_dict),
                  status=200,
                  content_type='application/json',
                  match_querystring=True)
    bugzilla.put(bug)
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)