From bc5cddb5ee78cb5566dc47de7dabf7318e2953bb Mon Sep 17 00:00:00 2001 From: Naomi Date: Wed, 26 Sep 2018 16:18:57 +0100 Subject: [PATCH] Added some documentation --- README.md | 5 +++++ ojusomap/tests.py | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 88e40c9..ad685a4 100644 --- a/README.md +++ b/README.md @@ -195,12 +195,17 @@ $ python manage.py runserver # Running The Tests +You will need to install chromedriver, and if you want to test in Firefox (see comments in `ojusomap/tests.py`) you will also need to install geckodriver. To install either of these you need to download the zip file for your architecture from http://chromedriver.chromium.org/downloads or https://github.com/mozilla/geckodriver/releases and unzip it into a place on your `PATH`. Each zip just contains a single binary, so it is very straightforward. + ```bash + $ pip install -r requirements-test.txt $ python manage.py collectstatic $ pytest -v ``` +NB. The "map" tests use selenium with chrome driver, but in headless mode so that they can run in GitLab CI. If you want to see them running, you can comment out the relevant line in `ojusomap/tests.py` (search for "headless") + # Troubleshooting Sometimes, you see crashes like the following with `psycopg`: diff --git a/ojusomap/tests.py b/ojusomap/tests.py index 39865f5..6819de8 100644 --- a/ojusomap/tests.py +++ b/ojusomap/tests.py @@ -22,8 +22,16 @@ TIMEOUT = 8 class SeleniumTest(LiveServerTestCase): @classmethod def setUpClass(cls): + ### To test with firefox, uncomment these lines and comment those pertaining + ### to Chrome. However, it will not work with GitLab CI because the docker + ### container does not have the geckodriver installed. + # profile = webdriver.FirefoxProfile() + # profile.set_preference("dom.forms.number", False) + # cls.sl = webdriver.Firefox(profile) chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--no-sandbox') + # comment out this next line in order to see the tests running in a browser. + # But be sure to put it back before comitting, or gitlab CI will fail. chrome_options.add_argument('--headless') chrome_options.add_argument('--disable-gpu') cls.sl = webdriver.Chrome(chrome_options=chrome_options)