Skip to content

Commit

Permalink
Fixed pytests, CircleCi tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkwok475 committed Jan 9, 2025
1 parent 85c884c commit 354cfb4
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 127 deletions.
4 changes: 2 additions & 2 deletions main_window/competition/mapping/mapbox_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,11 @@ def appendh(A, B):
img = appendv(img, row)

if is_img_not_blank is True:
plt.imsave(outfile, img.astype(np.uint8))
plt.imsave(outfile, img)

t2 = time.perf_counter()
LOGGER.debug(f"Successfully generated size {str(self.scale)} map in {t2 - t1} seconds.")
return plt.imread(outfile, "jpeg")
return img
else:
LOGGER.debug(f"Found size {str(self.scale)} map!")
return plt.imread(outfile, "jpeg")
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ dependencies = [
"sortedcontainers==2.4.0",
"pyqt5-qt5==5.15.2",
"digi-xbee",
"opencv-python-headless>=4.10.0.84",
"opencv-python>=4.10.0.84",
]

[tool.uv.sources]
Expand Down
13 changes: 6 additions & 7 deletions tests/test_mapbox_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,14 @@ def test_get_image_fail(self, hennings_tile, mocker):
)

def test_get_image_exists(self, hennings_tile, mocker):
impath = os.path.join(LOCAL, "tests", "test_mapbox_utils", "41322_89729.png")
hennings_image = pyplot.imread(impath, "jpeg")

hennings_image = pyplot.imread(
os.path.join(LOCAL, "tests", "test_mapbox_utils", "41322_89729.jpg"), "jpeg"
)
mocked_tile = mocker.patch("main_window.competition.mapping.mapbox_utils.maps.tile")
mocked_tile.return_value.status_code = 200
mocked_tile.return_value.content = cv2.imencode('.png', cv2.imread(impath))[1]
mocked_tile.return_value.content = hennings_image

# Pass true to overwrite as image file may exist from previous tests
i = hennings_tile.getImage(overwrite=True)
i = hennings_tile.getImage()

numpy.testing.assert_array_equal(i, hennings_image)

Expand Down Expand Up @@ -158,7 +157,7 @@ def test_gen_stitched_map(self, ubc_tile_grid):
# assert_allclose because linux vs. windows can decode the images slightly differently
# https://github.com/python-pillow/Pillow/issues/3833
# https://github.com/python-pillow/Pillow/issues/4686
numpy.testing.assert_allclose(hennings_image.astype(numpy.uint8)[:,:,:3], stitched_map[:,:,:3], rtol=0, atol=20) # Some systems return alpha channels for one and not the other, needs to be removed before comparison
numpy.testing.assert_allclose(hennings_image.astype(numpy.float64)[:,:,:3] * 255, stitched_map[:,:,:3], rtol=0, atol=20) # Some systems return alpha channels for one and not the other, needs to be removed before comparison


def test_point_to_tile(ubc_point_1):
Expand Down
Binary file added tests/test_mapbox_utils/41322_89729.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tests/test_mapbox_utils/41322_89729.png
Binary file not shown.
Loading

0 comments on commit 354cfb4

Please sign in to comment.