Skip to content

Commit 7a25360

Browse files
authored
Merge pull request #33 from sypht-team/feature/PLF-2508-upload-doc-state
Feature/plf 2508 upload doc state
2 parents 80c2caa + 0c5db10 commit 7a25360

File tree

5 files changed

+37
-8
lines changed

5 files changed

+37
-8
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ sypht.egg-info
1414
coverage.xml
1515

1616
venv
17-
.env
17+
.env
18+
19+
.direnv

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ install:
1111
- pip install codecov
1212

1313
script:
14-
- echo "skipping tests"
14+
- pip install pytest
15+
- pytest -s tests/*.py
1516

1617
deploy:
1718
user: $PYPI_USER

sypht/client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,17 @@ def delete_workflow_data(self, rules_id=None, company_id=None, endpoint=None):
342342
headers["Content-Type"] = "application/json"
343343
return self._parse_response(self.requests.delete(endpoint, headers=headers))
344344

345-
def create_file(self, file, filename=None, endpoint=None, headers=None):
345+
def create_file(self, file, filename=None, endpoint=None, headers=None, data=None):
346346
endpoint = urljoin(endpoint or self.base_endpoint, "fileupload/v2/multipart")
347347
headers = headers or {}
348348
headers = self._get_headers(**headers)
349349
if filename is not None:
350350
file = filename, file
351+
data = data or {}
351352
return self._parse_response(
352-
self.requests.post(endpoint, files={"file": file}, headers=headers)
353+
self.requests.post(
354+
endpoint, files={"file": file}, data=data, headers=headers
355+
)
353356
)
354357

355358
def get_file(self, file_id, endpoint=None, headers=None):

tests/tests_client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ def validate_uuid4(uuid_string):
1919
class DataExtraction(unittest.TestCase):
2020
def setUp(self):
2121
warnings.simplefilter("ignore", category=ResourceWarning)
22-
23-
self.sypht_client = SyphtClient(
24-
os.environ["CLIENT_ID"], os.environ["CLIENT_SECRET"]
25-
)
22+
self.sypht_client = SyphtClient()
2623

2724
def test_with_wrong_fieldset(self):
2825
with self.assertRaises(Exception) as context:

tests/tests_client_create_file.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import unittest
2+
3+
from sypht.client import SyphtClient
4+
5+
6+
class CreateFileTests(unittest.TestCase):
7+
def setUp(self):
8+
self.sypht_client = SyphtClient()
9+
10+
def test_create_file(self):
11+
with open("tests/sample_invoice.pdf", "rb") as f:
12+
13+
response = self.sypht_client.create_file(file=("sample_invoice.pdf", f))
14+
self.assertTrue(response["status"], "RECIEVED")
15+
16+
def test_create_file_with_data(self):
17+
with open("tests/sample_invoice.pdf", "rb") as f:
18+
19+
response = self.sypht_client.create_file(
20+
file=("sample_invoice.pdf", f), data={"splitState": "created_by_split"}
21+
)
22+
self.assertTrue(response["status"], "RECIEVED")
23+
24+
25+
if __name__ == "__main__":
26+
unittest.main()

0 commit comments

Comments
 (0)