-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathtest_app.py
More file actions
99 lines (63 loc) · 2.97 KB
/
Copy pathtest_app.py
File metadata and controls
99 lines (63 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
import os
import sys
from unittest import mock
import pytest
from pydantic import ValidationError
@pytest.fixture(scope="function", autouse=True)
def stack_defaults():
with mock.patch.dict(os.environ, {}, clear=True):
os.environ["SEEDFARMER_PROJECT_NAME"] = "test-project"
os.environ["SEEDFARMER_DEPLOYMENT_NAME"] = "test-deployment"
os.environ["SEEDFARMER_MODULE_NAME"] = "test-module"
os.environ["CDK_DEFAULT_ACCOUNT"] = "111111111111"
os.environ["CDK_DEFAULT_REGION"] = "us-east-1"
os.environ["SEEDFARMER_PARAMETER_JOB_NAME"] = "job-name"
os.environ["SEEDFARMER_PARAMETER_TASK_TYPE"] = "image_bounding_box"
os.environ["SEEDFARMER_PARAMETER_LABELING_WORKTEAM_ARN"] = "labeling-workteam"
os.environ["SEEDFARMER_PARAMETER_LABELING_CATEGORIES_S3_URI"] = "s3://bucket/labeling-categories"
os.environ["SEEDFARMER_PARAMETER_LABELING_TASK_TITLE"] = "labeling-title"
os.environ["SEEDFARMER_PARAMETER_LABELING_TASK_DESCRIPTION"] = "labeling-description"
os.environ["SEEDFARMER_PARAMETER_LABELING_TASK_KEYWORDS"] = '["labeling-keywords"]'
# Unload the app import so that subsequent tests don't reuse
if "app" in sys.modules:
del sys.modules["app"]
yield
def test_app() -> None:
import app # noqa: F401
def test_job_name() -> None:
del os.environ["SEEDFARMER_PARAMETER_JOB_NAME"]
with pytest.raises(ValidationError):
import app # noqa: F401
def test_task_type() -> None:
del os.environ["SEEDFARMER_PARAMETER_TASK_TYPE"]
with pytest.raises(ValidationError):
import app # noqa: F401
def test_task_type_invalid_value() -> None:
os.environ["SEEDFARMER_PARAMETER_TASK_TYPE"] = "task_type"
with pytest.raises(Exception):
import app # noqa: F401
def test_labeling_workteam_arn() -> None:
del os.environ["SEEDFARMER_PARAMETER_LABELING_WORKTEAM_ARN"]
with pytest.raises(ValidationError):
import app # noqa: F401
def test_labeling_categories_s3_uri() -> None:
del os.environ["SEEDFARMER_PARAMETER_LABELING_CATEGORIES_S3_URI"]
with pytest.raises(ValidationError):
import app # noqa: F401
def test_labeling_task_title() -> None:
del os.environ["SEEDFARMER_PARAMETER_LABELING_TASK_TITLE"]
with pytest.raises(ValidationError):
import app # noqa: F401
def test_labeling_task_description() -> None:
del os.environ["SEEDFARMER_PARAMETER_LABELING_TASK_DESCRIPTION"]
with pytest.raises(ValidationError):
import app # noqa: F401
def test_labeling_task_keywords() -> None:
del os.environ["SEEDFARMER_PARAMETER_LABELING_TASK_KEYWORDS"]
with pytest.raises(ValidationError):
import app # noqa: F401
def test_app_with_custom_tags() -> None:
os.environ["SEEDFARMER_PARAMETER_CUSTOM_TAGS"] = '{"CustomerTag": "test-value"}'
import app # noqa: F401