tests¶
테스트 모듈.
conftest¶
pytest 에서 사용될 전역 Fixture들을 정의합니다.
-
AddStockFunc
¶ add_stock()
함수 타입.alias of Callable[[List[Tuple[str, str, int, Optional[str]]]], None]
-
AddStockLines
¶ add_stock()
함수의 인자 타입.alias of List[Tuple[str, str, int, Optional[str]]]
-
get_repo
(get_session)¶ SqlAlchemyRepository
팩토리 함수를 리턴하는 픽스쳐입니다.- Return type
Callable
[[],SqlAlchemyRepository
]
-
get_session
()¶ Session
팩토리 메소드(SessionMaker
) 를 리턴하는 픽스쳐 입니다.호출시마다
init_db()
을 호출(drop_all=True)하여 모든 DB 엔티티를 매번 재생성합니다.- Return type
-
server
(get_session)¶ ServerThread
로 구현된 재시작 가능한 멀티스레드 Flask 서버를 리턴하는 픽스쳐입니다.픽스쳐 사용후에는 `shutdown`을 통해 서버를 종료합니다.
- Return type
Generator
[FlaskServerThread
,None
,None
]
e2e¶
E2E 테스트 모듈입니다.
-
class
CustomFlask
(import_name, static_url_path=None, static_folder='static', static_host=None, host_matching=False, subdomain_matching=False, template_folder='templates', instance_path=None, instance_relative_config=False, root_path=None)¶ 동일 endpoint에 라우팅을 덮어쓰도록 허용하는 커스텀 Flask 구현입니다.
-
add_url_rule
(rule, endpoint=None, view_func=None, provide_automatic_options=None, **options)¶ 기존 매핑을 제거 후 등록합니다.
-
-
class
FlaskServerThread
(app)¶ 여러 다른 Flask App 컨텍스트를 교체하고 재시작 가능한 멀티스레드 서버.
-
run
()¶ 서버를 실행합니다.
- Return type
None
-
shutdown
()¶ 서버를 종료합니다.
- Return type
None
-
-
restart_flask_server
(app)¶ 기존에 시작중인
ServerThread
를 종료후 재시작 합니다.- Return type
None
-
start_flask_server
(app)¶ ServerThread
를 시작합니다.- Return type
None
-
stop_flask_server
()¶ ServerThread
를 종료합니다.- Return type
None
__init__¶
테스트 기본 설정 및 헬퍼 함수를 정의합니다.
-
class
mytest
¶ pytest 를 흉내내는 간단한 Jupyter Notebook용 테스트 러너 입니다.
-
classmethod
fixture
(func)¶ 함수 객체를 픽스쳐 레지스트리에 등록하는 함수 데코레이터.
- Return type
Callable
[…,Any
]
-
classmethod
run
(func)¶ 이전에 실행한 유닛 테스트를 다시 실행합니다.
Example
@test def test_example() ... mytest.run(test_example)
- Return type
Any
-
classmethod
test
(func)¶ 유닛 테스트를 등록하는 함수 데코레이터.
함수 정의와 동시에 테스트 함수를 실행합니다. 함수 실행이 실패해도 예외 메세지가 출력될 뿐 실행이 중단되지 않습니다.
파라메터가 정의된 함수의 경우 파라메터 이름들을 픽스쳐 레지스트리에서 찾아 재귀적으로 픽스쳐 함수를 실행한 결과를 인자 값으로 주입하여 테스트 함수를 실행합니다.
테스트 실행시 예외가 발생하면 예외 메세지를 출력합니다.
함수 객체는 내부 테스트 레지스트리에 보관되며
mytest.run()
으로 다시 실행할 수 있습니다.- Return type
Callable
[…,Any
]
-
classmethod
-
random_batchref
(num=1)¶ 임의의 Batch reference를 생성합니다.
- Return type
str
-
random_orderid
(name='')¶ 임의의 order_id 를 생성합니다.
- Return type
str
-
random_sku
(name='')¶ 임의의 SKU를 생성합니다.
- Return type
str
-
random_suffix
()¶ 랜덤 ID뒤에 붙일 UUID 기반의 6자리 임의의 ID를 생성합니다.
- Return type
str