Here are the examples of the python api pytest_twisted.inlineCallbacks taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

145 Examples 7

3 Source File : test_onu_tcont.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_remove_onu_tcont_to_hardware(tcont_fixture):
    with mock.patch("voltha.extensions.omci.omci_cc") as omci:
        tcont_fixture._is_mock = False
        tcont_fixture._entity_id = 2048
        yield tcont_fixture.remove_from_hardware(omci)
        omci.send.assert_called_once()
				 
			
3 Source File : test_onu_tcont.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_add_onu_tcont_to_hardware(tcont_fixture):
    with mock.patch("voltha.extensions.omci.omci_cc") as omci:
        tcont_fixture._is_mock = False
        yield tcont_fixture.add_to_hardware(omci, EXAMPLE_TCONT_ENTITY_ID, tcont_fixture.alloc_id)
        assert tcont_fixture._free_alloc_id == tcont_fixture.alloc_id
        omci.send.assert_called_once()
				 
			
3 Source File : test_adtran_rest.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_404_on_post(test_client, mock_treq):
    mock_treq.post.side_effect = [MockResponse(404)]
    with pytest.raises(RestInvalidResponseCode,
                       message="REST POST '' request to 'http://1.2.3.4:80/test/uri' failed with status code 404"):
        yield test_client.request("POST", "/test/uri", SOME_JSON)
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_declare_binding_failure():
    """Assert that if a binding can't be declared, it results in an exception."""
    serv = service.FedoraMessagingService(amqp_url="amqp://")
    serv.startService()
    client = yield serv.getFactory().whenConnected()

    binding = [
        {"exchange": str(uuid.uuid4()), "queue": str(uuid.uuid4()), "routing_key": "#"}
    ]
    try:
        yield client.bind_queues(binding)
    except exceptions.BadDeclaration as e:
        assert "binding" == e.obj_type
        assert binding[0] == e.description
        assert isinstance(e.reason, pika.exceptions.ChannelClosed)
    yield serv.stopService()
				 
			
3 Source File : test_adtran_rest.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_good_request(test_client, mock_treq):
    mock_resp = MockResponse(200)
    mock_treq.post.side_effect = [mock_resp]
    mock_resp.headers.hasHeader.return_value = True
    mock_resp.headers.getRawHeaders.return_value = ['application/json']
    mock_resp.content.return_value = """{"other": "json"}"""
    output = yield test_client.request("POST", "/test/uri", SOME_JSON)
    assert output == {"other": "json"}
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_declare_exchange_failures():
    """Assert that if an exchange can't be declared, it results in an exception."""
    serv = service.FedoraMessagingService(amqp_url="amqp://")
    serv.startService()
    client = yield serv.getFactory().whenConnected()

    exchanges = [{"exchange": str(uuid.uuid4()), "passive": True}]
    try:
        yield client.declare_exchanges(exchanges)
    except exceptions.BadDeclaration as e:
        assert "exchange" == e.obj_type
        assert exchanges[0] == e.description
        assert isinstance(e.reason, pika.exceptions.ChannelClosed)
    yield serv.stopService()
				 
			
3 Source File : test_adtran_netconf.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_edit_config_with_any_exception(test_client):
    test_client._session = mock.MagicMock()
    test_client._session.edit_config.side_effect = SyntaxError()
    with pytest.raises(SyntaxError):
        yield test_client.edit_config("<config")
				 
			
3 Source File : test_adtran_netconf.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_close(test_client):
    mock_session = mock.MagicMock()
    test_client._session = mock_session
    mock_session.connected = True
    yield test_client.close()
    mock_session.close_session.assert_called_once_with()
				 
			
3 Source File : test_adtran_netconf.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_rpc(test_client):
    test_client._session = mock.MagicMock()
    with mock.patch("voltha.adapters.adtran_olt.net.adtran_netconf.etree") as mock_etree:
        yield test_client.rpc("<rpc>xml</rpc>")
        mock_etree.fromstring.assert_called_once_with("<rpc>xml</rpc>")
				 
			
3 Source File : test_onu_tcont.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_add_onu_tcont_to_hardware_exception(tcont_fixture):
    with mock.patch("voltha.extensions.omci.omci_cc") as omci:
        tcont_fixture._is_mock = False
        tcont_fixture.alloc_id = "some bad value"
        with pytest.raises(Exception):
            yield tcont_fixture.add_to_hardware(omci, EXAMPLE_TCONT_ENTITY_ID, tcont_fixture.alloc_id)
				 
			
