Skip to content

Commit

Permalink
Add credit card test
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Apr 7, 2019
1 parent 74f947d commit abd06cf
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
6 changes: 3 additions & 3 deletions process
Original file line number Diff line number Diff line change
Expand Up @@ -658,11 +658,11 @@ def finalise(config, step, root_folder):
if os.path.exists(img):
images2.append(img)

file_name = os.path.join(root_folder, 'append.png')
call(CONVERT + images2 + [
'-background', '#ffffff', '-gravity', 'center', '-append',
os.path.join(root_folder, 'final.png')
'-background', '#ffffff', '-gravity', 'center', '-append', file_name
])
images = [os.path.join(root_folder, 'final.png')]
images = [file_name]

pdf = []
for img in images:
Expand Down
Binary file added tests/credit-card-1.expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/credit-card-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/credit-card-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,43 @@ def test_full(progress, experimental):
'+adjoin', os.path.join(root_folder, 'final.png')
])
check_image(root_folder, os.path.join(root_folder, 'final.png'), 'all-2')


# @pytest.mark.skip(reason='for test')
def test_credit_card_full():
os.environ['PROGRESS'] = 'TRUE'
os.environ['EXPERIMENTAL'] = 'FALSE'
root_folder = '/results/credit-card/'
if not os.path.exists(root_folder):
os.makedirs(root_folder)
config = {
'args': {
'assisted_split': False,
'level': True,
'append_credit_card': True,
},
'full_name': 'Credit Card',
'destination': os.path.join(root_folder, 'final.pdf'),
}
step = {
'sources': [
os.path.join(os.path.dirname(__file__), 'credit-card-1.png'),
os.path.join(os.path.dirname(__file__), 'credit-card-2.png'),
]
}
step = process.transform(config, step, '/tmp/test-config.yaml', root_folder)
assert len(step['sources']) == 2
assert step['name'] == 'finalise'
process.finalise(config, step, root_folder)
pdfinfo = process.output(['pdfinfo', os.path.join(root_folder, 'final.pdf')]).split('\n')
regex = re.compile(r'([a-zA-Z ]+): +(.*)')
pdfinfo = [regex.match(e) for e in pdfinfo]
pdfinfo = dict([e.groups() for e in pdfinfo if e is not None])
assert pdfinfo['Title'] == 'Credit Card'
assert pdfinfo['Pages'] == '1'
assert pdfinfo['Page size'] == '1155.09 x 1693.03 pts'
process.call([
'gm', 'convert', os.path.join(root_folder, 'final.pdf'),
'+adjoin', os.path.join(root_folder, 'final.png')
])
check_image(root_folder, os.path.join(root_folder, 'final.png'), 'credit-card-1')

0 comments on commit abd06cf

Please sign in to comment.