Commit graph

11 commits

Author SHA1 Message Date
deeplow
be5a942a73
Add unit tests for document.py 2022-10-27 13:44:09 +01:00
Alex Pyrgiotis
03c3541bdc
tests: Run Mypy against tests
Run Mypy static checks against our tests. This brings them inline with
the rest of the codebase, and we have an extra level of certainty that
the tests (and unit tests in particular) will not significantly diverge
from the code they are testing.
2022-10-25 19:09:23 +03:00
Alex Pyrgiotis
7d218e5522
tests: Fix path separator issues on Windows
Concatenate directories and filenames in a platform-independent way, by
using pathlib.Path. This fixes issues in the tests where the "/" path
separator made the tests fail on Windows.
2022-10-25 19:09:22 +03:00
Alex Pyrgiotis
ae67dfa5a9
tests: Test filenames with spaces in them
Add two tests that check if Dangerzone properly handles input and output
filenames with spaces in them. Previously this was not straight-forward
because we didn't tokenize arguments, which lead to Click splitting
filenames with spaces in two.
2022-10-25 19:09:22 +03:00
Alex Pyrgiotis
51d4fb04c8
tests: Tokenize CLI arguments
Pass tokenized arguments (i.e., arguments as lists of strings) to CLI
invocations, else Click will attempt to tokenize them internally. The
problem with leaving tokenization to Click is that it uses
`shlex.split()`, which is Unix-oriented, and may miss some cases in
Windows.
2022-10-25 19:09:22 +03:00
Alex Pyrgiotis
6b7797639c
tests: Wrap Click results with extra functionality
Wrap Click results (`Result`) with a new class (`CLIResult`), which
includes:

1. Assertion statements.
2. Logic for formatting and printing a Click result.
3. Invocation arguments, which are missing from the original `Result`
   class.
2022-10-25 19:09:17 +03:00
deeplow
c0f0e7bf6a
move banner() code to cli & version() to util
- display_banner() was only displayed in CLI mode so it makes sense
for it to be in the CLI.
- get_version(), was mvoed to util since it is a static function
that is needed in multiple parts of the application.
2022-09-15 10:40:31 +01:00
deeplow
0f4e6e9156
create non-ascii filename test cases dynamically instead of static PDF
originally PDF files were included for these edge-cases but in
reality all we want to test is the filename itself. So it reduces
repo size if we have them generated dynamically.
2022-09-13 13:38:33 +01:00
deeplow
d3f478b17f
migrate to pytest & test_docs -> tests/test_docs
Use pytest instead of unittest to have greater flexibility in test
parametrization.
2022-09-13 13:07:58 +01:00
deeplow
84acf116c7
remove non-implemented tests
Since we're not doing test-drive-development, we should not have
tests for unimplemented features.
2022-09-13 13:07:12 +01:00
deeplow
377665c459
move tests to project root 2022-09-13 13:07:10 +01:00
Renamed from dangerzone/tests/test_cli.py (Browse further)