def create_pr(arguments): client = AzureDevOpsInteractor(arguments.token) client.create_pull_request(arguments.project, arguments.repo, arguments.source, arguments.destination) print( f"Created PR successfully from {arguments.source} to {arguments.destination} for {arguments.project}/{arguments.repo}" )
def test_get_repo(): token = "" branch = "" repo = "" client = AzureDevOpsInteractor(token) with raises(azure.devops.exceptions.AzureDevOpsClientRequestError): test = client.get_repo(repo, branch) repo_name=test.name
def test_load_repo(): token = os.environ["AZDO_TOKEN"] branch = "" repo = "" project = "" client = AzureDevOpsInteractor(token) with raises(azure.devops.exceptions.AzureDevOpsClientRequestError): test = client.load_repo(project, repo)
def step_impl(context): project_name = "RunwayTest" repo_name = str(uuid.uuid4()) client = AzureDevOpsInteractor(os.environ["AZDO_TOKEN"]) repo = client.create_repo(project_name, repo_name) repo.create_branch('develop') context.client = client context.repo = repo
def test_create_thread(): dummy_token = "test-token" dummy_branch = "test-branch" dummy_repo = "test-repo" client = AzureDevOpsInteractor(dummy_token) client.pull_requests_for_repo = MagicMock() with patch.object(client, "create_thread", client.pull_requests_for_repo) as mock_create_thread: client.create_thread(dummy_repo, dummy_branch, "test-artifact-name", 1) mock_create_thread.assert_called_with("test-repo", "test-branch", "test-artifact-name", 1) return mock_create_thread
def create_thread(arguments): client = AzureDevOpsInteractor(arguments.token) pullrequest = client.load_pull_request(arguments.project, arguments.repo, arguments.source) if pullrequest is None: print("No Pull Request Found.") sys.exit(1) client.create_thread(arguments.repo, arguments.project, arguments.artifact, pullrequest["pull_request_id"]) print(f"Created Thread successfully for {pullrequest['title']}")
def mock_pull_request(title="RouteToLive: feature/Utopia to develop", source="feature/Utopia", destination="develop", description=AzureDevOpsInteractor.pr_description(), is_draft=True): return MagicMock(title=title, source_ref_name=source, target_ref_name=destination, description=description, is_draft=is_draft)
def test_invalid_token_fails(): with raises(azure.devops.exceptions.AzureDevOpsServiceError): client = AzureDevOpsInteractor('test-token') client.load_repo("", "")