def test_createIssue(mockGithub):
    gh = GitHub(token='foo')
    gh.github = mockGithub
    repo = gh._getUser().create_repo()
    gh._createIssue(repo, 'testMilestone', 'testTitle', 'testBody', [])

    repo.create_issue.assert_called_with('testTitle', body='testBody', milestone='testMilestone', labels=[])
def test_createCard(mockGithub):
    gh = GitHub(token='foo')
    gh.github = mockGithub
    repo = gh._getUser().create_repo()
    project = gh._createProject(repo, 'testOrg', 'testBody')
    column = gh._createColumn(project, 'test')
    issue = gh._createIssue(repo, 'testMilestone', 'testTitle', 'testBody', [])
    gh._createCard(column, issue)

    column.create_card.assert_called_with(content_id=issue.id, content_type="Issue")
def test_deploy_withRepo(fs):
    MockedFiles._mockCorrectFileSystem(fs)

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

    gh = GitHub(token='foo')
    gh._createOrgRepo = MagicMock(return_value=mock_returnNone)
    gh._createUserRepo = MagicMock(return_value=mock_returnNone)
    gh._deleteLabels = MagicMock(return_value=mock_returnNone)
    gh._createProject = MagicMock(return_value=mock_returnNone)
    gh._createColumns = MagicMock(return_value=mock_returnNone)
    gh._createMilestone = MagicMock(return_value=mock_returnNone)
    gh._createIssue = MagicMock(return_value=mock_returnNone)
    gh._createCard = MagicMock(return_value=mock_returnNone)
    gh._buildDescription = MagicMock(return_value=mock_returnNone)

    backlog = Backlog()
    config = backlog._getConfig('workitems/correct')
    workItems = backlog._buildWorkItems(MockedFiles._mockParsedFileList(), config)

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

    gh.deploy(args, workItems)
    gh._createUserRepo.assert_called_with('testProject')

    gh._deleteLabels.assert_called()
    assert gh._createProject.call_count == 4
    assert gh._createColumns.call_count == 4
    assert gh._createMilestone.call_count == 6
    assert gh._createIssue.call_count == 4
    assert gh._createCard.call_count == 4