Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Test as a Service Client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
INS Courses
AutPy
Test as a Service Client
Commits
a6cb022c
Commit
a6cb022c
authored
2 years ago
by
Florian Bruhin
Browse files
Options
Downloads
Patches
Plain Diff
tests: Add golden tests for error conditions
parent
46ee962a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/golden/error-empty.yml
+9
-0
9 additions, 0 deletions
tests/golden/error-empty.yml
tests/golden/error-json.yml
+13
-0
13 additions, 0 deletions
tests/golden/error-json.yml
tests/test_cli.py
+10
-2
10 additions, 2 deletions
tests/test_cli.py
with
32 additions
and
2 deletions
tests/golden/error-empty.yml
0 → 100644
+
9
−
0
View file @
a6cb022c
input
:
http_status
:
500
exit_code
:
1
output
:
|
Last change: 0 seconds ago
Server error '500 Internal Server Error' for url
'http://localhost:5000/testbook'
For more information check: https://httpstatuses.com/500
This diff is collapsed.
Click to expand it.
tests/golden/error-json.yml
0 → 100644
+
13
−
0
View file @
a6cb022c
input
:
error
:
SomethingWentWrongError
msg
:
Alles kaputt
http_status
:
400
exit_code
:
1
output
:
|
Last change: 0 seconds ago
Client error '400 Bad Request' for url 'http://localhost:5000/testbook'
For more information check: https://httpstatuses.com/400
Error: SomethingWentWrongError
Message: Alles kaputt
💥 Submission failed! (2022-10-12 13:37:00)
This diff is collapsed.
Click to expand it.
tests/test_cli.py
+
10
−
2
View file @
a6cb022c
...
...
@@ -140,12 +140,20 @@ def test_golden(
time_machine
:
TimeMachineFixture
,
nb_arg
:
str
,
)
->
None
:
httpx_mock
.
add_response
(
json
=
golden
[
"
input
"
])
# FIXME add URL?
httpx_mock
.
add_response
(
# FIXME add URL?
method
=
"
POST
"
,
json
=
golden
[
"
input
"
],
status_code
=
golden
.
get
(
"
http_status
"
,
200
),
)
delay
=
golden
.
get
(
"
delay
"
,
0
)
time_machine
.
move_to
(
FROZEN_TIME
+
datetime
.
timedelta
(
seconds
=
delay
))
result
=
runner
.
invoke
(
cli
.
app
,
[
nb_arg
])
print
(
result
.
stdout
)
assert
result
.
exit_code
==
0
# FIXME pytest-golden should probably support a fallback for .get, or at least
# __contains__
exit_code
=
0
if
golden
.
get
(
"
exit_code
"
)
is
None
else
golden
.
out
[
"
exit_code
"
]
assert
result
.
exit_code
==
exit_code
assert
result
.
stdout
==
golden
.
out
[
"
output
"
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment