Example #1
0
def test_we_can_add_single_keyword(bug_return):
    bug = Bug(**bug_return['bugs'][0])
    bug.keywords.append('ateam-marionette-server')
    output = bug.diff()
    assert isinstance(output, dict)
    assert output == {'keywords': {'add': ['ateam-marionette-server']}}
    assert ['regression', 'ateam-marionette-server'] == bug.keywords
Example #2
0
def test_we_throw_an_error_for_invalid_status_types():
    bug = Bug(**example_return['bugs'][0])
    try:
        bug.status = "foo"
        assert 1 == 0, "Should have thrown an error about invalid type"
    except BugException as e:
        assert str(e) == "Message: Invalid status type was used"
Example #3
0
def test_we_cant_set_the_resolution_when_not_valid():
    bug = Bug(**example_return['bugs'][0])
    try:
        bug.resolution = 'FOO'
        assert 1 == 0, "Should thrown an error"
    except BugException as e:
        assert str(e) == "Message: Invalid resolution type was used Code: None"
Example #4
0
def test_we_can_update_a_bug_with_login_token(bug_return):
    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(bug_return),
                  status=200,
                  content_type='application/json',
                  match_querystring=True)
    bugzilla = Bugsy()
    bug = bugzilla.get(1017315)
    responses.reset()
    responses.add(responses.GET,
                  'https://bugzilla.mozilla.org/rest/bug/1017315',
                  body=json.dumps(bug_return),
                  status=200,
                  content_type='application/json')
    clone = Bug(bugsy=bugzilla, **bug.to_dict())
    clone.status = 'NEW'
    clone.update()
    assert clone.id == 1017315
    assert clone.status == 'RESOLVED'
Example #5
0
def test_we_cant_set_the_resolution_when_not_valid():
    bug = Bug(**example_return['bugs'][0])
    try:
        bug.resolution = 'FOO'
        assert 1==0, "Should thrown an error"
    except BugException as e:
        assert str(e) == "Message: Invalid resolution type was used"
Example #6
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 == "*****@*****.**"
Example #7
0
def test_we_can_add_multiple_emails_to_cc_list(bug_return):
    bug = Bug(**bug_return['bugs'][0])
    bug.cc.extend(['*****@*****.**', '*****@*****.**'])
    output = bug.diff()
    assert isinstance(output, dict)
    assert sorted(output['cc']['add']) == sorted(
        ['*****@*****.**', '*****@*****.**'])
Example #8
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'
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)
Example #10
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'
Example #11
0
def test_we_throw_an_error_for_invalid_status_types():
    bug = Bug(**example_return['bugs'][0])
    try:
        bug.status = "foo"
        assert 1 == 0, "Should have thrown an error about invalid type"
    except BugException as e:
        assert str(e) == "Message: Invalid status type was used Code: None"
Example #12
0
def test_we_can_add_remove_a_keyword_list(bug_return):
    bug = Bug(**bug_return['bugs'][0])
    bug.keywords.remove('regression')
    output = bug.diff()
    assert isinstance(output, dict)
    assert output == {'keywords': {'remove': ['regression']}}
    keywords = bug.keywords
    assert [] == keywords
Example #13
0
def test_we_cant_set_status_unless_there_is_a_bug_id():
    bug = Bug()
    try:
        bug.status = 'RESOLVED'
    except BugException as e:
        assert str(
            e
        ) == "Message: Can not set status unless there is a bug id. Please call Update() before setting Code: None"
Example #14
0
def test_we_cant_update_unless_we_have_a_bug_id():
    bug = Bug()
    try:
        bug.update()
    except BugException as e:
        assert str(
            e
        ) == "Message: Unable to update bug that isn't in Bugzilla Code: None"
def test_we_cant_set_status_unless_there_is_a_bug_id():
    bug = Bug()
    try:
        bug.status = "RESOLVED"
    except BugException as e:
        assert (
            str(e)
            == "Message: Can not set status unless there is a bug id. Please call Update() before setting Code: None"
        )
Example #16
0
def test_we_can_add_and_remove_depends_on(bug_return):
    bug = Bug(**bug_return['bugs'][0])
    bug.depends_on.remove(123456)
    bug.depends_on.append(145123)
    output = bug.diff()
    assert isinstance(output, dict)
    assert output == {'depends_on': {'add': [145123], 'remove': [123456]}}
    deps = bug.depends_on
    assert isinstance(deps, list)
    assert [145123] == deps
Example #17
0
def test_we_can_add_and_remove_blocks(bug_return):
    bug = Bug(**bug_return['bugs'][0])
    bug.blocks.remove(654321)
    bug.blocks.append(145123)
    output = bug.diff()
    assert isinstance(output, dict)
    assert output == {'blocks': {'add': [145123], 'remove': [654321]}}
    deps = bug.blocks
    assert isinstance(deps, list)
    assert [145123] == deps
Example #18
0
def test_we_can_add_multiple_keywords_to_list(bug_return):
    bug = Bug(**bug_return['bugs'][0])
    bug.keywords.extend(['intermittent', 'ateam-marionette-server'])
    output = bug.diff()
    assert isinstance(output, dict)
    assert sorted(output['keywords']['add']) == sorted(
        ['intermittent', 'ateam-marionette-server'])
    keywords = bug.keywords
    assert sorted(['regression', 'intermittent',
                   'ateam-marionette-server']) == sorted(keywords)
Example #19
0
def test_we_cant_add_attachment_without_id(attachment_return):
    bug = Bug()
    attachment = Attachment(None, **attachment_return['bugs']['1017315'][0])

    try:
        bug.add_attachment(attachment)
    except BugException as e:
        assert str(
            e
        ) == "Message: Cannot add an attachment without a bug id Code: None"
