Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
RoboQualityController
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
RoboCT (Public)
RoboQuality
RoboQualityController
Commits
2eeb038d
Commit
2eeb038d
authored
8 months ago
by
Simon Wittl
Browse files
Options
Downloads
Patches
Plain Diff
rm loadertest
parent
4f4e7e39
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_rq_json_loader.py
+0
-133
0 additions, 133 deletions
test/test_rq_json_loader.py
with
0 additions
and
133 deletions
test/test_rq_json_loader.py
deleted
100644 → 0
+
0
−
133
View file @
4f4e7e39
import
pytest
import
numpy
as
np
from
pathlib
import
Path
from
unittest.mock
import
MagicMock
,
patch
# Importing symbols from loader module
from
rq_controller.common
import
PyProjection
,
PyProjectionGeometry
,
PyRegionOfIntrest
,
PyVolume
import
pyometiff
from
rq_controller.common.io.rq_json
import
RqJsonLoader
class
MockOMETIFFReader
:
def
__init__
(
self
,
data
):
self
.
data
=
data
def
read
(
self
):
return
self
.
data
,
None
,
None
@pytest.fixture
def
rq_json_loader
()
->
RqJsonLoader
:
return
RqJsonLoader
()
@pytest.fixture
def
mock_load_json
():
# Mocking the load_json method to avoid actual file operations
with
patch
.
object
(
RqJsonLoader
,
'
load_json
'
)
as
mock
:
mock
.
return_value
=
{
'
focal_spot_mm
'
:
np
.
array
([
1.0
,
1.1
,
1.2
]),
'
detector_postion_mm
'
:
np
.
array
([
2.0
,
2.1
,
2.2
]),
'
detector_orientation_quad
'
:
np
.
array
([
3.0
,
3.1
,
3.2
]),
'
frame_id
'
:
'
frame1
'
,
'
focal_spot_orientation_quad
'
:
np
.
array
([
4.0
,
4.1
,
4.2
]),
'
detector_heigth_mm
'
:
5.0
,
'
detector_width_mm
'
:
6.0
,
'
voltage_kv
'
:
7.0
,
'
current_ua
'
:
8.0
,
'
exposure_time_ms
'
:
9.0
,
'
center_points_mm
'
:
[
10.0
,
11.0
,
12.0
],
'
dimensions_mm
'
:
[
13.0
,
14.0
,
15.0
],
'
resolution_mm
'
:
[
16.0
,
17.0
,
18.0
]
}
yield
mock
def
test_initialization
(
rq_json_loader
):
assert
rq_json_loader
.
porjection_geometry_suffix
==
'
.geom-json
'
assert
rq_json_loader
.
projection_suffix
==
'
.tif
'
assert
rq_json_loader
.
region_of_intrest_suffix
==
'
.roi-json
'
assert
rq_json_loader
.
volume_suffix
==
'
.ome.tiff
'
def
test_load_projection_geometry
(
rq_json_loader
,
mock_load_json
):
load_path
=
Path
(
'
/fake/path.tif
'
)
projection_geometry
=
rq_json_loader
.
load_projection_geometry
(
load_path
)
assert
isinstance
(
projection_geometry
,
PyProjectionGeometry
)
# Add more assertions as needed based on your implementation
def
test_load_projection
(
rq_json_loader
,
mock_load_json
):
load_path
=
Path
(
'
/fake/path.tif
'
)
projection
=
rq_json_loader
.
load_projection
(
load_path
)
assert
isinstance
(
projection
,
PyProjection
)
# Add more assertions as needed based on your implementation
def
test_load_region_of_intrest
(
rq_json_loader
,
mock_load_json
):
load_path
=
Path
(
'
/fake/path.roi-json
'
)
region_of_intrest
=
rq_json_loader
.
load_region_of_intrest
(
load_path
)
assert
isinstance
(
region_of_intrest
,
PyRegionOfIntrest
)
# Add more assertions as needed based on your implementation
def
test_load_volume
(
rq_json_loader
,
mock_load_json
):
load_path
=
Path
(
'
/fake/path.ome.tiff
'
)
with
patch
(
'
pyometiff.OMETIFFReader
'
,
MockOMETIFFReader
):
volume
=
rq_json_loader
.
load_volume
(
load_path
)
assert
isinstance
(
volume
,
PyVolume
)
# Add more assertions as needed based on your implementation
def
test_load_projection_geometry_raises_not_implemented
(
rq_json_loader
):
load_path
=
Path
(
'
/fake/path.tif
'
)
with
pytest
.
raises
(
NotImplementedError
):
rq_json_loader
.
load_projection_geometry
(
load_path
)
def
test_load_projection_raises_not_implemented
(
rq_json_loader
):
load_path
=
Path
(
'
/fake/path.tif
'
)
with
pytest
.
raises
(
NotImplementedError
):
rq_json_loader
.
load_projection
(
load_path
)
def
test_load_region_of_intrest_raises_not_implemented
(
rq_json_loader
):
load_path
=
Path
(
'
/fake/path.roi-json
'
)
with
pytest
.
raises
(
NotImplementedError
):
rq_json_loader
.
load_region_of_intrest
(
load_path
)
def
test_load_volume_raises_not_implemented
(
rq_json_loader
):
load_path
=
Path
(
'
/fake/path.ome.tiff
'
)
with
pytest
.
raises
(
NotImplementedError
):
rq_json_loader
.
load_volume
(
load_path
)
def
test_load_json
(
rq_json_loader
):
load_path
=
Path
(
'
/fake/path.json
'
)
data_dict
=
{
'
focal_spot_mm
'
:
np
.
array
([
1.0
]),
'
detector_postion_mm
'
:
np
.
array
([
2.0
]),
'
detector_orientation_quad
'
:
np
.
array
([
3.0
]),
'
frame_id
'
:
'
frame1
'
,
'
focal_spot_orientation_quad
'
:
np
.
array
([
4.0
])
}
with
patch
(
'
builtins.open
'
,
MagicMock
(
return_value
=
MagicMock
(
spec
=
open
))):
with
patch
(
'
json.load
'
,
MagicMock
(
return_value
=
data_dict
)):
result
=
rq_json_loader
.
load_json
(
load_path
)
assert
result
==
data_dict
def
test_load_json_file_not_found
(
rq_json_loader
):
load_path
=
Path
(
'
/fake/path.json
'
)
with
pytest
.
raises
(
FileNotFoundError
):
rq_json_loader
.
load_json
(
load_path
)
def
test_load_volume_invalid_dtype
(
rq_json_loader
,
mock_load_json
):
load_path
=
Path
(
'
/fake/path.ome.tiff
'
)
with
patch
(
'
pyometiff.OMETIFFReader
'
,
MockOMETIFFReader
):
with
pytest
.
raises
(
ValueError
):
rq_json_loader
.
load_volume
(
load_path
)
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