Skip to content

Instantly share code, notes, and snippets.

@saga
Created April 9, 2013 15:56
Show Gist options
  • Save saga/5346913 to your computer and use it in GitHub Desktop.
Save saga/5346913 to your computer and use it in GitHub Desktop.
Downloading test files and attachments
Public Sub TestFilesAndAttachments(theTest As TDAPIOLELib.Test)
' This routine gets a test object and
' first downloads the script files and then the attachments.
' The debug outputs are based on test:
' "OTA_DEMO_SUBJECT\OTA_SUBJECT_level1\OTA_SUB_1.2\SimpleVAPI-XP"
Dim TestAttachFact As AttachmentFactory
Dim attachList As List, TAttach As Attachment
Dim TestAttachStorage As IExtendedStorage
Dim TestStorage As IExtendedStorage
Dim TestDownLoadPath As String, AttachDownLoadPath$
Dim isFatalErr As Boolean
Dim OwnerType As String, OwnerKey As Variant
'---------------------------------------
' Get the test storage.
Dim NullList As List
Set TestStorage = theTest.ExtendedStorage
TestStorage.ClientPath = _
"d:\" & theTest.Name & "\testStorage"
'-------------------------------------------------------
' Use IExtendedStorage.LoadEx to get the test files.
TestDownLoadPath = _
TestStorage.LoadEx("", True, NullList, isFatalErr)
Debug.Print "Fatal error = " & CStr(isFatalErr)
'Fatal error = False
Debug.Print "The test download path: " & TestDownLoadPath
' The test download path: d:\SimpleVAPI-XP\testStorage
' For this test, the files downloaded by
' TestStorage.LoadEx are:
' script.vbs
' test.sr
'---------------------------------------
' Get the Attachments.
Set TestAttachFact = theTest.Attachments
TestAttachFact.FactoryProperties OwnerType, OwnerKey
Debug.Print "OwnerType = " & OwnerType & ", " _
& "OwnerKey = " & OwnerKey; ""
' OwnerType = TEST, OwnerKey = 98
'
'----------------------------
' Get the list of attachments and go through
' the list, downloading one at a time.
Set attachList = TestAttachFact.NewList("")
For Each TAttach In attachList
With TAttach
Debug.Print "----------------------------"
Debug.Print "Download attachment" & vbCrLf
Debug.Print "Before setting path"
Debug.Print "The attachment name: " & .Name
Debug.Print "The attachment server name: " & .ServerFileName
Debug.Print "The filename: " & .FileName
'
' Before setting path
' The attachment Name: TEST_98_SampleAttachment.txt
' The attachment server name: C:\Program Files\Mercury Interactive\Quality Center\repository\qc\Default\Steve_85_Doc\Attach\TEST_98_SampleAttachment.txt
' The filename: C:\DOCUME~1\steves\LOCALS~1\Temp\TD_80\423af35f\Attach\TEST98\TEST_98_SampleAttachment.txt
'----------------------------------------------------
' Use Attachment.AttachmentStorage to get the
' extended storage object.
Set TestAttachStorage = .AttachmentStorage
TestAttachStorage.ClientPath = _
"d:\" & theTest.Name & "\attachStorage"
'----------------------------------------------------
' Use Attachment.Load to download the attachment files.
TAttach.Load True, AttachDownLoadPath
' Note that the Attachment.FileName property changes as a result
' of setting the IExtendedStorage.ClientPath.
Debug.Print vbCrLf & "After download"
Debug.Print "Down load path: " & AttachDownLoadPath
Debug.Print "The filename: " & .FileName
' After download
' Down load path: d:\SimpleVAPI-XP\attachStorage
' The filename: d:\SimpleVAPI-XP\attachStorage\TEST_98_SampleAttachment.txt
End With
Next TAttach
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment