Пример #1
0
def test_GitHub_fetch_commits_request_not_ok(m):
    g = GitHub('18f.gsa.gov', '18F')
    endpoint = "commits"
    url = "%s/repos/%s/%s/%s" % (g.api, g.owner, g.repo, endpoint)
    m.get(url, json=[], status_code=404, headers={'Content-Type': 'text/html'})
    actual = g.fetch_commits()
    assert actual is False
Пример #2
0
def test_GitHub_fetch_endpoint_when_request_not_ok(m):
    g = GitHub('18f.gsa.gov', '18F')
    endpoint = "nonexistentendpoint"
    url = "%s/repos/%s/%s/%s" % (g.api, g.owner, g.repo, endpoint)
    m.get(url, text="", status_code=404, headers={'Content-Type': 'text/html'})
    actual = g.fetch_endpoint(endpoint)
    assert actual is False
Пример #3
0
def test_GitHub_fetch_commits_request_ok(m):
    g = GitHub('18f.gsa.gov', '18F')
    endpoint = "commits"
    url = "%s/repos/%s/%s/%s" % (g.api, g.owner, g.repo, endpoint)
    m.get(url, json=[{"name": "18f.gsa.gov"}], status_code=200)
    actual = g.fetch_commits()
    assert actual == [{'name': '18f.gsa.gov'}]
Пример #4
0
def test_GitHub_fetch_raw_when_request_not_ok(m):
    g = GitHub('18f.gsa.gov', '18F')
    request_string = "18F/18f.gsa.gov/staging/go.html"
    url = "https://raw.githubusercontent.com/18F/18f.gsa.gov/staging/go.html"
    m.get(url, status_code=418, text="I'm a teapot")
    actual = g.fetch_raw(request_string)
    assert actual is False
Пример #5
0
def test_GitHub_fetch_raw(m):
    g = GitHub('18f.gsa.gov', '18F')
    request_string = "18F/18f.gsa.gov/staging/go"
    url = "https://raw.githubusercontent.com/%s" % request_string
    m.get(url, text="Success!", status_code=200)
    actual = g.fetch_raw(request_string)
    assert actual.text == "Success!"
Пример #6
0
def test_GitHub_fetch_raw(m):
    g = GitHub('18f.gsa.gov', '18F')
    request_string = "18F/18f.gsa.gov/staging/go"
    url = "https://raw.githubusercontent.com/%s" % request_string
    m.get(url, text="Success!", status_code=200)
    actual = g.fetch_raw(request_string)
    assert actual.text == "Success!"
Пример #7
0
def test_GitHub_fetch_commits_request_ok(m):
    g = GitHub('18f.gsa.gov', '18F')
    endpoint = "commits"
    url = "%s/repos/%s/%s/%s" % (g.api, g.owner, g.repo, endpoint)
    m.get(url, json=[{"name": "18f.gsa.gov"}], status_code=200)
    actual = g.fetch_commits()
    assert actual == [{'name': '18f.gsa.gov'}]
Пример #8
0
def test_GitHub_parse_by_key():
    g = GitHub('', '')
    expected = ['data-pull', 'data-push']
    data = [{"name": "data-push"}, {"name": "data-pull"},
            {"name": "nondata-push"}]
    actual = g.parse_by_key(data, 'name', 'data')
    assert expected.sort() == actual.sort()
Пример #9
0
def test_GitHub_fetch_raw_when_request_not_ok(m):
    g = GitHub('18f.gsa.gov', '18F')
    request_string = "18F/18f.gsa.gov/staging/go.html"
    url = "https://raw.githubusercontent.com/18F/18f.gsa.gov/staging/go.html"
    m.get(url, status_code=418, text="I'm a teapot")
    actual = g.fetch_raw(request_string)
    assert actual is False
Пример #10
0
def test_GitHub_split_by_event():
    events = list()
    expected = list()
    events.append({'event': 'milestoned', 'name': 'Issue 0'})
    events.append({'event': 'closed', 'name': 'Issue 1'})
    expected.append(events[0])
    g = GitHub('18f.gsa.gov', '18F')
    actual = g.split_by_event(events, 'milestoned')
    assert actual == expected
Пример #11
0
def test_GitHub_split_by_event():
    events = list()
    expected = list()
    events.append({'event': 'milestoned', 'name': 'Issue 0'})
    events.append({'event': 'closed', 'name': 'Issue 1'})
    expected.append(events[0])
    g = GitHub('18f.gsa.gov', '18F')
    actual = g.split_by_event(events, 'milestoned')
    assert actual == expected
Пример #12
0
def test_GitHub_fetch_issues(m):
    g = GitHub('18f.gsa.gov', '18F')
    url = "%s/repos/%s/%s/issues?per_page=100" % (g.api, g.owner, g.repo)
    expected = [{"number": i} for i in range(100)]
    m.get(url,
          json=expected,
          status_code=200,
          headers={'Content-Type': 'application/json'})
    actual = g.fetch_issues()
    assert list(actual) == expected
Пример #13
0
def test_GitHub_fetch_commits_request_not_ok(m):
    g = GitHub('18f.gsa.gov', '18F')
    endpoint = "commits"
    url = "%s/repos/%s/%s/%s" % (g.api, g.owner, g.repo, endpoint)
    m.get(url,
          json=[],
          status_code=404,
          headers={'Content-Type': 'text/html'})
    actual = g.fetch_commits()
    assert actual is False
Пример #14
0
def test_GitHub_fetch_endpoint_when_request_not_ok(m):
    g = GitHub('18f.gsa.gov', '18F')
    endpoint = "nonexistentendpoint"
    url = "%s/repos/%s/%s/%s" % (g.api, g.owner, g.repo, endpoint)
    m.get(url,
          text="",
          status_code=404,
          headers={'Content-Type': 'text/html'})
    actual = g.fetch_endpoint(endpoint)
    assert actual is False
Пример #15
0
def test_GitHub_fetch_issues(m):
    g = GitHub('18f.gsa.gov', '18F')
    url = "%s/repos/%s/%s/issues?per_page=100" % (g.api, g.owner, g.repo)
    expected = [{"number": i} for i in range(100)]
    m.get(url,
          json=expected,
          status_code=200,
          headers={'Content-Type': 'application/json'})
    actual = g.fetch_issues()
    assert list(actual) == expected
Пример #16
0
def test_GitHub_parse_by_key():
    g = GitHub('', '')
    expected = ['data-pull', 'data-push']
    data = [{
        "name": "data-push"
    }, {
        "name": "data-pull"
    }, {
        "name": "nondata-push"
    }]
    actual = g.parse_by_key(data, 'name', 'data')
    assert expected.sort() == actual.sort()
Пример #17
0
def test_GitHub_fetch_issues_request_not_ok(m):
    g = GitHub('18f.gsa.gov', '18F')
    url = "%s/repos/%s/%s/issues" % (g.api, g.owner, g.repo)
    m.get(url, text="I'm a teapot", status_code=418)
    actual = g.fetch_issues()
    assert actual == False
Пример #18
0
def test_GitHub_fetch_issues_request_not_ok(m):
    g = GitHub('18f.gsa.gov', '18F')
    url = "%s/repos/%s/%s/issues" % (g.api, g.owner, g.repo)
    m.get(url, text="I'm a teapot", status_code=418)
    actual = g.fetch_issues()
    assert actual == False