Beispiel #1
0
def test_vhost_parse():
    """Tests vhost parse method."""
    vhost = Vhost(DEFAULT_ARGS)
    vhost.data = VHOST_DATA
    assert vhost.parse() == {'htdocs'     : {'path' : '/the/root/dir'},
                             'access_log' : {'path' : '/the/access/log'},
                             'error_log'  : {'path' : '/the/error/log'},
                             'log'        : {'path' : '/the/access'}}
Beispiel #2
0
def test_vhost_init(*args):
    """Tests vhost init method."""
    vhost = Vhost(DEFAULT_ARGS)
    vhost.data = VHOST_DATA
    assert vhost.domain == 'example.com'
    assert vhost.htdocs == '/the/root/dir'
    assert vhost.access_log == '/the/access/log'
    assert vhost.error_log == '/the/error/log'
Beispiel #3
0
def test_vhost_verify(mock_enabled, mock_file_verify):
    """Tests vhost verify method."""
    vhost = Vhost(DEFAULT_ARGS)
    assert vhost.verify()
    mock_enabled.return_value = False
    assert not vhost.verify()
    mock_enabled.return_value = True
    mock_file_verify.return_value = False
    assert not vhost.verify()
Beispiel #4
0
def test_vhost_parse_with_prompts():
    """Tests vhost parse method with prompts."""
    vhost = Vhost(DEFAULT_ARGS)
    vhost.data = ''
    with patch(_INPUT, return_value='/a/sample/dir'):
        assert vhost.parse() == {'htdocs'     : {'path' : '/a/sample/dir'},
                                 'access_log' : {'path' : '/a/sample/dir'},
                                 'error_log'  : {'path' : '/a/sample/dir'},
                                 'log'        : {'path' : '/a/sample'}}
    assert vhost.htdocs == '/a/sample/dir'
    assert vhost.access_log == '/a/sample/dir'
    assert vhost.error_log == '/a/sample/dir'
Beispiel #5
0
def test_vhost_enable(*args):
    """Test vhost enable method."""
    vhost = Vhost(DEFAULT_ARGS)
    assert vhost.enable(False)
Beispiel #6
0
def test_vhost_create(mock_enable, mock_create):
    """Tests vhost create method."""
    vhost = Vhost(DEFAULT_ARGS)
    vhost.create()
    mock_create.assert_called_once_with()
    mock_enable.assert_called_once_with()
Beispiel #7
0
def test_vhost_disable(_):
    """Tests vhost disble method."""
    vhost = Vhost(DEFAULT_ARGS)
    assert vhost.disable(False)