示例#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
文件: test.py 项目: 18F/site-data
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
文件: test.py 项目: 18F/site-data
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
文件: test.py 项目: 18F/site-data
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
文件: test.py 项目: 18F/site-data
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
文件: test.py 项目: 18F/site-data
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
文件: test.py 项目: 18F/site-data
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
文件: test.py 项目: 18F/site-data
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
文件: test.py 项目: 18F/site-data
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
文件: test.py 项目: 18F/site-data
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