azure-devops-python-api icon indicating copy to clipboard operation
azure-devops-python-api copied to clipboard

Get test cases appears to return None

Open ctrickler opened this issue 8 years ago • 8 comments

Using test client and the get test cases function, see sample code below. I am always getting None, yet if I manually create the URL with the ids, it appears I get valid results.

        credentials = BasicAuthentication(TEST_TOKEN_USER, TEST_TOKEN_VALUE)
        connection = VssConnection(base_url=TEST_SITE, creds=credentials)
        test_client = connection.get_client('vsts.test.v4_1.test_client.TestClient')

        plans = test_client.get_plans(TEST_PROJECT)
        for plan in plans:
            print(plan.id, plan.name)
            plancounts[plan.name] = 0
            suites = test_client.get_test_suites_for_plan(TEST_PROJECT, plan.id)
            for suite in suites:
                print("\t" + suite.name)
                cases = test_client.get_test_cases(suite.project.id, plan.id, suite.id)

ctrickler avatar Jun 07 '18 15:06 ctrickler

@ctrickler thanks for reporting. Can you turn on debug logging and let us know the request url and the response after scrubbing any private data?

import logging

logging.basicConfig(level=logging.DEBUG)

Thanks, Ted

tedchamb avatar Jun 07 '18 15:06 tedchamb

Think I figured out the issue, here is my log DEBUG:root:Loading cache file: C:\Users\cxt01.vsts\python-sdk\cache\resources.json DEBUG:root:attempting to read file C:\Users\cxt01.vsts\python-sdk\cache\resources.json as utf-8-sig DEBUG:root:File cache hit for resources on: https://REDACTED.visualstudio.com DEBUG:root:Loading cache file: C:\Users\cxt01.vsts\python-sdk\cache\options.json DEBUG:root:attempting to read file C:\Users\cxt01.vsts\python-sdk\cache\options.json as utf-8-sig DEBUG:root:File cache hit for options on: https://REDACTED.visualstudio.com DEBUG:root:Route template: {project}/_apis/test/Plans/{planId}/{resource}/{suiteId}/{action}/{testCaseIds} DEBUG:root:Api version '4.1' DEBUG:root:GET https://REDACTED.visualstudio.com/MYPROJECT/_apis/test/Plans/88620/Suites/88883 DEBUG:root:Request content: None DEBUG:msrest.pipeline:Configuring request: timeout=100, verify=True, cert=None DEBUG:msrest.pipeline:Configuring proxies: '' DEBUG:msrest.pipeline:Evaluate proxies against ENV settings: True DEBUG:msrest.pipeline:Configuring redirects: allow=True, max=30 DEBUG:msrest.pipeline:Configuring retry: max_retries=3, backoff_factor=0.8, max_backoff=90 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): REDACTED.visualstudio.com DEBUG:urllib3.connectionpool:https://REDACTED.visualstudio.com:443 "GET /MYPROJECT/_apis/test/Plans/88620/Suites/88883 HTTP/1.1" 200 809 DEBUG:root:Response content: {"id":88883,"name":"Scripting","url":"https://REDACTED.visualstudio.com/MYPROJECT/_apis/test/Plans/88620/Suites/88883","project":{"id":"8e8c49cb-d367-454b-9dd2-f55066597518","name":"REDACTED","url":"https://REDACTED.visualstudio.com/_apis/projects/MYPROJECT"},"plan":{"id":"88620","name":"Fresco Test Plan","url":"https://REDACTED.visualstudio.com/MYPROJECT/_apis/test/Plans/88620"},"parent":{"id":"88669","name":"Fresco Platform","url":"https://REDACTED.visualstudio.com/MYPROJECT/_apis/test/Plans/88620/Suites/88669"},"revision":10,"testCaseCount":66,"suiteType":"StaticTestSuite","testCasesUrl":"https://REDACTED.visualstudio.com/MYPROJECT/_apis/test/Plans/88620/Suites/88883/testcases","inheritDefaultConfigurations":true,"state":"In Progress","lastUpdatedBy":{"displayName":"Christopher Trickler","url":"https://app.vssps.visualstudio.com/A849c1808-a0cc-4df8-9c30-5c6daec4116c/_apis/Identities/c514914a-e30c-4b86-834c-4d95ac4a3a18","_links":{"avatar":{"href":"https://REDACTED.visualstudio.com/_apis/GraphProfile/MemberAvatars/aad.YmZhYTE3ZTQtNjYxZS03NzI0LWE1MDYtZDAxZDQyYjZkYzAw"}},"id":"c514914a-e30c-4b86-834c-4d95ac4a3a18","uniqueName":"EMAIL","imageUrl":"https://REDACTED.visualstudio.com/_api/_common/identityImage?id=c514914a-e30c-4b86-834c-4d95ac4a3a18","descriptor":"aad.YmZhYTE3ZTQtNjYxZS03NzI0LWE1MDYtZDAxZDQyYjZkYzAw"},"lastUpdatedDate":"2018-02-28T16:32:48.743Z"}

