-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(tests): move bank PDF fixtures to same dir as test files
- Loading branch information
1 parent
2b0df10
commit f1c843e
Showing
19 changed files
with
20 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
tests/integration/fixtures/**/input.pdf filter=git-crypt diff=git-crypt | ||
tests/integration/banks/**/input.pdf filter=git-crypt diff=git-crypt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,60 @@ | ||
from pathlib import Path | ||
|
||
from pytest import raises | ||
|
||
from monopoly.banks import Hsbc | ||
from monopoly.config import BruteForceConfig | ||
from monopoly.pdf import PdfParser | ||
|
||
fixture_directory = Path(__file__).parent / "fixtures" | ||
|
||
|
||
def test_can_open_protected(parser: PdfParser): | ||
parser.file_path = "tests/integration/fixtures/protected.pdf" | ||
parser.file_path = fixture_directory / "protected.pdf" | ||
parser.password = "foobar123" | ||
|
||
parser.open() | ||
|
||
|
||
def test_can_brute_force_open_protected(parser: PdfParser): | ||
brute_force_config = BruteForceConfig("foobar", "?d?d?d") | ||
parser.file_path = "tests/integration/fixtures/protected.pdf" | ||
parser.file_path = fixture_directory / "protected.pdf" | ||
|
||
parser.open(brute_force_config) | ||
|
||
|
||
def test_wrong_password_raises_error(parser: PdfParser): | ||
parser.file_path = "tests/integration/fixtures/protected.pdf" | ||
parser.file_path = fixture_directory / "protected.pdf" | ||
parser.password = "wrong_pw" | ||
|
||
with raises(ValueError, match="Wrong password"): | ||
parser.open() | ||
|
||
|
||
def test_get_pages(parser: PdfParser): | ||
parser.file_path = "tests/integration/fixtures/4_pages_blank.pdf" | ||
parser.file_path = fixture_directory / "4_pages_blank.pdf" | ||
parser.page_range = slice(0, -1) | ||
|
||
pages = parser.get_pages() | ||
assert len(pages) == 3 | ||
|
||
|
||
def test_get_pages_invalid_returns_error(parser: PdfParser): | ||
parser.file_path = "tests/integration/fixtures/4_pages_blank.pdf" | ||
parser.file_path = fixture_directory / "4_pages_blank.pdf" | ||
parser.page_range = slice(99, -99) | ||
|
||
with raises(ValueError, match="bad page number"): | ||
parser.get_pages() | ||
|
||
|
||
def test_override_password(hsbc: Hsbc): | ||
hsbc = Hsbc("tests/integration/fixtures/protected.pdf", password="foobar123") | ||
hsbc = Hsbc(fixture_directory / "protected.pdf", password="foobar123") | ||
|
||
document = hsbc.open() | ||
assert not document.is_encrypted | ||
|
||
|
||
def test_error_raised_if_override_is_wrong(): | ||
with raises(ValueError, match="Wrong password"): | ||
hsbc = Hsbc("tests/integration/fixtures/protected.pdf", password="wrongpw") | ||
hsbc = Hsbc(fixture_directory / "protected.pdf", password="wrongpw") | ||
hsbc.open() |