-
Notifications
You must be signed in to change notification settings - Fork 36
/
test_run.py
71 lines (67 loc) · 2.12 KB
/
test_run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import json
import tempfile
from pathlib import Path
import os
import subprocess
import requests
import time
def test_run():
cmd = ["docker", "build", "-t", "akretion/boleto_cnab_api", "."]
result = subprocess.run(
cmd, check=False, capture_output=True, text=True, cwd=Path(__file__).parent
)
assert result.returncode == 0, result.stderr + "\n" + result.stdout
cmd = [
"docker",
"run",
"-d",
"-p",
"9292:9292",
"--name=boleto_cnab_api",
"akretion/boleto_cnab_api",
]
result = subprocess.run(cmd, check=False, capture_output=True, text=True)
assert result.returncode == 0, result.stderr + "\n" + result.stdout
time.sleep(5)
remessa_values = [
{
"valor": 5.0,
"cedente": "Kivanio Barbosa",
"documento_cedente": "12345678912",
"sacado": "Claudio Pozzebom",
"sacado_documento": "12345678900",
"agencia": "0810",
"conta_corrente": "53678",
"convenio": 12387,
"nosso_numero": "12345678",
"bank": "itau",
},
{
"valor": 10.00,
"cedente": "PREFEITURA MUNICIPAL DE VILHENA",
"documento_cedente": "04092706000181",
"sacado": "João Paulo Barbosa",
"sacado_documento": "77777777777",
"agencia": "1825",
"conta_corrente": "0000528",
"convenio": "245274",
"nosso_numero": "000000000000001",
"bank": "caixa",
},
]
content = json.dumps(remessa_values)
with open(tempfile.mktemp(), "w") as f:
file_name = f.name
f.write(content)
files = {"data": open(file_name, "rb")}
result = requests.post(
"http://localhost:9292/api/boleto/multi",
data={
"type": "pdf",
},
files=files,
)
assert str(result.status_code)[0] == "2"
cmd = ["docker", "rm", "-f", "boleto_cnab_api"]
result = subprocess.run(cmd, check=False, capture_output=True, text=True)
assert result.returncode == 0, result.stderr + "\n" + result.stdout