def test_add_link(self):
        client = VstsClient(self.instance, self.personal_access_token)

        # Get a User Story
        query = "Select [System.Id], [System.Title], [System.State] From WorkItems Where [System.Title] = 'Test Story'"
        result = client.query(query, 'Contoso')
        userstory_id = result.rows[0]['id']

        # Get a Feature
        query = "Select [System.Id], [System.Title], [System.State] From WorkItems Where [System.Title] = 'Flying car'"
        result = client.query(query, 'Contoso')
        feature_id = result.rows[0]['id']

        # Link them together using a parent relationship
        client.add_link(userstory_id, feature_id, LinkTypes.PARENT,
                        "This is a comment")
示例#2
0
                if issue.epic.done:
                    doc.add(
                        JsonPatchOperation('add', SystemFields.STATE,
                                           State.RESOLVED))
                else:
                    doc.add(
                        JsonPatchOperation('add', SystemFields.STATE,
                                           State.ACTIVE))

                # Create the feature in Azure DevOps
                feature = vsts_client.create_workitem('Contoso', 'Feature',
                                                      doc)

            # Link the user story with feature (PARENT)
            vsts_client.add_link(workitem.id, feature.id, LinkTypes.PARENT)

        # Migrate attachments
        if len(issue.attachments) > 0:
            for attachment in issue.attachments:
                vsts_attachment = None

                # Download the attachment(s) from Jira
                with open('./tmp/{}'.format(attachment.filename), 'wb') as f:
                    f.write(
                        jira_client.download_attachment(
                            attachment.id, attachment.filename))

                # Upload the attachment(s) to VSTS
                with open('./tmp/{}'.format(attachment.filename), 'rb') as f:
                    vsts_attachment = vsts_client.upload_attachment(