def test_manager_connector_clean(self): self.test_manager_update_connector() res = ManagerHelper.run(PageModel.connection, PageModelMode.clean, 1) self.assertEqual(res.success, True) res = ManagerHelper.run(PageModel.connection, PageModelMode.clean, 2) self.assertEqual(res.success, True) c = self.session.query(Transform).count() self.assertEqual(c, 0)
def test_manager_list(self): con = self.init_test_connector(typ=FlinkConnectorType.hive, c_type=ConnectorType.system) res = ManagerHelper.run(PageModel.connection, PageModelMode.update, con.source.id) self.assertEqual(res.success, True) res = ManagerHelper.run(PageModel.connector, PageModelMode.list, con.id) self.assertEqual(res.success, True)
def test_manager_connection_clean(self): self.test_manager_update_connection() res = ManagerHelper.run(PageModel.connection, PageModelMode.clean, 1) self.assertEqual(res.success, True) self.assertEqual(self.session.query(ResourceVersion).count(), 0) self.assertEqual(self.session.query(ResourceTemplate).count(), 0) self.assertEqual(self.session.query(ResourceName).count(), 0)
def test_manager_update_connector(self): connector = self.init_test_connector() res = ManagerHelper.run(PageModel.connector, PageModelMode.update, connector.id) print(res.msg) self.assertEqual(res.success, True) c = self.session.query(ResourceVersion).join( ResourceVersion.connection).filter( Connection.id == connector.target.id).count() self.assertTrue(c > 0)
def update_test_connection(self, url, typ, connector='', include='fsqlfly\..*'): con = Connection(name='fake', url=url, type=typ, connector=connector, include=include) self.session.add(con) self.session.commit() res = ManagerHelper.run(PageModel.connection, PageModelMode.update, con.id) self.assertTrue(res.success)
def post(self, model: str, mode: str, pk: str): return self.write_res(ManagerHelper.run(model, mode, pk))
def test_manager_init_not_support(self): con = self.init_test_connection() res = ManagerHelper.run(PageModel.connection, PageModelMode.init, con.id) self.assertEqual(res.success, False)
def test_manager_update_connector_with_hive_fail(self): connector = self.init_test_connector(FlinkConnectorType.hive) res = ManagerHelper.run(PageModel.connector, PageModelMode.update, connector.id) self.assertEqual(res.success, False)
def test_manager_update_connection(self): con = self.init_test_connection() res = ManagerHelper.run(PageModel.connection, PageModelMode.update, con.id) print(res.msg) self.assertEqual(res.success, True)
def test_manager_helper_mode_not_support(self): con = self.init_test_connection() with self.assertRaises(NotImplementedError): self.assertEqual( ManagerHelper.run(PageModel.connection, 'fake-mode', con.id).success, False)
def test_manager_helper_with_api_error(self): self.assertEqual( ManagerHelper.run(PageModel.connector, 'fake-mode', '1').success, False)