def test_gyomu_app_load(self, environment_setup): app = GyomuAppsInfoCdtbl() app.application_id = TEST_APPLICATION_ID2 app.description = "Test Application" user: User = UserFactory.get_current_user() app.mail_from_name = user.userid app.mail_from_address = "*****@*****.**" json_data = gyomuapps_schema_load.dumps(app) dictionary = gyomuapps_schema.loads(json_data=json_data) with DbConnectionFactory.get_gyomu_db_session() as session: app_loaded = gyomuapps_schema_load.load(dictionary, session=session) assert app.application_id == app_loaded.application_id app2 = GyomuAppsInfoCdtbl() app2.application_id = TEST_APPLICAIONT_ID3 app2.description = "Testw Application" user: User = UserFactory.get_current_user() app2.mail_from_name = user.userid app2.mail_from_address = "*****@*****.**" app_list = [app, app2] json_data = gyomuapps_total_list_schema.dumps(app_list) dictionary = gyomuapps_total_list_schema.loads(json_data=json_data) with DbConnectionFactory.get_gyomu_db_session() as session: apps = gyomuapps_total_list_schema_load.load(dictionary, session=session) assert len(apps) == 2
def test_gyomu_app(self): app = GyomuAppsInfoCdtbl() app.application_id = TEST_APPLICATION_ID2 app.description = "Test Application" user: User = UserFactory.get_current_user() app.mail_from_name = user.userid app.mail_from_address = "*****@*****.**" json_data = Json.to_json(app, gyomuapps_schema) app_loaded = Json.deserialize(json_data, GyomuAppsInfoCdtbl, gyomuapps_schema) assert app.application_id == app_loaded.application_id app2 = GyomuAppsInfoCdtbl() app2.application_id = TEST_APPLICAIONT_ID3 app2.description = "Testw Application" user: User = UserFactory.get_current_user() app2.mail_from_name = user.userid app2.mail_from_address = "*****@*****.**" app_list = [app, app2] json_data = Json.to_json(app_list, gyomuapps_total_list_schema) #json_data = gyomuapps_total_list_schema.dumps(app_list) #dictionary = gyomuapps_total_list_schema.loads(json_data=json_data) #assert len(dictionary)==2 app_list_loaded = Json.deserialize(json_data, GyomuAppsInfoCdtbl, gyomuapps_total_list_schema) assert len(app_list_loaded) == 2
def test_insert_app_info(environment_setup): app = GyomuAppsInfoCdtblAccess.get(TEST_APPLICATION_ID2) if app is not None: GyomuAppsInfoCdtblAccess.delete(app) original_apps_count = len(GyomuAppsInfoCdtblAccess.get_all()) app = GyomuAppsInfoCdtbl() app.application_id = TEST_APPLICATION_ID2 app.description = "Test Application" user: User = UserFactory.get_current_user() app.mail_from_name = user.userid app.mail_from_address = "*****@*****.**" GyomuAppsInfoCdtblAccess.add(app) new_apps_count = len(GyomuAppsInfoCdtblAccess.get_all()) assert new_apps_count == (original_apps_count+1) app = GyomuAppsInfoCdtblAccess.get(TEST_APPLICATION_ID2) amend_description="Test2 Application" app.description=amend_description amend_mail_name='dummy' app.mail_from_name=amend_mail_name amend_mail_address='*****@*****.**' app.mail_from_address = amend_mail_address GyomuAppsInfoCdtblAccess.update(app) app = GyomuAppsInfoCdtblAccess.get(TEST_APPLICATION_ID2) assert app.description == amend_description assert app.mail_from_name==amend_mail_name assert app.mail_from_address == amend_mail_address app.application_id= TEST_APPLICAIONT_ID_AMEND GyomuAppsInfoCdtblAccess.update(app, original_application_id=TEST_APPLICATION_ID2) app = GyomuAppsInfoCdtblAccess.get(TEST_APPLICATION_ID2) assert app is None app = GyomuAppsInfoCdtblAccess.get(TEST_APPLICAIONT_ID_AMEND) assert app.application_id == TEST_APPLICAIONT_ID_AMEND GyomuAppsInfoCdtblAccess.delete(app)
def test_gyomu_app_validation(self): app = GyomuAppsInfoCdtbl() app.application_id = TEST_APPLICATION_ID2 app.description = "Test Application" user: User = UserFactory.get_current_user() app.mail_from_name = user.userid app.mail_from_address = "*****@*****.**" json_data = Json.to_json(app, gyomuapps_schema) json_data = '{"mail_from_name": "yoshm", "description": "Test Application", "application_id": "Test", "mail_from_address": "*****@*****.**"}' with pytest.raises(ValidationError) as ve: app2 = Json.deserialize(json_data, GyomuAppsInfoCdtbl, gyomuapps_schema) assert 'application_id' in ve.value.messages json_data = '{"mail_from_name": "yoshma123456789123456789123456789123456789123456789123456789yoshma123456789123456789123456789123456789123456789123456789yoshma123456789123456789123456789123456789123456789123456789yoshma123456789123456789123456789123456789123456789123456789yoshma123456789123456789123456789123456789123456789123456789yoshma123456789123456789123456789123456789123456789123456789", ' \ '"description": "Test Application", "application_id": 32651, "mail_from_address": "*****@*****.**"}' with pytest.raises(ValidationError) as ve: dictionary = gyomuapps_schema.loads(json_data=json_data) assert 'mail_from_name' in ve.value.messages json_data = '{"mail_from_name": "yoshm",' \ ' "description": "Test Application123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789Application123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789", ' \ '"application_id": 32651, "mail_from_address": "*****@*****.**"}' with pytest.raises(ValidationError) as ve: dictionary = gyomuapps_schema.loads(json_data=json_data) assert 'description' in ve.value.messages json_data = '{"mail_from_name": "yoshma123456789123456789123456789123456789123456789123456789yoshma123456789123456789123456789123456789123456789123456789yoshma123456789123456789123456789123456789123456789123456789yoshma123456789123456789123456789123456789123456789123456789yoshma123456789123456789123456789123456789123456789123456789yoshma123456789123456789123456789123456789123456789123456789", ' \ ' "description": "Test Application123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789Application123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789", ' \ '"application_id": 32651, "mail_from_address": "*****@*****.**"}' with pytest.raises(ValidationError) as ve: dictionary = gyomuapps_schema.loads(json_data=json_data) assert 'description' in ve.value.messages assert 'mail_from_name' in ve.value.messages json_data = '{"mail_from_name": "yoshm", "description": "Test Application", "application_id": 35456, "mail_from_address": "Testt.com"}' with pytest.raises(ValidationError) as ve: dictionary = gyomuapps_schema.loads(json_data=json_data) pass assert 'mail_from_address' in ve.value.messages
def application_info_setup(environment_setup): with DbConnectionFactory.get_gyomu_db_session() as session: app2 = session.query(GyomuAppsInfoCdtbl).get(TEST_APPLICATION_ID) if app2 is not None: session.delete(app2) session.commit() app = GyomuAppsInfoCdtbl() app.application_id = TEST_APPLICATION_ID app.description = "Test Application" user: User = UserFactory.get_current_user() app.mail_from_name = user.userid app.mail_from_address = "*****@*****.**" with DbConnectionFactory.get_gyomu_db_session() as session: session.add(app) session.commit() yield TEST_APPLICATION_ID with DbConnectionFactory.get_gyomu_db_session() as session: session.delete(app) session.commit()
def __init__(self, user: User = None, shared_dictionary: dict = None): if user is None: user = UserFactory.get_current_user() self._user = user self.init(shared_dictionary)
def __init__(self, user: User = None): if user is None: user = UserFactory.get_current_user() self._user = user self.init()