3 Source File : test_onu_gem_port.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_remove_from_hardware_isMock():
    """
    verify call to remove hardware when isMock = True
    """
    _isMock = True

    mock_handler = MagicMock()
    mock_handler.device_id = MOCK_HANDLER_DEVICE_ID

    ogp = OnuGemPort(mock_handler, GEM_DATA, ALLOCID, TECHPROFILEID, UNIID, ENTITYID, MULTICAST, TRAFFICCLASS,
                     _isMock)

    result = yield ogp.remove_from_hardware('fake')
    assert result == 'mock'
				 
			
3 Source File : test_olt_gem_port.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_add_to_hardware_ismock():
    """
    verify call to add hardware when isMock = True
    """

    _isMock = True

    ogp = OltGemPort(GEMID, ALLOCID, TECHPROFILEID, PONID, ONUID, UNIID, ENCRYPTION, MULTICAST, TRAFFICCLASS,
                     HANDLER, _isMock)

    result = yield ogp.add_to_hardware('session')
    assert result == 'mock'
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_consume_successful_halt():
    """Assert consume halts when all consumer.result deferreds have succeeded."""
    consumers = [consumer.Consumer()]
    consumers[0].result = defer.succeed(None)
    try:
        with mock.patch("fedora_messaging.api.twisted_consume") as mock_consume:
            mock_consume.return_value = defer.succeed(consumers)
            d = threads.deferToThread(api.consume, None)
            protocol._add_timeout(d, 0.1)
            yield d
    except (defer.TimeoutError, defer.CancelledError):
        pytest.fail("Expected the consume call to immediately finish, not time out")
				 
			
3 Source File : test_adtran_netconf.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_reconnect_ignore_errors(test_client):
    with mock.patch.object(test_client, "connect") as mock_connect:
        with mock.patch.object(test_client, "close") as mock_close:
            mock_connect.side_effect = SyntaxError()
            mock_close.side_effect = SyntaxError()
            yield test_client._reconnect()
            mock_connect.assert_called_once()
            mock_close.assert_called_once()
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_declare_queue_failures():
    """Assert that if a queue can't be declared, it results in an exception."""
    serv = service.FedoraMessagingService(amqp_url="amqp://")
    serv.startService()
    client = yield serv.getFactory().whenConnected()

    queues = [{"queue": str(uuid.uuid4()), "passive": True}]
    try:
        yield client.declare_queues(queues)
    except exceptions.BadDeclaration as e:
        assert "queue" == e.obj_type
        assert queues[0] == e.description
        assert isinstance(e.reason, pika.exceptions.ChannelClosed)
    yield serv.stopService()
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_make_rest_connection(simple_handler):
    with mock.patch('voltha.adapters.adtran_olt.net.adtran_rest.AdtranRestClient.request',
                    return_value={'module-info': {}}) as request:
        yield simple_handler.make_restconf_connection()
        request.assert_called_once_with('GET', simple_handler.HELLO_URI, name='hello', timeout=simple_handler.timeout)
        assert isinstance(simple_handler.rest_client, AdtranRestClient)
				 
			
3 Source File : test_adtran_netconf.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_edit_config_session_not_connected(test_client):
    test_client._session = mock.MagicMock()
    test_client._session.connected = False
    with mock.patch.object(test_client, "_reconnect") as mock_reconnect:
        yield test_client.edit_config("<some>config</some>")
        mock_reconnect.assert_called_once()
				 
			
3 Source File : test_adtran_netconf.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_get_session_not_connected(test_client):
    test_client._session = mock.MagicMock()
    test_client._session.connected = False
    with mock.patch.object(test_client, "_reconnect") as mock_reconnect:
        yield test_client.get("<get>xml</get>")
        mock_reconnect.assert_called_once()
				 
			
3 Source File : test_adtran_netconf.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_close_not_connected(test_client):
    mock_session = mock.MagicMock()
    test_client._session = mock_session
    mock_session.connected = False
    output = yield test_client.close()
    assert output
				 
			
3 Source File : test_adtran_netconf.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_get_config_session_not_connected(test_client):
    test_client._session = mock.MagicMock()
    test_client._session.connected = False
    with mock.patch.object(test_client, "_reconnect") as mock_reconnect:
        yield test_client.get_config()
        mock_reconnect.assert_called_once()
				 
			
