Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DataCatalog
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eFlows4HPC WP2
DataCatalog
Commits
c2d0ef52
Commit
c2d0ef52
authored
3 years ago
by
Jedrzej Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
pytest compatible testing
parent
322f1ad8
No related branches found
No related tags found
No related merge requests found
Pipeline
#69392
passed
3 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/apiserver_tests/test_apiwithauth.py
+10
-9
10 additions, 9 deletions
tests/apiserver_tests/test_apiwithauth.py
with
10 additions
and
9 deletions
tests/apiserver_tests/test_apiwithauth.py
+
10
−
9
View file @
c2d0ef52
from
fastapi.testclient
import
TestClient
from
apiserver.main
import
app
,
my_user
,
my_auth
from
context
import
apiserver
,
storage
#from apiserver import app, my_user, my_auth
from
unittest
import
TestCase
from
apiserver.security.user
import
User
...
...
@@ -9,26 +11,25 @@ def myfunc():
class
UserTests
(
TestCase
):
def
setUp
(
self
):
self
.
client
=
TestClient
(
app
)
app
.
dependency_overrides
=
{}
apiserver
.
app
.
dependency_overrides
[
apiserver
.
main
.
my_auth
]
=
myfunc
apiserver
.
app
.
dependency_overrides
[
apiserver
.
main
.
my_user
]
=
myfunc
self
.
client
=
TestClient
(
apiserver
.
app
)
def
tearDown
(
self
):
app
.
dependency_overrides
=
{}
apiserver
.
app
.
dependency_overrides
=
{}
def
test_me
(
self
):
app
.
dependency_overrides
[
my_user
]
=
myfunc
resp
=
self
.
client
.
get
(
'
/me
'
)
self
.
assertEqual
s
(
resp
.
json
(),
{
'
username
'
:
'
foo
'
,
'
email
'
:
'
bar
'
})
self
.
assertEqual
(
resp
.
json
(),
{
'
username
'
:
'
foo
'
,
'
email
'
:
'
bar
'
})
def
test_token
(
self
):
app
.
dependency_overrides
[
my_auth
]
=
myfunc
rsp
=
self
.
client
.
post
(
'
/token
'
).
json
()
self
.
assertEqual
(
rsp
[
"
token_type
"
],
"
bearer
"
)
self
.
assertTrue
(
'
access_token
'
in
rsp
)
def
test_create
(
self
):
app
.
dependency_overrides
[
my_user
]
=
myfunc
my_data
=
{
'
name
'
:
'
some dataset
'
,
'
url
'
:
'
http://loc.me/1
'
,
...
...
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