Commit Graph

32 Commits

Author SHA1 Message Date
Rebecca Law
0bd844a961 Update puralisation 2019-09-25 16:09:36 +01:00
Rebecca Law
d902ac3b44 Added the url for api docs.
Updated error message when js tests fail
2019-09-25 15:47:35 +01:00
Chris Hill-Scott
1a353d90eb Create the app once per run, not once per test
Turns out our tests spent a lot of time recreating the app for each test
case, which is quite intense.

This commit makes the fixture sessions level, so the app is only created
once per test session, not once per test function.

This cuts down the time taken to run the test suite to about 50 seconds.

It also makes the tests more parallelizable. Before this change going
from 4 to 8 processes made the tests slower. Now it cuts them down from
about 50 seconds to about 35 seconds[1]. So this commit also lets Pytest
choose the best number of processes to run, since on my machine it
chooses 8, which is the fastest.

Overall this means the

1. With a 2.2GHz quad-core Intel Core i7 processor on a 2015 MacBook Pro
2019-09-18 15:58:25 +01:00
Pea Tyczynska
7f4580cb82 Update content following review 2018-11-16 15:15:40 +00:00
Alexey Bezhan
2f876243ae Pin all requirements in requirements.txt
The list of top-level dependencies is moved to requirements-app.txt,
which is used by `make freeze-requirements` to generate the full
list of requirements in requirements.txt.

