Skip to content

Commit f5ffe1b

Browse files
committed
minor fix
1 parent ab44dd1 commit f5ffe1b

2 files changed

Lines changed: 76 additions & 15 deletions

File tree

Public/Videos/New-Video.ps1

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function New-Video {
99
[Parameter()]
1010
[ValidateNotNullOrEmpty()]
1111
[Alias('input_reference')]
12-
[string[]]$InputReference,
12+
[string]$InputReference,
1313

1414
[Parameter(ValueFromPipelineByPropertyName)]
1515
[Completions(
@@ -99,20 +99,8 @@ function New-Video {
9999
}
100100

101101
if ($PSBoundParameters.ContainsKey('InputReference')) {
102-
if ($ApiType -eq [OpenAIApiType]::Azure) {
103-
$PostBody.files = @()
104-
foreach ($ref in $InputReference) {
105-
$FileInfo = Resolve-FileInfo $ref
106-
$PostBody.files += $FileInfo
107-
}
108-
}
109-
else {
110-
if ($InputReference.Count -gt 1) {
111-
Write-Warning 'Only one input_reference is supported in OpenAI API. The first one will be used.'
112-
}
113-
$FileInfo = Resolve-FileInfo $InputReference[0]
114-
$PostBody.input_reference = $FileInfo
115-
}
102+
$FileInfo = Resolve-FileInfo $InputReference[0]
103+
$PostBody.input_reference = $FileInfo
116104
}
117105
#endregion
118106

Tests/Videos/New-Video.tests.ps1

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,83 @@ Describe 'New-Video' {
5151
Model = 'sora-2-pro'
5252
InputReference = (Join-Path $script:TestData 'sweets_donut.png')
5353
Seconds = 12
54+
Size = '1280x720'
5455
}
5556
$script:Result = New-Video @Params -ea Stop
5657
} | Should -Not -Throw
5758
Should -Invoke -CommandName Invoke-OpenAIAPIRequest -ModuleName $script:ModuleName -Times 1 -Exactly
5859
}
5960
}
61+
62+
Context 'Integration tests (online)' -Tag 'Online' {
63+
64+
BeforeAll {
65+
Clear-OpenAIContext
66+
}
67+
68+
BeforeEach {
69+
$script:Result = ''
70+
}
71+
72+
It 'Create a video job' {
73+
{
74+
$Params = @{
75+
Prompt = 'Dancing Donuts'
76+
Model = 'sora-2'
77+
Seconds = 4
78+
Size = '1280x720'
79+
TimeoutSec = 30
80+
MaxRetryCount = 1
81+
}
82+
$script:Result = New-Video @Params -ea Stop
83+
} | Should -Not -Throw
84+
Should -Invoke -CommandName Invoke-OpenAIAPIRequest -ModuleName $script:ModuleName -Times 1 -Exactly
85+
$Result | Should -BeOfType [pscustomobject]
86+
$Result.psobject.TypeNames | Should -Contain 'PSOpenAI.Video.Job'
87+
$Result.id | Should -Not -BeNullOrEmpty
88+
$Result.created_at | Should -BeOfType [datetime]
89+
}
90+
}
91+
92+
Context 'Integration tests (Azure OpenAI)' -Tag 'Azure' {
93+
94+
BeforeAll {
95+
# Set Context for Azure OpenAI
96+
$AzureContext = @{
97+
ApiType = 'Azure'
98+
AuthType = 'Azure'
99+
ApiKey = $env:AZURE_OPENAI_API_KEY
100+
ApiBase = $env:AZURE_OPENAI_ENDPOINT
101+
TimeoutSec = 30
102+
}
103+
Set-OpenAIContext @AzureContext
104+
}
105+
106+
BeforeEach {
107+
$script:Result = ''
108+
}
109+
110+
AfterAll {
111+
Clear-OpenAIContext
112+
}
113+
114+
It 'Create a video job' {
115+
{
116+
$Params = @{
117+
Prompt = 'Dancing Donuts'
118+
Model = 'sora'
119+
Seconds = 3
120+
Size = '480x480'
121+
TimeoutSec = 30
122+
MaxRetryCount = 1
123+
}
124+
$script:Result = New-Video @Params -ea Stop
125+
} | Should -Not -Throw
126+
Should -Invoke -CommandName Invoke-OpenAIAPIRequest -ModuleName $script:ModuleName -Times 1 -Exactly
127+
$Result | Should -BeOfType [pscustomobject]
128+
$Result.psobject.TypeNames | Should -Contain 'PSOpenAI.Video.Job'
129+
$Result.id | Should -Not -BeNullOrEmpty
130+
$Result.created_at | Should -BeOfType [datetime]
131+
}
132+
}
60133
}

0 commit comments

Comments
 (0)