3 Source File : test_adtran_netconf.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_rpc_session_reconnect(test_client):
    test_client._session = mock.MagicMock()
    test_client._session.connected = False
    with mock.patch.object(test_client, "_reconnect") as mock_reconnect:
        yield test_client.rpc("<rpc>xml</rpc>")
        mock_reconnect.assert_called_once()
				 
			
3 Source File : test_adtran_netconf.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_edit_config_with_config_at_start_of_xml(test_client):
    test_client._session = mock.MagicMock()
    test_client._session.edit_config.return_value = "<ok>"
    yield test_client.edit_config("<config")
    test_client._session.edit_config.assert_called_once_with(target="running", config="<config")
				 
			
3 Source File : test_adtran_netconf.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_reconnect(test_client):
    with mock.patch.object(test_client, "connect") as mock_connect:
        with mock.patch.object(test_client, "close") as mock_close:
            yield test_client._reconnect()
            mock_connect.assert_called_once()
            mock_close.assert_called_once()
				 
			
3 Source File : test_onu_gem_port.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_add_to_hardware_isMock():
    """
    verify call to add hardware when isMock = True
    """
    _isMock = True

    mock_handler = MagicMock()
    mock_handler.device_id = MOCK_HANDLER_DEVICE_ID

    ogp = OnuGemPort(mock_handler, GEM_DATA, ALLOCID, TECHPROFILEID, UNIID, ENTITYID, MULTICAST, TRAFFICCLASS,
                     _isMock)

    result = yield ogp.add_to_hardware('fake', 'fake', 'fake', 'fake')
    assert result == 'mock'
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_disable(simple_handler, device):
    device.oper_status = OperStatus.ACTIVE
    simple_handler.logical_device_id = 1234
    yield simple_handler.disable()
    assert device.oper_status == OperStatus.UNKNOWN
				 
			
			 
			     @mark.parametrize("install_by_delete", [True, False])
@pytest_twisted.inlineCallbacks
def test_perform_flow_install(flow_task, install_by_delete, mock_res):
    flow_task.check_status_and_state = Mock()
    flow_task._onu_device.omci_cc.send = Mock()
    flow_task._install_by_delete = install_by_delete
    flow_task._onu_device.omci_cc.send.return_value = 'test'
    yield flow_task.perform_flow_install()
    if install_by_delete:
        flow_task.check_status_and_state.assert_any_call('test', operation='delete')
        flow_task.check_status_and_state.assert_any_call('test', 'flow-recreate-before-set')
    flow_task.check_status_and_state.assert_any_call('test', 'set-extended-vlan-tagging-operation-configuration-data')
    flow_task.check_status_and_state.assert_any_call('test', 'flow-set-ext-vlan-tagging-op-config-data-untagged')
				 
			
