summaryrefslogtreecommitdiffstats
path: root/testing/mozbase/mozhttpd/tests/baseurl.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/mozbase/mozhttpd/tests/baseurl.py
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/mozbase/mozhttpd/tests/baseurl.py')
-rw-r--r--testing/mozbase/mozhttpd/tests/baseurl.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/testing/mozbase/mozhttpd/tests/baseurl.py b/testing/mozbase/mozhttpd/tests/baseurl.py
new file mode 100644
index 0000000000..4bf923a8d7
--- /dev/null
+++ b/testing/mozbase/mozhttpd/tests/baseurl.py
@@ -0,0 +1,33 @@
+import mozhttpd
+import mozunit
+import pytest
+
+
+@pytest.fixture(name="httpd")
+def fixture_httpd():
+ """Yields a started MozHttpd server."""
+ httpd = mozhttpd.MozHttpd(port=0)
+ httpd.start(block=False)
+ yield httpd
+ httpd.stop()
+
+
+def test_base_url(httpd):
+ port = httpd.httpd.server_port
+
+ want = "http://127.0.0.1:{}/".format(port)
+ got = httpd.get_url()
+ assert got == want
+
+ want = "http://127.0.0.1:{}/cheezburgers.html".format(port)
+ got = httpd.get_url(path="/cheezburgers.html")
+ assert got == want
+
+
+def test_base_url_when_not_started():
+ httpd = mozhttpd.MozHttpd(port=0)
+ assert httpd.get_url() is None
+
+
+if __name__ == "__main__":
+ mozunit.main()