kapsikkum-unmanic – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | # Unit Testing |
2 | |||
3 | |||
4 | |||
5 | ## Setup |
||
6 | |||
7 | Before any tests can be run, you need to execute |
||
8 | ``` |
||
9 | tests/scripts/setup_tests.sh |
||
10 | ``` |
||
11 | |||
12 | |||
13 | ----------------------------------------------------------- |
||
14 | |||
15 | |||
16 | ## Python PEP8 conformity |
||
17 | |||
18 | Prior to committing code, it should be tested against PEP8 formatting standards |
||
19 | ``` |
||
20 | pycodestyle ./ |
||
21 | ``` |
||
22 | |||
23 | You can also specify the files to run individual. Eg. |
||
24 | ``` |
||
25 | pycodestyle ./lib/common.py |
||
26 | ``` |
||
27 | |||
28 | |||
29 | ----------------------------------------------------------- |
||
30 | |||
31 | |||
32 | ## Python unit tests |
||
33 | |||
34 | To run all tests execute from the project directory root: |
||
35 | ``` |
||
36 | pytest --log-cli-level=INFO |
||
37 | ``` |
||
38 | |||
39 | You can also specify the files to run individual. Eg. |
||
40 | ``` |
||
41 | pytest --log-cli-level=INFO lib/common.py |
||
42 | ``` |
||
43 | |||
44 | For more in-depth logging of tests, change the params to: |
||
45 | ``` |
||
46 | pytest --log-cli-level=DEBUG -s |
||
47 | ``` |
||
48 | |||
49 | |||
50 | ----------------------------------------------------------- |
||
51 | |||
52 | |||
53 | ## WebUI acceptance tests |
||
54 | |||
55 | This is still a WIP but the idea will be to have a series of API calls to determine successful functionality of the Web API |
||
56 | |||
57 | To run the test first run a docker environment. You can do this by running |
||
58 | ``` |
||
59 | tests/scripts/library_scan.sh |
||
60 | ``` |
||
61 | You can export the following variables to configure the test container: |
||
62 | ``` |
||
63 | DEBUGGING=true |
||
64 | NUMBER_OF_WORKERS=1 |
||
65 | SCHEDULE_FULL_SCAN_MINUTES=1 |
||
66 | RUN_FULL_SCAN_ON_START=true |
||
67 | ``` |
||
68 | To clean the config run |
||
69 | ``` |
||
70 | tests/scripts/library_scan.sh --clean |
||
71 | ``` |
||
72 | |||
73 | |||
74 | ----------------------------------------------------------- |
||
75 | |||
76 | |||
77 | ## Python unit tests within docker |
||
78 | |||
79 | To run the python unit tests within the test docker env |
||
80 | (in order to test them in a controlled environment), run |
||
81 | these commands: |
||
82 | |||
83 | ``` |
||
84 | docker-compose -f docker/docker-compose-test.yml up --force-recreate |
||
85 | ``` |
||
86 | |||
87 | Wait for the container to start, then run: |
||
88 | |||
89 | ``` |
||
90 | docker exec --workdir=/app unmanic-testenv pycodestyle ./ |
||
91 | ``` |
||
92 | |||
93 | and |
||
94 | |||
95 | ``` |
||
96 | docker exec --workdir=/app unmanic-testenv pytest --log-cli-level=INFO |
||
97 | ``` |
||
98 | |||
99 | When developing, if you wish to run only a single test, run: |
||
100 | |||
101 | ``` |
||
102 | docker exec --workdir=/app unmanic-testenv pytest --log-cli-level=INFO --maxfail 1 -s tests/test_<TEST NAME>.py |
||
103 | ``` |