コード例 #1
0
 def test_create_request_handler(self):
     nav = CanvasNavigator()
     loc = Location()
     name = "nipytest - unit test - test_create_request_handler"
     controller = canvas_ext.create_http_context_map(nav.current, name)
     # Testing incorrect inputs
     with self.assertRaises(AssertionError):
         canvas_ext.create_request_handler("id", loc, controller, PORT)
         # noinspection PyTypeChecker
         canvas_ext.create_request_handler(nav.current, 1, controller, PORT)
         canvas_ext.create_request_handler(nav.current, loc, 1, PORT)
         # noinspection PyTypeChecker
         canvas_ext.create_request_handler(nav.current, loc, controller,
                                           "string")
     # Run function
     request_handler = canvas_ext.create_request_handler(
         nav.current, loc, controller, PORT)
     # If output is ok type, function was successful
     self.assertIsInstance(request_handler, nifi.ProcessorEntity)
     self.assertEqual(
         request_handler.component.config.properties["Listening Port"],
         str(PORT))
     # Remove temporary created object(s)
     canvas.delete_processor(request_handler, force=True)
     canvas.delete_controller(controller, True)
コード例 #2
0
def test_delete_processor(fixture_processor, regress):
    test_proc = fixture_processor.generate()
    assert test_proc.status.name == config.test_processor_name
    # try to delete running processor
    canvas.schedule_processor(test_proc, 'RUNNING')
    with pytest.raises(ValueError):
        _ = canvas.delete_processor(test_proc)
    canvas.schedule_processor(test_proc, 'STOPPED')
    r = canvas.delete_processor(test_proc)
    assert r.status is None
    # try to delete twice
    with pytest.raises(ValueError):
        _ = canvas.delete_processor(test_proc)
コード例 #3
0
def test_delete_processor(regress_nifi, fix_proc):
    f_p1 = fix_proc.generate()
    r1 = canvas.delete_processor(f_p1)
    assert r1.status is None
    assert isinstance(r1, nifi.ProcessorEntity)
    # try to delete processor twice
    with pytest.raises(ValueError):
        _ = canvas.delete_processor(f_p1)
    # try to delete running processor
    f_p2 = fix_proc.generate()
    canvas.schedule_processor(f_p2, True)
    with pytest.raises(ValueError):
        _ = canvas.delete_processor(f_p2)
    # and once more with feeling, er, force
    r2 = canvas.delete_processor(f_p2, force=True)
    assert r2.status is None
コード例 #4
0
 def test_create_output_router(self):
     nav = CanvasNavigator()
     loc = Location()
     name = "nipytest - unit test - test_create_output_router"
     # Testing incorrect inputs
     with self.assertRaises(AssertionError):
         canvas_ext.create_output_router("id", loc, name)
         # noinspection PyTypeChecker
         canvas_ext.create_output_router(nav.current, 1, name)
         # noinspection PyTypeChecker
         canvas_ext.create_output_router(nav.current, loc, 1)
     # Run function
     output_router = canvas_ext.create_output_router(nav.current, loc, name)
     # If output is ok type, function was successful
     self.assertIsInstance(output_router, nifi.ProcessorEntity)
     self.assertIsNotNone(output_router.component.name, name)
     # Remove temporary created object(s)
     canvas.delete_processor(output_router, force=True)
コード例 #5
0
 def test_create_output_attribute(self):
     nav = CanvasNavigator()
     loc = Location()
     name = "nipytest - unit test - test_create_output_attribute"
     # Testing incorrect inputs
     with self.assertRaises(AssertionError):
         canvas_ext.create_output_attribute("id", loc, name)
         # noinspection PyTypeChecker
         canvas_ext.create_output_attribute(nav.current, 1, name)
         # noinspection PyTypeChecker
         canvas_ext.create_output_attribute(nav.current, loc, 1)
     # Run function
     output_attribute = canvas_ext.create_output_attribute(
         nav.current, loc, name)
     # If output is ok type, function was successful
     self.assertIsInstance(output_attribute, nifi.ProcessorEntity)
     self.assertEqual(output_attribute.component.name,
                      "Set output name '" + name + "'")
     # Remove temporary created object(s)
     canvas.delete_processor(output_attribute)
コード例 #6
0
ファイル: utils.py プロジェクト: ksampson83/edge2ai-workshop
def nifi_delete_all(pg):
    canvas.schedule_process_group(pg.id, False)
    for conn in canvas.list_all_connections(pg.id):
        LOG.debug('Connection: ' + conn.id)
        canvas.delete_connection(conn, purge=True)
    for input_port in canvas.list_all_input_ports(pg.id):
        LOG.debug('Input Port: ' + input_port.id)
        canvas.delete_port(input_port)
    for output_port in canvas.list_all_output_ports(pg.id):
        LOG.debug('Output Port: ' + output_port.id)
        canvas.delete_port(output_port)
    for funnel in canvas.list_all_funnels(pg.id):
        LOG.debug('Funnel: ' + funnel.id)
        canvas.delete_funnel(funnel)
    for processor in canvas.list_all_processors(pg.id):
        LOG.debug('Processor: ' + processor.id)
        canvas.delete_processor(processor, force=True)
    for process_group in canvas.list_all_process_groups(pg.id):
        if pg.id == process_group.id:
            continue
        LOG.debug('Process Group: ' + process_group.id)
        nifi_delete_all(process_group)
        canvas.delete_process_group(process_group, force=True)