コード例 #1
0
def test_matching_issue_filter():
    config = Configuration(os.path.join(MOCK_FOLDER_PATH, 'conf.ini'))
    config.load_properties()

    assert is_matching_issue(['test', 'bug'], config.must_have_labels,
                             config.cant_have_labels,
                             config.filter_labels) is True
    assert is_matching_issue(['not test', 'bug'], config.must_have_labels,
                             config.cant_have_labels,
                             config.filter_labels) is False
    assert is_matching_issue(['not test', 'test', 'bug'],
                             config.must_have_labels, config.cant_have_labels,
                             config.filter_labels) is False

    config.filter_labels = ['not bug']
    assert is_matching_issue(['bug', 'test'], config.must_have_labels,
                             config.cant_have_labels,
                             config.filter_labels) is False
    assert is_matching_issue(['not bug', 'test'], config.must_have_labels,
                             config.cant_have_labels,
                             config.filter_labels) is True

    config.must_have_labels = ['test||something']
    assert is_matching_issue(['not bug', 'test'], config.must_have_labels,
                             config.cant_have_labels,
                             config.filter_labels) is True
    assert is_matching_issue(['not bug', 'something'], config.must_have_labels,
                             config.cant_have_labels,
                             config.filter_labels) is True
    assert is_matching_issue(['not bug', 'else'], config.must_have_labels,
                             config.cant_have_labels,
                             config.filter_labels) is False
コード例 #2
0
def test_get_filters():
    config = Configuration(os.path.join(MOCK_FOLDER_PATH, 'conf.ini'))
    config.load_properties()

    filters = ProjectManager.get_filters(config)

    assert len(filters) == 1
    assert ' label:bug' in filters[0]
    assert ' label:test' in filters[0]
    assert '-label:not test' in filters[0]

    config.filter_labels = ['one', 'two']
    config.must_have_labels = ['three', 'four||five']
    config.cant_have_labels = ['six', 'seven']
    filters = ProjectManager.get_filters(config)

    assert len(filters) == 4
    for filter_str in filters:
        assert ('label:one' in filter_str and 'label:two'
                not in filter_str) or ('label:one' not in filter_str
                                       and 'label:two' in filter_str)
        assert ('label:four' in filter_str and 'label:five'
                not in filter_str) or ('label:four' not in filter_str
                                       and 'label:five' in filter_str)