30 lines
892 B
Python
30 lines
892 B
Python
import pytest
|
|
|
|
from image_prediction.exceptions import InvalidBox
|
|
from image_prediction.info import Info
|
|
from image_prediction.stitching.utils import validate_box_size, validate_box_coords
|
|
|
|
|
|
def test_validate_fail_too_short():
|
|
box = {Info.WIDTH: 1, Info.HEIGHT: 0}
|
|
with pytest.raises(InvalidBox):
|
|
validate_box_size(box)
|
|
|
|
|
|
def test_validate_fail_too_thin():
|
|
box = {Info.WIDTH: 0, Info.HEIGHT: 1}
|
|
with pytest.raises(InvalidBox):
|
|
validate_box_size(box)
|
|
|
|
|
|
def test_validate_fail_xs_width_mismatch():
|
|
box = {Info.WIDTH: 2, Info.HEIGHT: 4, Info.X1: 0, Info.Y1: 0, Info.X2: 1, Info.Y2: 4}
|
|
with pytest.raises(InvalidBox):
|
|
validate_box_coords(box)
|
|
|
|
|
|
def test_validate_fail_ys_width_mismatch():
|
|
box = {Info.WIDTH: 2, Info.HEIGHT: 3, Info.X1: 0, Info.Y1: 0, Info.X2: 2, Info.Y2: 4}
|
|
with pytest.raises(InvalidBox):
|
|
validate_box_coords(box)
|