Skip to content
Merged
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
24 changes: 11 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
language: python
sudo: required
dist: xenial
dist: focal

# This stops the entire job from running if it's a PR
if: type != pull_request

python:
- 3.5
- 3.6
- 3.7
- "3.10"
- "3.11"
- "3.12"

install:
- pip install -r requirements.txt
- python -m pip install --upgrade pip
- python -m pip install "poetry==2.3.4"
- poetry install --no-interaction --no-ansi

script:
- mkdir -p tmp
- pip install requests==2.18.4
- pip install coveralls
- coverage run setup.py test

after_success:
coveralls
- poetry run pytest
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ poetry install

## Test

Just clone the repo, install dependencies as you would in development and run `nose2` or `poetry run nose2`
Just clone the repo, install dependencies as you would in development and run:

```bash
poetry run pytest
```

## Contributing

Expand Down
22 changes: 19 additions & 3 deletions mifiel/document.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from mifiel import Base, Response
import mimetypes
import os
from os.path import basename
import requests
try:
Expand Down Expand Up @@ -107,18 +108,33 @@ def create_many_from_template(client, args={}):

def save_file(self, path):
url_ = self.url('{}/file').format(self.id)
response = requests.get(url_, auth=self.client.auth)
response = requests.get(url_, auth=self.client.auth, timeout=self._request_timeout())
response.raise_for_status()
self._ensure_parent_dir(path)
with open(path, 'wb') as file_:
file_.write(response.content)

def save_file_signed(self, path):
url_ = self.url('{}/file_signed').format(self.id)
response = requests.get(url_, auth=self.client.auth)
response = requests.get(url_, auth=self.client.auth, timeout=self._request_timeout())
response.raise_for_status()
self._ensure_parent_dir(path)
with open(path, 'wb') as file_:
file_.write(response.content)

def save_xml(self, path):
url_ = self.url('{}/xml').format(self.id)
response = requests.get(url_, auth=self.client.auth)
response = requests.get(url_, auth=self.client.auth, timeout=self._request_timeout())
response.raise_for_status()
self._ensure_parent_dir(path)
with open(path, 'w') as file_:
Comment thread
coderabbitai[bot] marked this conversation as resolved.
file_.write(response.text)

def _request_timeout(self):
return self.client.timeout if self.client.timeout else 30

@staticmethod
def _ensure_parent_dir(path):
directory = os.path.dirname(path)
if directory:
os.makedirs(directory, exist_ok=True)
9 changes: 0 additions & 9 deletions nose2.cfg

This file was deleted.

Loading