Skip to content

Commit

Permalink
removed duplicate test functions
Browse files Browse the repository at this point in the history
  • Loading branch information
AWSChris committed Aug 9, 2022
1 parent 930cdb4 commit 3959d6e
Showing 1 changed file with 1 addition and 105 deletions.
106 changes: 1 addition & 105 deletions python/example_code/lookoutvision/test/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_detect_anomalies(make_stubber, monkeypatch, error_code):
project_name = 'test-project_name'
model_version = 'test-model'
photo = 'test.jpeg'
content_type = f'image/jpeg'
content_type = 'image/jpeg'
image_contents = b'test-contents'
anomalous = True
confidence = .5
Expand Down Expand Up @@ -118,110 +118,6 @@ def test_reject_on_anomaly_types(make_stubber, error_code):
assert exc_info.typename == "KeyError"


@pytest.mark.parametrize('error_code', [None, 'TestException'])
def test_reject_on_coverage(make_stubber, error_code):

photo = 's3://doc-example-bucket/test-photo.jpeg'
prediction = {
"IsAnomalous": True,
"Confidence": 0.9,
"Anomalies": [
{
"Name": "broken",
"PixelAnomaly": {"TotalPercentageArea": 0.10}
},
{
"Name": "broken",
"PixelAnomaly": {"TotalPercentageArea": 0.50}
}
]
}

confidence_limit = 0.5
coverage_limit = 1
anomaly_label = "broken"

if error_code is None:
Inference.reject_on_coverage(
photo, prediction, confidence_limit, anomaly_label, coverage_limit)
else:
prediction = {
"IsAnomalous": True,
"Confidence": 0.9,
"Anomalies": [
{
"Name": "broken",
"PixelAnomalyX": {"TotalPercentageArea": 0.10}
},
{
"Name": "broken",
"PixelAnomalyX": {"TotalPercentageArea": 0.50}
}
]
}
with pytest.raises(KeyError) as exc_info:
Inference.reject_on_coverage(
photo, prediction, confidence_limit, anomaly_label, coverage_limit)
assert exc_info.typename == "KeyError"

@pytest.mark.parametrize('error_code', [None, 'TestException'])
def test_reject_on_classification(make_stubber, error_code):

photo = 's3://doc-example-bucket/test-photo.jpeg'
prediction = {
"IsAnomalous": True,
"Confidence": 0.9
}

confidence_limit = 0.5

if error_code is None:
Inference.reject_on_classification(photo, prediction, confidence_limit)
else:
prediction = {
"IsAnomalousX": True,
"Confidence": 0.9
}
with pytest.raises(KeyError) as exc_info:
Inference.reject_on_classification(
photo, prediction, confidence_limit)
assert exc_info.typename == "KeyError"


@pytest.mark.parametrize('error_code', [None, 'TestException'])
def test_reject_on_anomaly_types(make_stubber, error_code):

photo = 's3://doc-example-bucket/test-photo.jpeg'
prediction = {
"IsAnomalous": True,
"Confidence": 0.9,
"Anomalies": [
{"Name": "broken"},
{"Name": "cracked"}
]
}

confidence_limit = 0.5
anomaly_types_limit = 1

if error_code is None:
Inference.reject_on_anomaly_types(
photo, prediction, confidence_limit, anomaly_types_limit)
else:
prediction = {
"IsAnomalous": True,
"Confidence": 0.9,
"AnomaliesX": [
{"Name": "broken"},
{"Name": "cracked"}
]
}
with pytest.raises(KeyError) as exc_info:
Inference.reject_on_anomaly_types(
photo, prediction, confidence_limit, anomaly_types_limit)
assert exc_info.typename == "KeyError"


@pytest.mark.parametrize('error_code', [None, 'TestException'])
def test_reject_on_coverage(make_stubber, error_code):

Expand Down

0 comments on commit 3959d6e

Please sign in to comment.