Project

General

Profile

« Previous | Next » 

Revision 3e4bde86

Added by koszko over 1 year ago

fix test-environment* targets

View differences:

Makefile.in
81 81
		"$(PYTHON)" -m pytest
82 82

  
83 83
test-environment: certs/rootCA.pem certs/site.key
84
	"$(PYTHON)" -m test
84
	unset MOZ_HEADLESS; PYTHONPATH="$$PYTHONPATH:$(srcdir)/test" \
85
		"$(PYTHON)" -m haketilo_test
85 86

  
86 87
test-environment-with-haketilo: certs/rootCA.pem certs/site.key \
87 88
		$(default_target)-build.zip
88
	"$(PYTHON)" -m test --load-haketilo
89
	unset MOZ_HEADLESS; PYTHONPATH="$$PYTHONPATH:$(srcdir)/test" \
90
		"$(PYTHON)" -m haketilo_test --load-haketilo
89 91

  
90 92
# helper targets
91 93
clean mostlyclean:
README.md
116 116

  
117 117
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.
118 118

  
119
### Setting up an environment for manual testing
120

  
121
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:
122
``` python
123
from time import sleep
124
sleep(100000)
125
```
126
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.
127

  
119 128
## Copying
120 129

  
121 130
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.
test/haketilo_test/__main__.py
67 67
driver = firefox_safe_mode(proxy_port=int(port))
68 68

  
69 69
if load_haketilo:
70
    driver.install_addon(str(here.parent / 'mozilla-build.zip'), temporary=True)
70
    driver.install_addon(str(Path.cwd() / 'mozilla-build.zip'), temporary=True)
71 71
    driver.get(get_extension_base_url(driver) + 'html/settings.html')
72 72

  
73 73
print("You can now control the browser through 'driver' object")
test/haketilo_test/misc_constants.py
48 48
default_proxy_host = '127.0.0.1'
49 49
default_proxy_port = 1337
50 50

  
51
default_cert_dir = proj_root / 'test' / 'certs'
51
default_cert_dir = Path.cwd() / 'certs'
52 52

  
53 53
default_extension_uuid = 'a1291446-be95-48ad-a4c6-a475e389399b'
54 54
default_haketilo_id = '{6fe13369-88e9-440f-b837-5012fb3bedec}'
test/haketilo_test/server.py
99 99
        if resp_body:
100 100
            self.wfile.write(resp_body)
101 101

  
102
def do_an_internet(certdir=Path.cwd() / 'certs',
103
                   port=default_proxy_port):
102
def do_an_internet(certdir=default_cert_dir, port=default_proxy_port):
104 103
    """Start up the proxy/server"""
105 104
    class RequestHijackerWithCertdir(RequestHijacker):
106 105
        def __init__(self, *args, **kwargs):

Also available in: Unified diff