(See alphagov/notifications-api#1938 for details.)
2018-07-30 16:43:03 +01:00
Chris Hill-Scott
f3a0c505bd Enforce order and style of imports
Done using isort[1], with the following command:
```
isort -rc ./app ./tests
```

Adds linting to the `run_tests.sh` script to stop badly-sorted imports
getting re-introduced.

Chosen style is ‘Vertical Hanging Indent’ with trailing commas, because
I think it gives the cleanest diffs, eg:
```
from third_party import (
    lib1,
    lib2,
    lib3,
    lib4,
)
```

1. https://pypi.python.org/pypi/isort
2018-02-27 16:35:13 +00:00
Leo Hemsted
5005a0db51 Merge pull request #1864 from alphagov/pytest-env
Automatically set environment vars before tests
2018-02-14 15:11:53 +00:00
Chris Hill-Scott
14b5f9e778 Allow up to 10 tests to fail before stopping
This is a sensible compromise between 1 test and ALL THE TESTS.

Uses the `maxfail` option as documented here:
https://docs.pytest.org/en/latest/usage.html#stopping-after-the-first-or-n-failures
2018-02-14 13:25:41 +00:00
Chris Hill-Scott
9f275d2a0b Stop pytest on first failing test
If a PR is going to fail because tests aren’t passing then you:
- should know about it as quick as possible
- shouldn’t waste precious Jenkins CPU running subsequent tests

This commit adds the `-x` flag to pytest, which stops the test run as
soon as one failing test is discovered.
2018-02-14 11:50:51 +00:00
Chris Hill-Scott
513c64be64 Remove environment_test.sh
These config variables are now set in `pytest.ini` instead.
2018-02-14 11:28:15 +00:00
Chris Hill-Scott
5efc86bbcc Remove flag from flake8 command
This flag was only needed because of a bug in flake8. This bug is fixed
now.
2018-02-12 10:26:55 +00:00
Chris Hill-Scott
b24c23fe3b Lint for print statements
flake8-print is a flake8 plugin that checks for `print()` statements in
Python files.

This should save us having to manually spot these when reviewing pull
requests.

The `--enable=T` flag needs to be set until this bug is fixed:
https://github.com/JBKahn/flake8-print/issues/27
2018-01-05 12:14:28 +00:00
Chris Hill-Scott
1530613fb4 Remove references to pycodestyle
We’re using flake8 now instead.
2017-10-20 11:02:39 +01:00
Chris Hill-Scott
eb2eea2e0b Use more processors when running tests
Back on my old 2013 Macbook Pro, 2 was the optimum number of cores for the fastest test runs. Which is why I chose `-n2` when I originally introduced this flag (see 9ced677ec7).

Now I have a faster Macbook (same as every other developer), which has more cores to take advantage of.

We also use 4 cores when running the API tests.

Cores | Time taken to run tests
--- | ---
1 | 28.31s
2 | 18.15s
3 | 14.33s
4 | 12.32s
5 | 12.98s
6 | 13.49s
8 | 15.37s
2017-10-18 11:15:09 +01:00
Martyn Inglis
e233c3868d Added some whitespace 2017-04-25 17:02:06 +01:00
Martyn Inglis
e7d6fd3293 updated run_tests to not use venv in the app if VIRTUAL_ENV is set 2017-04-25 15:32:12 +01:00
Leo Hemsted
9fda5d1847 remove remember_me cookie and related code 2017-02-27 15:18:18 +00:00
Chris Hill-Scott
f048b918a0 Use pycodestyle instead of PEP8
PEP8 was renamed to pycodestyle; this issue explains why:
PyCQA/pycodestyle#466

This commit changes our tests to use pycodestyle instead of pep8.

No changes to our code were required as a result.
2017-02-02 10:50:26 +00:00
Leo Hemsted
008c88e42c add junit xml reporting to pytest 2016-08-31 15:15:28 +01:00
bandesz
26ff449b77 Create Docker build image, build project with Docker 2016-08-22 17:25:05 +01:00
Leo Hemsted
d5238bce5b handle if user doesn't provide name/email
also clean up usage of DESKPRO_PERSON_EMAIL and put it in the conf rather than env
2016-08-04 18:01:08 +01:00
Chris Hill-Scott
e775ea2446 Delete commented out lines
These aren’t being used, so why have them?
2016-07-05 09:28:20 +01:00
Chris Hill-Scott
9ced677ec7 Run tests on multiple CPU cores
We can make the tests run slightly faster by parallelizing them across
multiple CPU cores:

- from some casual testing locally, 2 cores gives the optimum speedup
- Travis container-based builds have 2 CPU cores available[1]
- the net gain is about 20%, or 2 seconds
- unfortunately we can’t do this on the API because each test is still
  using the same instance of the database

1. https://docs.travis-ci.com/user/ci-environment/#Virtualization-environments
2016-07-05 09:27:50 +01:00
Nicholas Staples
6ea72182d2 Download CSV option now available. 2016-04-12 14:19:51 +01:00
Rebecca Law
02687710ae Remove commented code 2016-04-12 12:23:01 +01:00
Rebecca Law
9620d91330 Removed unused files and directory. 2016-04-11 09:35:50 +01:00
Chris Hill-Scott
5c4de3d13d Add code coverage
- generates a code coverage report
- triggers Coveralls on every Travis build
- adds a badge to the README
2016-04-07 11:03:27 +01:00
Adam Shimali
3e167c69f2 Clean up config a bit. Get values for config from environment.
Removed some old redundant config.
2016-03-23 15:07:04 +00:00
Martyn Inglis
2473b09beb Start aligning Admin app with config styles used elsewhere
- no config overrides - now all set in environment
- use different files for staging and live too allow for differently named env variables
- updates to run_app and run_tests scripts to set correct environment (test/development) so correct config picked up
- use environment file on deployed environments to pick correct config
2016-03-17 13:45:59 +00:00
Chris Hill-Scott
0201825c45 Add linting for SASS and Javascript
Similar to how PEP8 enforces Python style, there are tools for front end code:
- jshint[1] for Javascript
- sass-lint[2] for SASS

This commit adds the Gulp plugins for both, and sets up some sensible rules
(which can be iterated on).

It also adds a command to `./scripts/run_tests.sh`, so that any errors in the
front end code will fail the build before it has a chance to be deployed.

1. http://jshint.com/
2. https://www.npmjs.com/package/sass-lint
2016-02-08 12:02:22 +00:00
Rebecca Law
83a1dbd79d Added a blank test 2015-11-18 16:52:43 +00:00
Rebecca Law
29012c78ee Initial creation of notify-admin-frontend 2015-11-18 16:19:40 +00:00