Append /testcases to end of URL request GET https://REDACTED.visualstudio.com/MYPROJECT/_apis/test/Plans/88620/Suites/88883/testcases

From: Ted Chambers [mailto:[email protected]] Sent: Thursday, June 7, 2018 11:49 AM To: Microsoft/vsts-python-api [email protected] Cc: Trickler, Christopher [email protected]; Mention [email protected] Subject: Re: [Microsoft/vsts-python-api] Get test cases appears to return None (#75)

@ctricklerhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_ctrickler&d=DwMCaQ&c=tvvHx3uC0XdtgG-ImPDjfM0QnakIsmmGcwejQDVxD-g&r=Se7wyvMdygE9Arvn5HBgLQQCGKEhAzqCyLBAde9rlYf-mqRt12gIDzMXrjnGlxpR&m=om4rPzQvJLKNRZabibx6zB8f-0UGDhW7nhzlkiqNhb4&s=g0XjwnMyBLYXWDyAvcIiZPibn7ahwjYSfmZiSqi6dFk&e= thanks for reporting. Can you turn on debug logging and let us know the request url and the response after scrubbing any private data?

import logging

logging.basicConfig(level=logging.DEBUG)

Thanks, Ted

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_Microsoft_vsts-2Dpython-2Dapi_issues_75-23issuecomment-2D395470609&d=DwMCaQ&c=tvvHx3uC0XdtgG-ImPDjfM0QnakIsmmGcwejQDVxD-g&r=Se7wyvMdygE9Arvn5HBgLQQCGKEhAzqCyLBAde9rlYf-mqRt12gIDzMXrjnGlxpR&m=om4rPzQvJLKNRZabibx6zB8f-0UGDhW7nhzlkiqNhb4&s=NTronKGJwdL4a8TM50Kszw5g-zeaFs0ttyVNjlde4Pw&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AmLfISkTscknOOrtZbPEhm003vCrTVNzks5t6UtngaJpZM4Uen8D&d=DwMCaQ&c=tvvHx3uC0XdtgG-ImPDjfM0QnakIsmmGcwejQDVxD-g&r=Se7wyvMdygE9Arvn5HBgLQQCGKEhAzqCyLBAde9rlYf-mqRt12gIDzMXrjnGlxpR&m=om4rPzQvJLKNRZabibx6zB8f-0UGDhW7nhzlkiqNhb4&s=jKhywNzxxS9VwuBnn5LoiYjHUCG_f_RpoEnvkJll7Ws&e=.

ctrickler avatar Jun 07 '18 20:06 ctrickler

@ctrickler thank you, the info you provided was helpful. I am working on the fix.

tedchamb avatar Jun 08 '18 17:06 tedchamb

Fixed with #76, #77

tedchamb avatar Jun 08 '18 21:06 tedchamb

@ctrickler Thanks again for reporting this issue. The fix is now ready on pypi.

https://github.com/Microsoft/vsts-python-api/releases/tag/0.1.8

tedchamb avatar Jun 08 '18 22:06 tedchamb

Looks like the test cases are now being retrieved, but the data structure does not populate the test case name, from field System.Title I think is the underlying data returned.

Should I file a new bug or continue on this thread?

From: Ted Chambers [mailto:[email protected]] Sent: Friday, June 8, 2018 6:27 PM To: Microsoft/vsts-python-api [email protected] Cc: Trickler, Christopher [email protected]; Mention [email protected] Subject: Re: [Microsoft/vsts-python-api] Get test cases appears to return None (#75)

@ctricklerhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_ctrickler&d=DwMCaQ&c=tvvHx3uC0XdtgG-ImPDjfM0QnakIsmmGcwejQDVxD-g&r=Se7wyvMdygE9Arvn5HBgLQQCGKEhAzqCyLBAde9rlYf-mqRt12gIDzMXrjnGlxpR&m=4-ibq63-3RNa7-DkbWkK5efblwqrFcR3WF_7TT9V_vk&s=7U2tlHFu2gXm0f4uw70caq7ZltPfir4LiMTyQfuG3tQ&e= Thanks again for reporting this issue. The fix is no ready on pypi.

https://github.com/Microsoft/vsts-python-api/releases/tag/0.1.8https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_Microsoft_vsts-2Dpython-2Dapi_releases_tag_0.1.8&d=DwMCaQ&c=tvvHx3uC0XdtgG-ImPDjfM0QnakIsmmGcwejQDVxD-g&r=Se7wyvMdygE9Arvn5HBgLQQCGKEhAzqCyLBAde9rlYf-mqRt12gIDzMXrjnGlxpR&m=4-ibq63-3RNa7-DkbWkK5efblwqrFcR3WF_7TT9V_vk&s=V3HUVy97Arighzw78qFgk17xKGJhztE55sEGgkt5ufI&e=

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_Microsoft_vsts-2Dpython-2Dapi_issues_75-23issuecomment-2D395908971&d=DwMCaQ&c=tvvHx3uC0XdtgG-ImPDjfM0QnakIsmmGcwejQDVxD-g&r=Se7wyvMdygE9Arvn5HBgLQQCGKEhAzqCyLBAde9rlYf-mqRt12gIDzMXrjnGlxpR&m=4-ibq63-3RNa7-DkbWkK5efblwqrFcR3WF_7TT9V_vk&s=1llbvgcPQb7UtBiz8-ETWhXWBshz7L-JYR8CqQ3w9GI&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AmLfIfV81UUXF59efBNerq-2Db0G8PH37Jks5t6vpIgaJpZM4Uen8D&d=DwMCaQ&c=tvvHx3uC0XdtgG-ImPDjfM0QnakIsmmGcwejQDVxD-g&r=Se7wyvMdygE9Arvn5HBgLQQCGKEhAzqCyLBAde9rlYf-mqRt12gIDzMXrjnGlxpR&m=4-ibq63-3RNa7-DkbWkK5efblwqrFcR3WF_7TT9V_vk&s=V5qTPMyWXrL63y3mnMcpJUiLNUQEVI8wHs2TT2kwZXw&e=.

ctrickler avatar Jun 11 '18 11:06 ctrickler

Also, not sure if it is supposed to build out the other properties of the test, but one in particular I am interested in is ‘Microsoft.VSTS.TCM.AutomationStatus’

Such that the query can be used to get the automation status of the test cases.

From: Ted Chambers [mailto:[email protected]] Sent: Friday, June 8, 2018 6:27 PM To: Microsoft/vsts-python-api [email protected] Cc: Trickler, Christopher [email protected]; Mention [email protected] Subject: Re: [Microsoft/vsts-python-api] Get test cases appears to return None (#75)

@ctricklerhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_ctrickler&d=DwMCaQ&c=tvvHx3uC0XdtgG-ImPDjfM0QnakIsmmGcwejQDVxD-g&r=Se7wyvMdygE9Arvn5HBgLQQCGKEhAzqCyLBAde9rlYf-mqRt12gIDzMXrjnGlxpR&m=4-ibq63-3RNa7-DkbWkK5efblwqrFcR3WF_7TT9V_vk&s=7U2tlHFu2gXm0f4uw70caq7ZltPfir4LiMTyQfuG3tQ&e= Thanks again for reporting this issue. The fix is no ready on pypi.

https://github.com/Microsoft/vsts-python-api/releases/tag/0.1.8https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_Microsoft_vsts-2Dpython-2Dapi_releases_tag_0.1.8&d=DwMCaQ&c=tvvHx3uC0XdtgG-ImPDjfM0QnakIsmmGcwejQDVxD-g&r=Se7wyvMdygE9Arvn5HBgLQQCGKEhAzqCyLBAde9rlYf-mqRt12gIDzMXrjnGlxpR&m=4-ibq63-3RNa7-DkbWkK5efblwqrFcR3WF_7TT9V_vk&s=V3HUVy97Arighzw78qFgk17xKGJhztE55sEGgkt5ufI&e=

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_Microsoft_vsts-2Dpython-2Dapi_issues_75-23issuecomment-2D395908971&d=DwMCaQ&c=tvvHx3uC0XdtgG-ImPDjfM0QnakIsmmGcwejQDVxD-g&r=Se7wyvMdygE9Arvn5HBgLQQCGKEhAzqCyLBAde9rlYf-mqRt12gIDzMXrjnGlxpR&m=4-ibq63-3RNa7-DkbWkK5efblwqrFcR3WF_7TT9V_vk&s=1llbvgcPQb7UtBiz8-ETWhXWBshz7L-JYR8CqQ3w9GI&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AmLfIfV81UUXF59efBNerq-2Db0G8PH37Jks5t6vpIgaJpZM4Uen8D&d=DwMCaQ&c=tvvHx3uC0XdtgG-ImPDjfM0QnakIsmmGcwejQDVxD-g&r=Se7wyvMdygE9Arvn5HBgLQQCGKEhAzqCyLBAde9rlYf-mqRt12gIDzMXrjnGlxpR&m=4-ibq63-3RNa7-DkbWkK5efblwqrFcR3WF_7TT9V_vk&s=V5qTPMyWXrL63y3mnMcpJUiLNUQEVI8wHs2TT2kwZXw&e=.

ctrickler avatar Jun 11 '18 11:06 ctrickler

@ctrickler This python library is a thin wrapper around the VSTS REST APIs. You can find more information about how the APIs work in our REST documentation found here: https://docs.microsoft.com/en-us/rest/api/vsts/?view=vsts-rest-4.1

Information on the get_test_cases api mentioned above can be found here: https://docs.microsoft.com/en-us/rest/api/vsts/test/test%20%20suites/get%20test%20cases?view=vsts-rest-5.0

I am not an expert on the Test APIs, but it looks to me like there is a work item reference returned from the API in the testCase property. You should be able to use the testCase.id property along with the work item tracking client, to get details on that work item. See here: https://docs.microsoft.com/en-us/rest/api/vsts/wit/work%20items/get%20work%20item?view=vsts-rest-4.1

With the get_work_item api, you can specify which fields you would like returned by specifying them in the fields query parameter.

If you have other questions about the APIs themselves, you can ask them in the feedback section on the REST API Documentation site, and those questions will get routed to the appropriate team. You will find the feedback section at the bottom of the resource page, which is the parent page (see TOC on left) of the endpoint page.

I hope this helps, Ted

tedchamb avatar Jun 11 '18 15:06 tedchamb