Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test countries #57

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
*.*~
*.egg
*.egg-info
*.odt
/*.odt
*.txt
.tox
.cache
.vscode
dist
build
eggs
eggs
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:3.6.4

RUN pip install \
pytest==3.3.2

COPY ./* /opt/secretary/

RUN pip install -e /opt/secretary
6 changes: 3 additions & 3 deletions secretary.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
from uuid import uuid4
from xml.dom.minidom import parseString
from xml.parsers.expat import ExpatError, ErrorString
from jinja2 import Environment, Undefined, Markup
from jinja2 import Environment, Undefined
from markupsafe import Markup

PY2 = sys.version_info < (3, 0)

Expand Down Expand Up @@ -141,14 +142,13 @@ def __init__(self, environment=None, **kwargs):
self.environment.filters['pad'] = pad_string
self.environment.filters['markdown'] = self.markdown_filter
self.environment.filters['image'] = self.image_filter
self.environment.globals['SafeValue'] = jinja2.Markup
self.environment.globals['SafeValue'] = Markup

self.media_path = kwargs.pop('media_path', '')
self.media_callback = self.fs_loader

self._compile_tags_expressions()

@jinja2.evalcontextfilter
def finalize_value(self, value, *args):
"""Escapes variables values."""
if isinstance(value, Markup):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def run_tests(self):
py_modules=['secretary', 'markdown_map'],
platforms='any',
install_requires=[
'Jinja2', 'markdown2'
'Jinja2>=3', 'markdown2', 'MarkupSafe'
],
tests_require=['pytest'],
cmdclass={'test': PyTest},
Expand Down
Binary file removed simple_template.odt
Binary file not shown.
35 changes: 35 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Secretary tests

You can run tests on your local Python environment with the command :

<pre>
pytest
</pre>

## Docker image

You can also build a docker image dedicated to your tests :

<pre>
docker build -t phe/secretary .
</pre>

Then you can run the tests in a container :

<pre>
docker run -ti \
-v $PWD:/opt/secretary \
-e "PYTHONPATH=/opt" \
-w /opt/secretary \
phe/secretary pytest -v
</pre>

For special need, you may prefer to run a shell :

<pre>
docker run -ti \
-v $PWD:/opt/secretary \
-e "PYTHONPATH=/opt" \
-w /opt/secretary \
phe/secretary /bin/bash
</pre>
Binary file added tests/simple_template.odt
Binary file not shown.
Binary file added tests/test_countries.odt
Binary file not shown.
File renamed without changes.
14 changes: 14 additions & 0 deletions tests/tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
import os

def relative_path(rel_path) :
'''Give a full path relative to this file'''
return os.path.join(os.path.dirname(__file__), rel_path)


def compare_odt_files(file1, file2):
'''Compare two LibreOffice odt file
returns True if they are equal
'''
#TODO: check content
assert True