summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-02-17 16:05:20 +0100
committerWojtek Kosior <koszko@koszko.org>2022-02-17 16:09:57 +0100
commit3e4bde861cdee3312e1d410dc08f67d8e7c9168c (patch)
tree2b3da5e016a7354410d9003a96923d5e1a0c3347
parent753fd58a5778b634dcc9849d3ecb3fb5feb62154 (diff)
downloadbrowser-extension-3e4bde861cdee3312e1d410dc08f67d8e7c9168c.tar.gz
browser-extension-3e4bde861cdee3312e1d410dc08f67d8e7c9168c.zip
fix test-environment* targets
-rw-r--r--Makefile.in6
-rw-r--r--README.md9
-rw-r--r--test/haketilo_test/__main__.py2
-rw-r--r--test/haketilo_test/misc_constants.py2
-rwxr-xr-xtest/haketilo_test/server.py3
5 files changed, 16 insertions, 6 deletions
diff --git a/Makefile.in b/Makefile.in
index b9888ba..3c4293a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -81,11 +81,13 @@ test: test-prepare
"$(PYTHON)" -m pytest
test-environment: certs/rootCA.pem certs/site.key
- "$(PYTHON)" -m test
+ unset MOZ_HEADLESS; PYTHONPATH="$$PYTHONPATH:$(srcdir)/test" \
+ "$(PYTHON)" -m haketilo_test
test-environment-with-haketilo: certs/rootCA.pem certs/site.key \
$(default_target)-build.zip
- "$(PYTHON)" -m test --load-haketilo
+ unset MOZ_HEADLESS; PYTHONPATH="$$PYTHONPATH:$(srcdir)/test" \
+ "$(PYTHON)" -m haketilo_test --load-haketilo
# helper targets
clean mostlyclean:
diff --git a/README.md b/README.md
index c122dd3..888990c 100644
--- a/README.md
+++ b/README.md
@@ -116,6 +116,15 @@ python3 -m pytest -vv -k popup
As of Haketilo 1.0-beta1 some tests may spuriously fail. This is the result it being notoriously difficult to avoid some weirdnesses when driving Firefox using Selenium. To make sure a failed test is not the result of some more serious bug, you might want to rerun the test suite.
+### Setting up an environment for manual testing
+
+The automated tests are run with browser's all network requests going through a Python proxy. The proxy allows us to mock websites that are then navigated to in the browser. At times you might want to replicate this test environment while playing manually with the browser. A poor man's approach is to add something like:
+``` python
+from time import sleep
+sleep(100000)
+```
+inside one of the test functions and then run that test function from Pytest (with `MOZ_HEADLESS` unset!). This might make sense when debugging some particular test case. For general experiments we have instead provided convenience targets `make test-environment` and `make test-environment-with-haketilo`. Running any of those will spawn a browser window *together* with a Python shell where `driver` variable will hold Selenium driver object controlling that browser. In case of the `test-environment-with-haketilo` target the browser will additionally appear with Haketilo loaded into it.
+
## Copying
All copyright information is gathered in the `copyright` file which follows the [format of debian/copyright file](https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/). License notices are also present in all text files of the extension.
diff --git a/test/haketilo_test/__main__.py b/test/haketilo_test/__main__.py
index 7afda55..3664e8c 100644
--- a/test/haketilo_test/__main__.py
+++ b/test/haketilo_test/__main__.py
@@ -67,7 +67,7 @@ httpd = do_an_internet(certdir, int(port))
driver = firefox_safe_mode(proxy_port=int(port))
if load_haketilo:
- driver.install_addon(str(here.parent / 'mozilla-build.zip'), temporary=True)
+ driver.install_addon(str(Path.cwd() / 'mozilla-build.zip'), temporary=True)
driver.get(get_extension_base_url(driver) + 'html/settings.html')
print("You can now control the browser through 'driver' object")
diff --git a/test/haketilo_test/misc_constants.py b/test/haketilo_test/misc_constants.py
index 9cac9dc..ac34f32 100644
--- a/test/haketilo_test/misc_constants.py
+++ b/test/haketilo_test/misc_constants.py
@@ -48,7 +48,7 @@ with open(Path.cwd() / 'record.conf', 'rt') as conf:
default_proxy_host = '127.0.0.1'
default_proxy_port = 1337
-default_cert_dir = proj_root / 'test' / 'certs'
+default_cert_dir = Path.cwd() / 'certs'
default_extension_uuid = 'a1291446-be95-48ad-a4c6-a475e389399b'
default_haketilo_id = '{6fe13369-88e9-440f-b837-5012fb3bedec}'
diff --git a/test/haketilo_test/server.py b/test/haketilo_test/server.py
index 7dc5e9e..0963b5b 100755
--- a/test/haketilo_test/server.py
+++ b/test/haketilo_test/server.py
@@ -99,8 +99,7 @@ class RequestHijacker(ProxyRequestHandler):
if resp_body:
self.wfile.write(resp_body)
-def do_an_internet(certdir=Path.cwd() / 'certs',
- port=default_proxy_port):
+def do_an_internet(certdir=default_cert_dir, port=default_proxy_port):
"""Start up the proxy/server"""
class RequestHijackerWithCertdir(RequestHijacker):
def __init__(self, *args, **kwargs):