async def test_applicant_persistent_repo_patch(mysql_manage, applicant_persistent_repo, save_applicant_dummy_to_db): repo = applicant_persistent_repo await repo.patch(generate_applicant_email(0), {"password": "******"}) await repo.patch(generate_applicant_email(0), {"applicant_name": "연중모"}) await repo.patch(generate_applicant_email(0), {"applicant_sex": "MALE"}) await repo.patch(generate_applicant_email(0), {"post_code": "17002"})
async def test_applicant_persistent_repo_get(mysql_manage, applicant_persistent_repo, save_applicant_dummy_to_db): repo = applicant_persistent_repo result = await repo.get_one(generate_applicant_email(0)) assert generate_applicant_email(0) == result["email"] result = await repo.get_list() assert isinstance(result, list) and isinstance(result[0], dict) result = await repo.get_list({"email": generate_applicant_email(0)}) assert generate_applicant_email(0) == result[0]["email"]
async def test_applicant_status_persistent_repo_get( mysql_manage, applicant_status_persistent_repo, save_applicant_dummy_to_db, save_applicant_status_dummy_to_db, ): repo: ApplicantStatusPersistentRepository = applicant_status_persistent_repo for i in range(10): result = await repo.get_one(generate_applicant_email(i)) assert result["applicant_email"] == generate_applicant_email(i) assert result["receipt_code"] == i + 1
async def test_applicant_status_persistent_repo_patch( mysql_manage, applicant_status_persistent_repo, save_applicant_dummy_to_db, save_applicant_status_dummy_to_db, ): repo: ApplicantStatusPersistentRepository = applicant_status_persistent_repo await repo.patch(generate_applicant_email(0), {"is_paid": True}) await repo.patch(generate_applicant_email(0), {"is_printed_application_arrived": False}) await repo.patch(generate_applicant_email(0), {"exam_code": "029435"})
def create_applicant_status_dummy_object(applicant_index: int): return ApplicantStatus( applicant_email=generate_applicant_email(applicant_index), receipt_code=applicant_index, is_paid=random.choice([True, False]), is_final_submit=random.choice([True, False]), is_passed_first_apply=random.choice([True, False]), is_printed_application_arrived=random.choice([True, False]), exam_code=random.randint(100000, 999999), )
def applicant_view_test_data(): test_set = [ generate_endpoint_test_data( method="POST", endpoint="/api/v1/applicant", query_param={}, request_body={ "email": generate_applicant_email(11), "password": generate_random_string(), }, expected_response_status=201, expected_response_body={ **applicant_response(11), "status": applicant_status_dunno_response, }, ), generate_endpoint_test_data( method="POST", endpoint="/api/v1/applicant", query_param={}, request_body={ "email": generate_applicant_email(0), "password": generate_random_string(), }, expected_response_status=409, expected_response_body=status_message_response(), ), generate_endpoint_test_data( method="POST", endpoint="/api/v1/applicant", query_param={}, request_body={ "email": generate_applicant_email(11), "pssword": generate_random_string(), }, expected_response_status=400, expected_response_body=status_message_response(), ), ] return test_set
def applicant_batch_view_test_data(): test_set = [ generate_endpoint_test_data( method="GET", endpoint="/api/v1/applicant/batch", query_param={}, request_body={}, expected_response_status=200, expected_response_body=applicant_batch_response(10), ), generate_endpoint_test_data( method="GET", endpoint="/api/v1/applicant/batch", query_param={"email": generate_applicant_email(0)}, request_body={}, expected_response_status=200, expected_response_body=applicant_batch_response(1), ), generate_endpoint_test_data( method="GET", endpoint="/api/v1/applicant/batch", query_param={"sex": "FEMALE"}, request_body={}, expected_response_status=200, expected_response_body=applicant_batch_response(5, sex="FEMALE"), ), generate_endpoint_test_data( method="GET", endpoint="/api/v1/applicant/batch", query_param={"email": generate_applicant_email(14)}, request_body={}, expected_response_status=200, expected_response_body=applicant_batch_response(0), ), ] return test_set
async def test_applicant_persistent_repo_delete(mysql_manage, applicant_persistent_repo, save_applicant_dummy_to_db): repo = applicant_persistent_repo await repo.delete(generate_applicant_email(0))
async def test_applicant_cache_repo_delete(cache_manage, applicant_cache_repo, save_applicant_dummy_to_cache): repo = applicant_cache_repo for i in range(10): await repo.delete(generate_applicant_email(i))
async def test_applicant_cache_repo_get(cache_manage, applicant_cache_repo, save_applicant_dummy_to_cache): repo = applicant_cache_repo for i in range(10): result = await repo.get(generate_applicant_email(i)) assert generate_applicant_email(i) == result["email"]