Пример #1
0
def test_deploy_with_repo(fs):
    MockedFiles._mock_correct_file_system(fs)

    def mock_return_None(*args, **kwargs):
        return None

    gh = GitHub(token='foo')
    gh._create_org_repo = MagicMock(return_value=mock_return_None)
    gh._create_user_repo = MagicMock(return_value=mock_return_None)
    gh._initialize_repo = MagicMock(return_value=mock_return_None)
    gh._create_labels = MagicMock(return_value=mock_return_None)
    gh._delete_labels = MagicMock(return_value=mock_return_None)
    gh._create_project = MagicMock(return_value=mock_return_None)
    gh._create_columns = MagicMock(return_value=mock_return_None)
    gh._create_milestone = MagicMock(return_value=mock_return_None)
    gh._create_issue = MagicMock(return_value=mock_return_None)
    gh._create_card = MagicMock(return_value=mock_return_None)
    gh._build_description = MagicMock(return_value=mock_return_None)

    backlog = Backlog()
    config = backlog._get_config('workitems/correct', 'github')
    config["_repository_path"] = 'workitems/correct'
    work_items = backlog._build_work_items(
        MockedFiles._mock_parsed_file_list(), config)

    args = argparse.Namespace()
    args.org = None
    args.repo = 'testUser'
    args.project = 'testProject'
    args.backlog = 'correct'

    gh.deploy(args, work_items, config, [])
    gh._create_user_repo.assert_called_with('testProject',
                                            'Sample description')

    gh._delete_labels.assert_called()
    assert gh._create_project.call_count == 4
    assert gh._create_columns.call_count == 4
    assert gh._create_milestone.call_count == 6
    assert gh._create_issue.call_count == 4
    assert gh._create_card.call_count == 4
Пример #2
0
def test_build_description():
    gh = GitHub(token='foo')
    task1 = Task()
    task1.title = "Test 1"
    task1.description = "This is a description 1"

    task2 = Task()
    task2.title = "Test 2"
    task2.description = "This is a description 2"

    tasks = [task1, task2]
    desc = "This is a sample feature description"

    result = gh._build_description(desc, tasks)
    assert result == "This is a sample feature description" \
                     "\n" \
                     "\n- [ ] **Test 1**" \
                     "\n      This is a description 1" \
                     "\n" \
                     "\n- [ ] **Test 2**" \
                     "\n      This is a description 2"