def test_all_prs_get_labels(): cp = run_ok(f'--config-labels "{config("labels.abc.cfg")}" ' f'--config-auth "{auth}" ' f'--state all ' f'{user}/filabel-testrepo4') assert '\n' + cp.stdout == f''' REPO {user}/filabel-testrepo4 - OK PR https://github.com/{user}/filabel-testrepo4/pull/3 - OK + ab + abc PR https://github.com/{user}/filabel-testrepo4/pull/2 - OK + a + ab + abc PR https://github.com/{user}/filabel-testrepo4/pull/1 - OK + a + ab + abc ''' assert pr_labels('filabel-testrepo4', 1) == ['a', 'ab', 'abc'] assert pr_labels('filabel-testrepo4', 2) == ['a', 'ab', 'abc'] assert pr_labels('filabel-testrepo4', 3) == ['ab', 'abc'] # should erase lables, courtesy run(f'--config-labels "{config("labels.eraser.cfg")}" ' f'--config-auth "{auth}" ' f'--state all ' f'{user}/filabel-testrepo4')
def test_radioactive_waste_remove(): cp = run_ok(f'--config-labels "{config("labels.radiation_off.cfg")}" ' f'--config-auth "{auth}" ' f'{user}/filabel-testrepo2') assert '\n' + cp.stdout == f''' REPO {user}/filabel-testrepo2 - OK {RADIOACTIVE_WASE_DEL}''' assert pr_labels('filabel-testrepo2', 8) == [] assert pr_labels('filabel-testrepo2', 69) == [] assert pr_labels('filabel-testrepo2', 109) == []
def test_radioactive_waste_add(): cp = run_ok(f'--config-labels "{config("labels.radiation.cfg")}" ' f'--config-auth "{auth}" ' f'{user}/filabel-testrepo2') assert '\n' + cp.stdout == f''' REPO {user}/filabel-testrepo2 - OK {RADIOACTIVE_WASE_ADD}''' assert pr_labels('filabel-testrepo2', 2) == ['danger'] assert pr_labels('filabel-testrepo2', 55) == ['danger'] assert pr_labels('filabel-testrepo2', 103) == ['danger']
def test_radioactive_waste_empty(): cp = run_ok(f'--config-labels "{config("labels.empty.cfg")}" ' f'--config-auth "{auth}" ' f'{user}/filabel-testrepo2') assert '\n' + cp.stdout == f''' REPO {user}/filabel-testrepo2 - OK {RADIOACTIVE_WASE}''' assert pr_labels('filabel-testrepo2', 1) == [] assert pr_labels('filabel-testrepo2', 42) == [] assert pr_labels('filabel-testrepo2', 110) == []
def test_empty_labels_wont_remove(): cp = run_ok(f'--config-labels "{config("labels.empty.cfg")}" ' f'--config-auth "{auth}" ' f'{user}/filabel-testrepo1 {user}/filabel-testrepo3') assert '\n' + cp.stdout == f''' REPO {user}/filabel-testrepo1 - OK PR https://github.com/{user}/filabel-testrepo1/pull/2 - OK PR https://github.com/{user}/filabel-testrepo1/pull/1 - OK REPO {user}/filabel-testrepo3 - OK ''' assert pr_labels('filabel-testrepo1', 1) == ['a', 'ab', 'abc'] assert pr_labels('filabel-testrepo1', 2) == ['nine', 'ninenine']
def test_abc_labels_again(): cp = run_ok(f'--config-labels "{config("labels.abc.cfg")}" ' f'--config-auth "{auth}" ' f'{user}/filabel-testrepo1 {user}/filabel-testrepo3') assert '\n' + cp.stdout == f''' REPO {user}/filabel-testrepo1 - OK PR https://github.com/{user}/filabel-testrepo1/pull/2 - OK PR https://github.com/{user}/filabel-testrepo1/pull/1 - OK = a = ab = abc REPO {user}/filabel-testrepo3 - OK ''' assert pr_labels('filabel-testrepo1', 1) == ['a', 'ab', 'abc'] assert pr_labels('filabel-testrepo1', 2) == []
def test_empty_globs(): cp = run_ok(f'--config-labels "{config("labels.eraser.cfg")}" ' f'--config-auth "{auth}" ' f'{user}/filabel-testrepo1 {user}/filabel-testrepo3') assert '\n' + cp.stdout == f''' REPO {user}/filabel-testrepo1 - OK PR https://github.com/{user}/filabel-testrepo1/pull/2 - OK - eight - ninenine PR https://github.com/{user}/filabel-testrepo1/pull/1 - OK - a - abc - cd REPO {user}/filabel-testrepo3 - OK ''' assert pr_labels('filabel-testrepo1', 1) == [] assert pr_labels('filabel-testrepo1', 2) == []
def test_custom_base(): cp = run_ok(f'--config-labels "{config("labels.abc.cfg")}" ' f'--config-auth "{auth}" ' f'--base pr_open ' f'{user}/filabel-testrepo4') assert '\n' + cp.stdout == f''' REPO {user}/filabel-testrepo4 - OK PR https://github.com/{user}/filabel-testrepo4/pull/3 - OK + ab + abc ''' assert pr_labels('filabel-testrepo4', 2) == [] assert pr_labels('filabel-testrepo4', 3) == ['ab', 'abc'] # should erase lables, courtesy run(f'--config-labels "{config("labels.eraser.cfg")}" ' f'--config-auth "{auth}" ' f'{user}/filabel-testrepo4')
def test_diffs(): cp = run_ok(f'--config-labels "{config("labels.changer.cfg")}" ' f'--config-auth "{auth}" ' f'{user}/filabel-testrepo1 {user}/filabel-testrepo3 ' f'hroncok/non-exisitng-repo ') assert '\n' + cp.stdout == f''' REPO {user}/filabel-testrepo1 - OK PR https://github.com/{user}/filabel-testrepo1/pull/2 - OK + eight - nine PR https://github.com/{user}/filabel-testrepo1/pull/1 - OK = a - ab = abc + cd REPO {user}/filabel-testrepo3 - OK REPO hroncok/non-exisitng-repo - FAIL ''' assert pr_labels('filabel-testrepo1', 1) == ['a', 'abc', 'cd'] assert pr_labels('filabel-testrepo1', 2) == ['eight', 'ninenine']