Exemplo n.º 1
0
def test_equals():
    url = 'https://github.com/NCAR/xdev-bot'
    data = {'note': 'https://github.com/NCAR/xdev-bot/issues/11111'}
    accept = 'application/vnd.github.inertia-preview+json'
    ghargs1 = GHArgs(url, data=data, accept=accept)
    ghargs2 = GHArgs(url, data=data, accept=accept)
    assert ghargs1 == ghargs2
Exemplo n.º 2
0
def test_get_move_card_ghargs():
    card = {
        'url': 'https://api.github.com/projects/columns/cards/18001901',
        'id': 18001901,
        'note': 'https://github.com/NCAR/xdev-bot-testing/issues/76',
        'column_url': 'https://api.github.com/projects/columns/4507386',
        'column_id': 4507386,
        'created_at': '2019-02-22T20:42:18Z',
        'updated_at': '2019-02-22T20:42:18Z',
        'creator': 'xdev-bot',
        'sender': 'xdev-bot',
        'column_name': 'to_do'
    }
    cards = CardDB(card, index='note')

    with open(os.path.join(PWD, 'payload_examples/issue_closed.json')) as f:
        payload = json.load(f)
    event = sansio.Event(payload, event="issues", delivery_id="12345")

    ghargs = GHArgs('/projects/columns/cards/18001901/moves',
                    data={
                        'position': 'top',
                        'column_id': 4_507_393
                    },
                    accept='application/vnd.github.inertia-preview+json')
    assert get_move_card_ghargs(event, column='done', database=cards) == ghargs
Exemplo n.º 3
0
def test_kwargs_without_accept():
    url = 'https://github.com/NCAR/xdev-bot'
    data = {'note': 'https://github.com/NCAR/xdev-bot/issues/11111'}
    ghargs = GHArgs(url, data=data)
    assert ghargs.url == url
    assert ghargs.data == data
    assert ghargs.kwargs == {'data': data}
Exemplo n.º 4
0
def test_func():
    url = 'https://github.com/NCAR/xdev-bot'
    data = {'note': 'https://github.com/NCAR/xdev-bot/issues/11111'}
    func = 'patch'
    ghargs = GHArgs(url, data=data, func=func)
    assert ghargs.url == url
    assert ghargs.data == data
    assert ghargs.func == func
Exemplo n.º 5
0
def test_init_set_accept():
    url = 'https://github.com/NCAR/xdev-bot'
    data = {'note': 'https://github.com/NCAR/xdev-bot/issues/11111'}
    accept = 'application/vnd.github.inertia-preview+json'
    ghargs = GHArgs(url, data=data, accept=accept)
    assert ghargs.url == url
    assert ghargs.data == data
    assert ghargs.accept == accept
Exemplo n.º 6
0
def test_get_create_card_ghargs():
    with open(os.path.join(PWD, 'payload_examples/issue_opened.json')) as f:
        payload = json.load(f)
    event = sansio.Event(payload, event="issues", delivery_id="12345")

    ghargs = GHArgs('/projects/columns/4507386/cards',
                    data={'note': payload['issue']['html_url']},
                    accept='application/vnd.github.inertia-preview+json')
    assert get_create_card_ghargs(event) == ghargs
Exemplo n.º 7
0
def test_get_move_card_not_found_ghargs():
    cards = CardDB(index='note')

    with open(os.path.join(PWD, 'payload_examples/issue_closed.json')) as f:
        payload = json.load(f)
    event = sansio.Event(payload, event="issues", delivery_id="12345")

    ghargs = GHArgs('/projects/columns/4507393/cards',
                    data={'note': payload['issue']['html_url']},
                    accept='application/vnd.github.inertia-preview+json')
    assert get_move_card_ghargs(event, column='done', database=cards) == ghargs
Exemplo n.º 8
0
def test_get_update_status_ghargs_not_found():
    cards = CardDB(index='note')

    with open(os.path.join(PWD,
                           'payload_examples/card_moved_to_done.json')) as f:
        payload = json.load(f)
    event = sansio.Event(payload, event="project_card", delivery_id="12345")

    ghargs = GHArgs(
        'https://api.github.com/repos/NCAR/xdev-bot-testing/issues/75',
        data={'state': 'closed'},
        func='patch')
    assert get_update_status_ghargs(event, database=cards) == ghargs
Exemplo n.º 9
0
def test_get_update_status_ghargs():
    card = {
        'note': 'https://github.com/NCAR/xdev-bot-testing/issues/11',
        'column_name': 'done'
    }
    cards = CardDB(card, index='note')

    with open(os.path.join(PWD,
                           'payload_examples/card_created_issue.json')) as f:
        payload = json.load(f)
    event = sansio.Event(payload, event="project_card", delivery_id="12345")

    ghargs = GHArgs(
        'https://api.github.com/repos/NCAR/xdev-bot-testing/issues/11',
        data={'state': 'open'},
        func='patch')
    assert get_update_status_ghargs(event, database=cards) == ghargs
Exemplo n.º 10
0
def test_get_update_status_ghargs_merged_pr():
    card = {
        'note': 'https://github.com/NCAR/xdev-bot-testing/pull/75',
        'column_name': 'done',
        'merged': True
    }
    cards = CardDB(card, index='note')

    with open(
            os.path.join(
                PWD, 'payload_examples/card_moved_to_in_progress.json')) as f:
        payload = json.load(f)
    event = sansio.Event(payload, event="project_card", delivery_id="12345")

    ghargs = GHArgs('/projects/columns/cards/18727793/moves',
                    data={
                        'position': 'top',
                        'column_id': 4_507_393
                    },
                    accept='application/vnd.github.inertia-preview+json')

    assert get_update_status_ghargs(event, database=cards) == ghargs
Exemplo n.º 11
0
def test_init_set_data():
    url = 'https://github.com/NCAR/xdev-bot'
    data = {'note': 'https://github.com/NCAR/xdev-bot/issues/11111'}
    ghargs = GHArgs(url, data=data)
    assert ghargs.url == url
    assert ghargs.data == data
Exemplo n.º 12
0
def test_equals_different_type():
    url = 'https://github.com/NCAR/xdev-bot'
    data = {'note': 'https://github.com/NCAR/xdev-bot/issues/11111'}
    accept = 'application/vnd.github.inertia-preview+json'
    ghargs = GHArgs(url, data=data, accept=accept)
    assert not (ghargs == 2)
Exemplo n.º 13
0
def test_init():
    url = 'https://github.com/NCAR/xdev-bot'
    ghargs = GHArgs(url)
    assert ghargs.url == url