Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a basic MockServer integration test for Python #3534

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions it/exec-cmd.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,24 @@ elseif ($language -eq "python") {
pylint integration_test --disable=W --rcfile=.pylintrc
mypy integration_test
} -ErrorAction Stop

if (!([string]::IsNullOrEmpty($mockSeverITFolder))) {
$itTestPath = Join-Path -Path $testPath -ChildPath $mockSeverITFolder
Push-Location $itTestPath

$itTestPathSources = Join-Path -Path $testPath -ChildPath "integration_test" -AdditionalChildPath "client"
$itTestPathDest = Join-Path -Path $itTestPath -ChildPath "client"
if (Test-Path $itTestPathDest) {
Remove-Item $itTestPathDest -Force -Recurse
}
Copy-Item -Path $itTestPathSources -Destination $itTestPathDest -Recurse

Invoke-Call -ScriptBlock {
pytest
} -ErrorAction Stop

Pop-Location
}
}
Pop-Location

Expand Down
21 changes: 21 additions & 0 deletions it/python/basic/test_sample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pytest
from kiota_abstractions.authentication.anonymous_authentication_provider import (
AnonymousAuthenticationProvider,
)
from kiota_http.httpx_request_adapter import HttpxRequestAdapter

from client.api_client import ApiClient
from client.models.error import Error

@pytest.mark.asyncio
async def test_basic_upload_download():
auth_provider = AnonymousAuthenticationProvider()
request_adapter = HttpxRequestAdapter(auth_provider)
request_adapter.base_url = 'http://127.0.0.1:1080'
client = ApiClient(request_adapter)

with pytest.raises(Error) as execinfo:
await client.api.v1.topics.get()

assert execinfo.value.id == "my-sample-id"
assert execinfo.value.code == 123