mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
- Done automatically by running isort . in top level directory. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
Test module for (U)ser (Web) (S)ites.
|
|
"""
|
|
|
|
from plinth.modules.apache import (user_of_uws_directory, user_of_uws_url,
|
|
uws_directory_of_url, uws_directory_of_user,
|
|
uws_url_of_directory, uws_url_of_user)
|
|
|
|
|
|
def test_uws_namings():
|
|
"""Test name solvers for user, url and directory of UWS."""
|
|
|
|
assert '/home/usr/public_html' == uws_directory_of_user('usr')
|
|
assert '/~usr/' == uws_url_of_user('usr')
|
|
|
|
f = user_of_uws_directory
|
|
assert f('/home/usr/lacks/the/UWS/directory') is None
|
|
assert 'usr' == f('/home/usr/public_html/is/a/normal/UWS/file')
|
|
assert 'usr' == f('/home/usr/public_html/is/a/normal/UWS/path/')
|
|
assert '€.;#@|' == f('/home/€.;#@|/public_html/is/stange/but/valid/')
|
|
|
|
f = user_of_uws_url
|
|
assert f('/usr/is/not/a/valid/UWS/url/due/to/missing/tilde') is None
|
|
assert 'usr' == f('whatever/~usr/is/considered/a/valid/UWS/path')
|
|
assert 'usr' == f('~usr')
|
|
assert 'usr' == f('~usr/')
|
|
assert 'usr' == f('/~usr/')
|
|
|
|
assert '/home/usr/public_html' == uws_directory_of_url('~usr/any/file')
|
|
assert '/~usr/' == uws_url_of_directory('/home/usr/public_html/any/file')
|