Exemplo n.º 1
0
    def diagnose(self):
        """Run diagnostics and return the results."""
        results = super().diagnose()
        results.append(daemon.diagnose_port_listening(8000, 'tcp4'))
        results.extend(
            diagnose_url_on_all('http://{host}/plinth/',
                                check_certificate=False))

        return results
Exemplo n.º 2
0
def test_diagnose_url(get_addresses, check):
    """Test diagnosing a URL."""
    args = {
        'url': 'https://localhost/test',
        'kind': '4',
        'env': {
            'test': 'value'
        },
        'check_certificate': False,
        'extra_options': {
            'test-1': 'value-1'
        },
        'wrapper': 'test-wrapper',
        'expected_output': 'test-expected'
    }
    check.return_value = 'passed'
    result = diagnose_url(**args)
    assert result == ['Access URL https://localhost/test on tcp4', 'passed']

    check.return_value = 'failed'
    result = diagnose_url(**args)
    assert result == ['Access URL https://localhost/test on tcp4', 'failed']

    del args['kind']
    args['url'] = 'https://{host}/test'
    check.return_value = 'passed'
    get_addresses.return_value = [{
        'kind': '4',
        'address': 'test-host-1',
        'numeric': False,
        'url_address': 'test-host-1'
    }, {
        'kind': '6',
        'address': 'test-host-2',
        'numeric': False,
        'url_address': 'test-host-2'
    }]
    result = diagnose_url_on_all(**args)
    assert result == [
        ['Access URL https://test-host-1/test on tcp4', 'passed'],
        ['Access URL https://test-host-2/test on tcp6', 'passed'],
    ]