Example #20
0
def test_we_can_add_remove_an_email_to_cc_list(bug_return):
    bug = Bug(**bug_return['bugs'][0])
    bug.cc.append('*****@*****.**')
    bug.cc.remove('*****@*****.**')
    output = bug.diff()
    assert isinstance(output, dict)
    assert output == {
        'cc': {
            'add': ['*****@*****.**'],
            'remove': ['*****@*****.**']
        }
    }
Example #21
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
Example #23
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'
Example #24
0
def test_we_can_get_get_cc_list():
    bug = Bug(**example_return['bugs'][0])
    cced = bug.cc
    assert isinstance(cced, list)
    assert [
        u"*****@*****.**", u"*****@*****.**", u"*****@*****.**",
        u"*****@*****.**"
    ] == cced
Example #25
0
def test_we_can_get_get_cc_list(bug_return):
    bug = Bug(**bug_return['bugs'][0])
    cced = bug.cc
    assert isinstance(cced, list)
    assert [
        '*****@*****.**', '*****@*****.**', '*****@*****.**',
        '*****@*****.**'
    ] == cced
Example #26
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 == "*****@*****.**"
Example #27
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'
Example #28
0
def test_bug_update_updates_copy_dict(bug_return, comments_return):
    responses.add(responses.GET,
                  'https://bugzilla.mozilla.org/rest/login',
                  body='{"token": "foobar"}',
                  status=200,
                  content_type='application/json',
                  match_querystring=True)
    bugzilla = Bugsy("foo", "bar")
    bug = Bug(bugzilla, **bug_return['bugs'][0])

    bug.status = 'NEW'
    diff = bug.diff()
    bug_dict = copy.deepcopy(bug_return)
    bug_dict['bugs'][0]['status'] = 'NEW'
    responses.add(responses.GET,
                  'https://bugzilla.mozilla.org/rest/bug/1017315',
                  body=json.dumps(bug_dict),
                  status=200,
                  content_type='application/json')

    responses.add(responses.PUT,
                  'https://bugzilla.mozilla.org/rest/bug/1017315',
                  body=json.dumps(diff),
                  status=200,
                  content_type='application/json')

    bugzilla.put(bug)
    bug.update()
    assert bug._copy['status'] == 'NEW'
Example #29
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_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=400,
                    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. Code: 50"
def test_we_handle_errors_from_bugzilla_when_updating_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.PUT, 'https://bugzilla.mozilla.org/rest/bug/1017315',
                    body='{"error":true,"code":50,"message":"You must select/enter a component."}', status=400,
                    content_type='application/json')
  bugzilla = Bugsy("foo", "bar")

  bug_dict = example_return.copy()
  bug_dict['summary'] = 'I love foo but hate bar'
  bug = Bug(**bug_dict['bugs'][0])
  try:
      bugzilla.put(bug)
  except BugsyException as e:
      assert str(e) == "Message: You must select/enter a component. Code: 50"
Example #32
0
def test_we_cant_update_unless_we_have_a_bug_id():
    bug = Bug()
    try:
        bug.update()
    except BugException as e:
        assert str(e) == "Message: Unable to update bug that isn't in Bugzilla"
def test_we_can_get_a_dict_version_of_the_bug():
    bug = Bug(**example_return["bugs"][0])
    result = bug.to_dict()
    assert example_return["bugs"][0]["id"] == result["id"]
Example #34
0
def test_we_can_get_blocks_list():
    bug = Bug(**example_return['bugs'][0])
    blocks = bug.blocks
    assert isinstance(blocks, list)
    assert blocks == [654321]
Example #35
0
def test_we_can_get_depends_on_list():
    bug = Bug(**example_return['bugs'][0])
    depends_on = bug.depends_on
    assert isinstance(depends_on, list)
    assert depends_on == [123456]
Example #36
0
def test_we_can_get_a_dict_version_of_the_bug():
    bug = Bug(**example_return['bugs'][0])
    result = bug.to_dict()
    assert example_return['bugs'][0]['id'] == result['id']
Example #37
0
def test_we_can_pass_in_dict_and_get_a_bug():
    bug = Bug(**example_return['bugs'][0])
    assert bug.id == 1017315
    assert bug.status == 'RESOLVED'
    assert bug.summary == 'Schedule Mn tests on opt Linux builds on cedar'
    assert bug.assigned_to == "*****@*****.**"
Example #38
0
def test_we_can_set_the_resolution():
    bug = Bug(**example_return['bugs'][0])
    bug.resolution = 'INVALID'
    assert bug.resolution == 'INVALID'
Example #39
0
def test_we_can_get_the_resolution():
    bug = Bug(**example_return['bugs'][0])
    assert "FIXED" == bug.resolution
def test_we_can_set_the_resolution():
    bug = Bug(**example_return["bugs"][0])
    bug.resolution = "INVALID"
    assert bug.resolution == "INVALID"
Example #41
0
def test_we_can_get_Product_we_set():
    bug = Bug(product="firefox")
    assert bug.product == "firefox"
Example #42
0
def test_we_can_set_the_resolution():
    bug = Bug(**example_return['bugs'][0])
    bug.resolution = 'INVALID'
    assert bug.resolution == 'INVALID'
Example #43
0
def test_we_can_get_a_dict_version_of_the_bug():
    bug = Bug(**example_return['bugs'][0])
    result = bug.to_dict()
    assert example_return['bugs'][0]['id'] == result['id']