def test_enable_epics():
    az = AzDevOps(org='foo', token='bar')
    az._get_team = MagicMock(
        return_value=SimpleNamespace(id=1, project_id=1, name='foo'))
    project = SimpleNamespace(id=1)

    az._enable_epics(project, 'foo')

    assert az.clients.get_work_client.return_value.update_team_settings.called_with(
        {
            "backlogVisibilities": {
                "Microsoft.EpicCategory": 'true',
                "Microsoft.FeatureCategory": 'true',
                "Microsoft.RequirementCategory": 'true'
            }
        }, SimpleNamespace(team_id=1, project_id=1))
def test_deploy(fs):
    MockedFiles._mockCorrectFileSystem(fs)

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

    az = AzDevOps(org='foo', token='bar')
    az._create_project = MagicMock(return_value=mock_return_None)
    az._get_project = MagicMock(return_value=SimpleNamespace(id=1))
    az._enable_epics = MagicMock(return_value=mock_return_None)
    az._create_work_item = MagicMock(return_value=mock_return_None)

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

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

    az.deploy(args, work_items)

    az._create_project.assert_called_with('testProject')
    az._enable_epics.assert_called()

    assert az._create_work_item.call_count == 20
def test_deploy(fs):
    MockedFiles._mock_correct_file_system(fs)

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

    az = AzDevOps(org='foo', token='bar')
    az._create_project = MagicMock(return_value=mock_return_None)
    az._get_project = MagicMock(return_value=SimpleNamespace(id=1))
    az._enable_epics = MagicMock(return_value=mock_return_None)
    az._create_work_item = MagicMock(return_value=mock_return_None)

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

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

    az.deploy(args, work_items, config, [])

    az._create_project.assert_called_with('testProject', 'Sample description')
    az._enable_epics.assert_called()

    assert az._create_work_item.call_count == 20