3 Source File : test_olt_gem_port.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_remove_from_hardware_ismock():
    """
    verify call to remove hardware when isMock = True
    """

    _isMock = True

    ogp = OltGemPort(GEMID, ALLOCID, TECHPROFILEID, PONID, ONUID, UNIID, ENCRYPTION, MULTICAST, TRAFFICCLASS, HANDLER,
                     _isMock)

    result = yield ogp.remove_from_hardware('session')
    assert result == 'mock'
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_pub_timeout():
    """Assert PublishTimeout is raised if a connection just hangs."""
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.bind(("", 0))
    config.conf["amqp_url"] = "amqp://localhost:{port}/".format(
        port=sock.getsockname()[1]
    )

    try:
        yield threads.deferToThread(api.publish, api.Message(), 5)
    except Exception as e:
        if not isinstance(e, exceptions.PublishTimeout):
            pytest.fail("Expected a timeout exception, not {}".format(e))
    finally:
        sock.close()
    # Ensure the deferred has been renewed
    assert api._twisted_service._service.factory.when_connected().called is False
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_make_netconf_connection(simple_handler):
    AdtranDeviceHandler.NC_CLIENT = AdtranNetconfClient
    with mock.patch('voltha.adapters.adtran_olt.net.adtran_netconf.AdtranNetconfClient.connect'):
        yield simple_handler.make_netconf_connection()
        assert isinstance(simple_handler.netconf_client, AdtranNetconfClient)
        first_client = simple_handler.netconf_client

        yield simple_handler.make_netconf_connection(close_existing_client=True)
        assert isinstance(simple_handler.netconf_client, AdtranNetconfClient)
        assert first_client is not simple_handler.netconf_client
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_consume_unexpected_crash():
    """Assert unexpected exceptions raised inside the Twisted thread are raised."""
    try:
        with mock.patch("fedora_messaging.api._check_callback") as mock_check:
            mock_check.side_effect = RuntimeError("Beep boop you messed up")
            yield threads.deferToThread(api.consume, None)
        pytest.fail("Expected a RuntimeException to be raised")
    except RuntimeError as e:
        assert e.args[0] == "Beep boop you messed up"
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_finish_reboot(simple_handler, device):
    device.oper_status = OperStatus.ACTIVATING
    device.connect_status = ConnectStatus.UNREACHABLE
    yield simple_handler._finish_reboot(0, OperStatus.ACTIVE, ConnectStatus.REACHABLE)
    simple_handler._cancel_tasks()
    assert device.oper_status == OperStatus.ACTIVE
    assert device.connect_status == ConnectStatus.REACHABLE
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_protocol_publish_connection_error(queue_and_binding):
    """Assert individual protocols raise connection exceptions if closed."""
    api._init_twisted_service()
    protocol = yield api._twisted_service._service.factory.when_connected()
    yield protocol.close()
    try:
        yield protocol.publish(message.Message(), "amq.topic")
        pytest.fail("Expected a ConnectionException")
    except exceptions.ConnectionException:
        pass
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_make_rest_connection_bad_response(simple_handler):
    with mock.patch('voltha.adapters.adtran_olt.net.adtran_rest.AdtranRestClient.request',
                    return_value={}):
        with pytest.raises(ConnectError):
            yield simple_handler.make_restconf_connection()
        assert simple_handler.rest_client is None
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_check_confirms():
    """Assert confirmations are enabled by default."""
    serv = service.FedoraMessagingService(amqp_url="amqp://")
    serv.startService()
    client = yield serv.getFactory().whenConnected()
    channel = yield client._allocate_channel()
    assert channel._delivery_confirmation is True
    serv.stopService()
				 
			
3 Source File : test_onu_tcont.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_add_mock_onu_tcont_to_hardware(tcont_fixture):
    with mock.patch("voltha.extensions.omci.omci_cc") as omci:
        tcont_fixture._is_mock = True
        tcont_fixture._handler.device_id = EXAMPLE_DEVICE_ID
        output = yield tcont_fixture.add_to_hardware(omci, tcont_fixture.FREE_TCONT_ALLOC_ID, tcont_fixture.alloc_id)
        assert output == "mock"
				 
			
3 Source File : test_onu_tcont.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_remove_onu_tcont_from_hardware_exception(tcont_fixture):
    with mock.patch("voltha.extensions.omci.omci_cc") as omci:
        tcont_fixture._is_mock = False
        omci.send.side_effect = Exception
        with pytest.raises(Exception):
            yield tcont_fixture.remove_from_hardware(omci)
				 
			
3 Source File : test_adtran_rest.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_no_headers(test_client, mock_treq):
    mock_resp = MockResponse(200)
    mock_treq.post.side_effect = [mock_resp]
    mock_resp.headers.hasHeader.return_value = False
    with pytest.raises(Exception):
        yield test_client.request("POST", "/test/uri", SOME_JSON)
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_delete(simple_handler, device):
    device.oper_status = OperStatus.ACTIVE
    simple_handler.logical_device_id = 1234
    yield simple_handler.delete()
    assert device.reason == 'Deleting'
				 
			
3 Source File : test_onu_tcont.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_add_onu_tcont_to_hardware_default_id(tcont_fixture):
    with mock.patch("voltha.extensions.omci.omci_cc") as omci:
        tcont_fixture._is_mock = False
        yield tcont_fixture.add_to_hardware(omci, EXAMPLE_TCONT_ENTITY_ID)
        assert tcont_fixture._free_alloc_id == tcont_fixture.FREE_TCONT_ALLOC_ID
        omci.send.assert_called_once()
				 
			
3 Source File : test_adtran_netconf.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_edit_config_without_config_at_start_of_xml(test_client):
    test_client._session = mock.MagicMock()
    test_client._session.edit_config.return_value = "<ok>"
    yield test_client.edit_config("")
    test_client._session.edit_config.assert_called_once_with(
        target="running",
        config='<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"></config>')
				 
			
3 Source File : test_adtran_netconf.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_edit_config_session_reconnect_causes_exception(test_client):
    test_client._session = mock.MagicMock()
    test_client._session.connected = False
    with mock.patch.object(test_client, "_reconnect") as mock_reconnect:
        mock_reconnect.side_effect = SyntaxError()
        yield test_client.edit_config("<some>config</some>")
        mock_reconnect.assert_called_once()
				 
			
			 
			     @pytest.mark.twisted
