Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DBRepo
Manage
Activity
Members
Labels
Plan
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
FAIR Data Austria DB Repository
DBRepo
Commits
e508ee19
Commit
e508ee19
authored
5 months ago
by
Martin Weise
Browse files
Options
Downloads
Patches
Plain Diff
Fixed the test
Signed-off-by:
Martin Weise
<
martin.weise@tuwien.ac.at
>
parent
0b45f7f7
No related branches found
No related tags found
1 merge request
!370
Fixed the test
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/python/tests/test_unit_database.py
+22
-54
22 additions, 54 deletions
lib/python/tests/test_unit_database.py
with
22 additions
and
54 deletions
lib/python/tests/test_unit_database.py
+
22
−
54
View file @
e508ee19
import
unittest
import
unittest
import
requests_mock
import
requests_mock
from
pydantic_core
import
ValidationError
from
pydantic_core
import
ValidationError
from
dbrepo.RestClient
import
RestClient
from
dbrepo.RestClient
import
RestClient
from
dbrepo.api.dto
import
Database
,
Container
,
Image
,
DatabaseAccess
,
AccessType
,
DatabaseBrief
,
UserBrief
,
DataType
from
dbrepo.api.dto
import
Database
,
Container
,
Image
,
DatabaseAccess
,
AccessType
,
DatabaseBrief
,
UserBrief
,
\
ContainerBrief
,
ImageBrief
from
dbrepo.api.exceptions
import
ResponseCodeError
,
NotExistsError
,
ForbiddenError
,
MalformedError
,
AuthenticationError
from
dbrepo.api.exceptions
import
ResponseCodeError
,
NotExistsError
,
ForbiddenError
,
MalformedError
,
AuthenticationError
...
@@ -45,27 +45,16 @@ class DatabaseUnitTest(unittest.TestCase):
...
@@ -45,27 +45,16 @@ class DatabaseUnitTest(unittest.TestCase):
exchange_name
=
'
dbrepo
'
,
exchange_name
=
'
dbrepo
'
,
internal_name
=
'
test_abcd
'
,
internal_name
=
'
test_abcd
'
,
is_public
=
True
,
is_public
=
True
,
container
=
Container
(
is_schema_public
=
True
,
container
=
ContainerBrief
(
id
=
1
,
id
=
1
,
name
=
'
MariaDB Galera 11.1.3
'
,
name
=
'
MariaDB Galera 11.1.3
'
,
internal_name
=
'
mariadb
'
,
internal_name
=
'
mariadb
'
,
host
=
'
data-db
'
,
image
=
ImageBrief
(
port
=
3306
,
sidecar_host
=
'
data-db-sidecar
'
,
sidecar_port
=
3305
,
image
=
Image
(
id
=
1
,
id
=
1
,
registry
=
'
docker.io
'
,
name
=
'
mariadb
'
,
name
=
'
mariadb
'
,
version
=
'
11.2.2
'
,
version
=
'
11.2.2
'
,
dialect
=
'
org.hibernate.dialect.MariaDBDialect
'
,
jdbc_method
=
'
mariadb
'
driver_class
=
'
org.mariadb.jdbc.Driver
'
,
jdbc_method
=
'
mariadb
'
,
default_port
=
3306
,
data_types
=
[
DataType
(
display_name
=
"
SERIAL
"
,
value
=
"
serial
"
,
documentation
=
"
https://mariadb.com/kb/en/bigint/
"
,
is_quoted
=
False
,
is_buildable
=
True
)]
)
)
)
)
)
)
...
@@ -111,23 +100,16 @@ class DatabaseUnitTest(unittest.TestCase):
...
@@ -111,23 +100,16 @@ class DatabaseUnitTest(unittest.TestCase):
exchange_name
=
'
dbrepo
'
,
exchange_name
=
'
dbrepo
'
,
internal_name
=
'
test_abcd
'
,
internal_name
=
'
test_abcd
'
,
is_public
=
True
,
is_public
=
True
,
container
=
Container
(
is_schema_public
=
True
,
container
=
ContainerBrief
(
id
=
1
,
id
=
1
,
name
=
'
MariaDB Galera 11.1.3
'
,
name
=
'
MariaDB Galera 11.1.3
'
,
internal_name
=
'
mariadb
'
,
internal_name
=
'
mariadb
'
,
host
=
'
data-db
'
,
image
=
ImageBrief
(
port
=
3306
,
sidecar_host
=
'
data-db-sidecar
'
,
sidecar_port
=
3305
,
image
=
Image
(
id
=
1
,
id
=
1
,
registry
=
'
docker.io
'
,
name
=
'
mariadb
'
,
name
=
'
mariadb
'
,
version
=
'
11.2.2
'
,
version
=
'
11.2.2
'
,
dialect
=
'
org.hibernate.dialect.MariaDBDialect
'
,
jdbc_method
=
'
mariadb
'
driver_class
=
'
org.mariadb.jdbc.Driver
'
,
jdbc_method
=
'
mariadb
'
,
default_port
=
3306
)
)
)
)
)
)
...
@@ -180,29 +162,22 @@ class DatabaseUnitTest(unittest.TestCase):
...
@@ -180,29 +162,22 @@ class DatabaseUnitTest(unittest.TestCase):
exchange_name
=
'
dbrepo
'
,
exchange_name
=
'
dbrepo
'
,
internal_name
=
'
test_abcd
'
,
internal_name
=
'
test_abcd
'
,
is_public
=
True
,
is_public
=
True
,
container
=
Container
(
is_schema_public
=
True
,
container
=
ContainerBrief
(
id
=
1
,
id
=
1
,
name
=
'
MariaDB Galera 11.1.3
'
,
name
=
'
MariaDB Galera 11.1.3
'
,
internal_name
=
'
mariadb
'
,
internal_name
=
'
mariadb
'
,
host
=
'
data-db
'
,
image
=
ImageBrief
(
port
=
3306
,
sidecar_host
=
'
data-db-sidecar
'
,
sidecar_port
=
3305
,
image
=
Image
(
id
=
1
,
id
=
1
,
registry
=
'
docker.io
'
,
name
=
'
mariadb
'
,
name
=
'
mariadb
'
,
version
=
'
11.2.2
'
,
version
=
'
11.2.2
'
,
dialect
=
'
org.hibernate.dialect.MariaDBDialect
'
,
jdbc_method
=
'
mariadb
'
driver_class
=
'
org.mariadb.jdbc.Driver
'
,
jdbc_method
=
'
mariadb
'
,
default_port
=
3306
)
)
)
)
)
)
with
requests_mock
.
Mocker
()
as
mock
:
with
requests_mock
.
Mocker
()
as
mock
:
# mock
# mock
mock
.
put
(
'
/api/database/1
'
,
json
=
exp
.
model_dump
(),
status_code
=
202
)
mock
.
put
(
'
/api/database/1
/visibility
'
,
json
=
exp
.
model_dump
(),
status_code
=
202
)
# test
# test
client
=
RestClient
(
username
=
"
a
"
,
password
=
"
b
"
)
client
=
RestClient
(
username
=
"
a
"
,
password
=
"
b
"
)
response
=
client
.
update_database_visibility
(
database_id
=
1
,
is_public
=
True
,
is_schema_public
=
True
)
response
=
client
.
update_database_visibility
(
database_id
=
1
,
is_public
=
True
,
is_schema_public
=
True
)
...
@@ -211,7 +186,7 @@ class DatabaseUnitTest(unittest.TestCase):
...
@@ -211,7 +186,7 @@ class DatabaseUnitTest(unittest.TestCase):
def
test_update_database_visibility_not_allowed_fails
(
self
):
def
test_update_database_visibility_not_allowed_fails
(
self
):
with
requests_mock
.
Mocker
()
as
mock
:
with
requests_mock
.
Mocker
()
as
mock
:
# mock
# mock
mock
.
put
(
'
/api/database/1
'
,
status_code
=
403
)
mock
.
put
(
'
/api/database/1
/visibility
'
,
status_code
=
403
)
# test
# test
try
:
try
:
client
=
RestClient
(
username
=
"
a
"
,
password
=
"
b
"
)
client
=
RestClient
(
username
=
"
a
"
,
password
=
"
b
"
)
...
@@ -222,7 +197,7 @@ class DatabaseUnitTest(unittest.TestCase):
...
@@ -222,7 +197,7 @@ class DatabaseUnitTest(unittest.TestCase):
def
test_update_database_visibility_not_found_fails
(
self
):
def
test_update_database_visibility_not_found_fails
(
self
):
with
requests_mock
.
Mocker
()
as
mock
:
with
requests_mock
.
Mocker
()
as
mock
:
# mock
# mock
mock
.
put
(
'
/api/database/1
'
,
status_code
=
404
)
mock
.
put
(
'
/api/database/1
/visibility
'
,
status_code
=
404
)
# test
# test
try
:
try
:
client
=
RestClient
(
username
=
"
a
"
,
password
=
"
b
"
)
client
=
RestClient
(
username
=
"
a
"
,
password
=
"
b
"
)
...
@@ -244,28 +219,21 @@ class DatabaseUnitTest(unittest.TestCase):
...
@@ -244,28 +219,21 @@ class DatabaseUnitTest(unittest.TestCase):
exp
=
Database
(
exp
=
Database
(
id
=
1
,
id
=
1
,
name
=
'
test
'
,
name
=
'
test
'
,
owner
=
UserBrief
(
id
=
'
abdbf897-e599-4e5a-a3f0-7529884ea011
'
,
username
=
'
other
'
),
owner
=
UserBrief
(
id
=
'
abdbf897-e599-4e5a-a3f0-7529884ea011
'
,
username
=
'
mweise
'
),
contact
=
UserBrief
(
id
=
'
8638c043-5145-4be8-a3e4-4b79991b0a16
'
,
username
=
'
mweise
'
),
contact
=
UserBrief
(
id
=
'
8638c043-5145-4be8-a3e4-4b79991b0a16
'
,
username
=
'
mweise
'
),
exchange_name
=
'
dbrepo
'
,
exchange_name
=
'
dbrepo
'
,
internal_name
=
'
test_abcd
'
,
internal_name
=
'
test_abcd
'
,
is_public
=
True
,
is_public
=
True
,
container
=
Container
(
is_schema_public
=
True
,
container
=
ContainerBrief
(
id
=
1
,
id
=
1
,
name
=
'
MariaDB Galera 11.1.3
'
,
name
=
'
MariaDB Galera 11.1.3
'
,
internal_name
=
'
mariadb
'
,
internal_name
=
'
mariadb
'
,
host
=
'
data-db
'
,
image
=
ImageBrief
(
port
=
3306
,
sidecar_host
=
'
data-db-sidecar
'
,
sidecar_port
=
3305
,
image
=
Image
(
id
=
1
,
id
=
1
,
registry
=
'
docker.io
'
,
name
=
'
mariadb
'
,
name
=
'
mariadb
'
,
version
=
'
11.2.2
'
,
version
=
'
11.2.2
'
,
dialect
=
'
org.hibernate.dialect.MariaDBDialect
'
,
jdbc_method
=
'
mariadb
'
driver_class
=
'
org.mariadb.jdbc.Driver
'
,
jdbc_method
=
'
mariadb
'
,
default_port
=
3306
)
)
)
)
)
)
...
...
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