示例#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)
示例#2
0
def test_can_create_bug_and_set_summary_afterwards():
    bug = Bug()
    assert bug.id == None, "Id has been set"
    assert bug.summary == '', "Summary is not set to nothing on plain initialisation"
    bug.summary = "Foo"
    assert bug.summary == 'Foo', "Summary is not being set"
    assert bug.status == '', 'Status has been set'
示例#3
0
def test_can_create_bug_and_set_summary_afterwards():
    bug = Bug()
    assert bug.id == None, "Id has been set"
    assert bug.summary == '', "Summary is not set to nothing on plain initialisation"
    bug.summary = "Foo"
    assert bug.summary == 'Foo', "Summary is not being set"
    assert bug.status == '', 'Status has been set'
示例#4
0
def test_we_can_put_a_current_bug():
    responses.add(responses.GET,
                  'https://bugzilla.mozilla.org/rest/login',
                  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.PUT,
                  'https://bugzilla.mozilla.org/rest/bug/1017315',
                  body=json.dumps(bug_dict),
                  status=200,
                  content_type='application/json')
    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 = Bug(**example_return['bugs'][0])
    bug.summary = 'I love foo but hate bar'
    bug.assigned_to = "*****@*****.**"

    bugzilla.put(bug)
    assert bug.summary == 'I love foo but hate bar'
    assert bug.assigned_to == "*****@*****.**"
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)
示例#6
0
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
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
示例#8
0
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'
示例#9
0
def test_we_can_put_a_current_bug():
    responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login',
                      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.PUT, 'https://bugzilla.mozilla.org/rest/bug/1017315',
                      body=json.dumps(bug_dict), status=200,
                      content_type='application/json')
    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 = Bug(**example_return['bugs'][0])
    bug.summary = 'I love foo but hate bar'
    bug.assigned_to = "*****@*****.**"

    bugzilla.put(bug)
    assert bug.summary == 'I love foo but hate bar'
    assert bug.assigned_to == "*****@*****.**"
示例#10
0
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'