@pytest_twisted.inlineCallbacks
def test_should_mark_as_up_when_transitioning_from_down_to_up(plugin):
    plugin._currently_down = Mock(return_value=True)
    plugin._currently_down.__name__ = '_currently_down'
    plugin.agent.walk.return_value = defer.succeed(True)
    plugin._mark_as_up = Mock()
    plugin._mark_as_down = Mock()
    yield plugin.handle()
    plugin._mark_as_down.assert_not_called()
    plugin._mark_as_up.assert_called()
				 
			
3 Source File : test_onu_tcont.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_already_assigned_onu_tcont_to_hardware(tcont_fixture):
    with mock.patch("voltha.extensions.omci.omci_cc") as omci:
        tcont_fixture._is_mock = False
        tcont_fixture._entity_id = 1234
        with pytest.raises(KeyError):
            yield tcont_fixture.add_to_hardware(omci, EXAMPLE_TCONT_ENTITY_ID, tcont_fixture.alloc_id)
				 
			
3 Source File : test_adtran_netconf.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_edit_config_with_any_exception_ignore_errors(test_client):
    test_client._session = mock.MagicMock()
    test_client._session.edit_config.side_effect = SyntaxError()
    output = yield test_client.edit_config('operation="delete"', ignore_delete_error=True)
    assert output == 'ignoring-delete-error'
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_vmware_resource_async_render_GET_errback():
    request = mock.Mock()
    request.args = {
        b'vsphere_host': [b'127.0.0.1'],
    }

    args = mock.Mock()
    args.config_file = None

    resource = VMWareMetricsResource(args)

    with mock.patch('vmware_exporter.vmware_exporter.VmwareCollector') as Collector:
        Collector.return_value.collect.side_effect = RuntimeError('Test exception')
        yield resource._async_render_GET(request)

    request.setResponseCode.assert_called_with(500)
    request.write.assert_called_with(b'# Collection failed')
    request.finish.assert_called_with()
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_vmware_resource_async_render_GET_no_target():
    request = mock.Mock()
    request.args = {
    }

    args = mock.Mock()
    args.config_file = None

    resource = VMWareMetricsResource(args)

    with mock.patch('vmware_exporter.vmware_exporter.VmwareCollector'):
        yield resource._async_render_GET(request)

    request.setResponseCode.assert_called_with(500)
    request.write.assert_called_with(b'No vsphere_host or target defined!\n')
    request.finish.assert_called_with()
				 
			
3 Source File : test_onu_tcont.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_remove_mock_onu_tcont_from_hardware(tcont_fixture):
    with mock.patch("voltha.extensions.omci.omci_cc") as omci:
        tcont_fixture._is_mock = True
        output = yield tcont_fixture.remove_from_hardware(omci)
        assert output == "mock"
				 
			
3 Source File : test_onu_tcont.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_entity_already_set_onu_tcont_to_hardware(tcont_fixture):
    with mock.patch("voltha.extensions.omci.omci_cc") as omci:
        tcont_fixture._is_mock = False
        output = yield tcont_fixture.add_to_hardware(omci, tcont_fixture.entity_id, tcont_fixture.alloc_id)
        assert output == "Already set"
				 
			
3 Source File : test_adtran_rest.py , under Apache License 2.0 , by opencord
			 
			     @pytest_twisted.inlineCallbacks
def test_bad_json(test_client, mock_treq):
    mock_resp = MockResponse(200)
    mock_treq.post.side_effect = [mock_resp]
    mock_resp.headers.hasHeader.return_value = True
    mock_resp.headers.getRawHeaders.return_value = ['application/json']
    mock_resp.content.return_value = """{"other": "json}"""
    with pytest.raises(ValueError):
        yield test_client.request("POST", "/test/uri", SOME_JSON)
				 
			
			 
			     @pytest_twisted.inlineCallbacks
def test_reboot(simple_handler, device):
    device.oper_status = OperStatus.ACTIVE
    device.connect_status = ConnectStatus.REACHABLE
    simple_handler._initial_enable_complete = True
    yield simple_handler.make_netconf_connection()
    yield simple_handler.reboot()
    simple_handler._cancel_tasks()
    assert device.oper_status == OperStatus.ACTIVATING
    assert device.connect_status == ConnectStatus.UNREACHABLE