Skip to content

Commit

Permalink
make use cases as actual tests, refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jdum committed Oct 28, 2023
1 parent e73b3d9 commit fc84f50
Show file tree
Hide file tree
Showing 28 changed files with 1,266 additions and 1,135 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ Installation from sources (requiring setuptools):
pip install .
```

After installation, you can check everything is working (requirement: `pytest`):
After installation from sources, you can check everything is working (some requirements: `pytest`, Pillow, ...):

```python
pytest tests
pytest
```

The tests should run for a few seconds and issue no error.
The tests should run for a few seconds or minutes and issue no error.


Usage
Expand Down
30 changes: 14 additions & 16 deletions doc/container.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ <h1 class="title">Module <code>odfdo.container</code></h1>
def __save_zip(self, target):
&#34;&#34;&#34;Save a Zip ODF from the available parts.&#34;&#34;&#34;
parts = self.__parts

with ZipFile(target, &#34;w&#34;, compression=ZIP_DEFLATED) as filezip:
# Parts to save, except manifest at the end
part_names = list(parts.keys())
Expand Down Expand Up @@ -271,10 +270,10 @@ <h1 class="title">Module <code>odfdo.container</code></h1>
is_folder = False
pure_path = PurePath(folder, part_path)
path = Path(pure_path)
path.parent.mkdir(parents=False, exist_ok=True)
if is_folder:
path.mkdir(parents=False, exist_ok=True)
path.mkdir(parents=True, exist_ok=True)
else:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_bytes(content)
path.chmod(0o666)

Expand Down Expand Up @@ -393,12 +392,12 @@ <h1 class="title">Module <code>odfdo.container</code></h1>
target = target.split(&#34;.folder&#34;, 1)[0]
return target

def _save_as_zip(self, packaging, target, backup):
def _save_as_zip(self, target, backup):
if isinstance(target, str) and backup:
self.__do_backup(target)
self.__save_zip(target)

def _save_as_folder(self, packaging, target, backup):
def _save_as_folder(self, target, backup):
if not isinstance(target, str):
raise TypeError(
f&#34;Saving in folder format requires a folder name, not &#39;{target}&#39;&#34;
Expand Down Expand Up @@ -439,10 +438,10 @@ <h1 class="title">Module <code>odfdo.container</code></h1>
self.get_part(path)
target = self._save_target(target)
if packaging == &#34;folder&#34;:
self._save_as_folder(packaging, target, backup)
self._save_as_folder(target, backup)
else:
# default:
self._save_as_zip(packaging, target, backup)</code></pre>
self._save_as_zip(target, backup)</code></pre>
</details>
</section>
<section>
Expand Down Expand Up @@ -629,7 +628,6 @@ <h2 class="section-title" id="header-classes">Classes</h2>
def __save_zip(self, target):
&#34;&#34;&#34;Save a Zip ODF from the available parts.&#34;&#34;&#34;
parts = self.__parts

with ZipFile(target, &#34;w&#34;, compression=ZIP_DEFLATED) as filezip:
# Parts to save, except manifest at the end
part_names = list(parts.keys())
Expand Down Expand Up @@ -673,10 +671,10 @@ <h2 class="section-title" id="header-classes">Classes</h2>
is_folder = False
pure_path = PurePath(folder, part_path)
path = Path(pure_path)
path.parent.mkdir(parents=False, exist_ok=True)
if is_folder:
path.mkdir(parents=False, exist_ok=True)
path.mkdir(parents=True, exist_ok=True)
else:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_bytes(content)
path.chmod(0o666)

Expand Down Expand Up @@ -795,12 +793,12 @@ <h2 class="section-title" id="header-classes">Classes</h2>
target = target.split(&#34;.folder&#34;, 1)[0]
return target

def _save_as_zip(self, packaging, target, backup):
def _save_as_zip(self, target, backup):
if isinstance(target, str) and backup:
self.__do_backup(target)
self.__save_zip(target)

def _save_as_folder(self, packaging, target, backup):
def _save_as_folder(self, target, backup):
if not isinstance(target, str):
raise TypeError(
f&#34;Saving in folder format requires a folder name, not &#39;{target}&#39;&#34;
Expand Down Expand Up @@ -841,10 +839,10 @@ <h2 class="section-title" id="header-classes">Classes</h2>
self.get_part(path)
target = self._save_target(target)
if packaging == &#34;folder&#34;:
self._save_as_folder(packaging, target, backup)
self._save_as_folder(target, backup)
else:
# default:
self._save_as_zip(packaging, target, backup)</code></pre>
self._save_as_zip(target, backup)</code></pre>
</details>
<h3>Static methods</h3>
<dl>
Expand Down Expand Up @@ -1060,10 +1058,10 @@ <h2 id="arguments">Arguments</h2>
self.get_part(path)
target = self._save_target(target)
if packaging == &#34;folder&#34;:
self._save_as_folder(packaging, target, backup)
self._save_as_folder(target, backup)
else:
# default:
self._save_as_zip(packaging, target, backup)</code></pre>
self._save_as_zip(target, backup)</code></pre>
</details>
</dd>
<dt id="odfdo.container.Container.set_part"><code class="name flex">
Expand Down
Loading

0 comments on commit fc84f50

Please sign in to comment.