Skip to content

Commit dd47651

Browse files
authored
feat(actions): add live tests [wip] (sammchardy#1432)
* try adding secret * add debug * update * update * update * another try * remove env * update * add environment * print var * update * update * revert file' * revert file * try setting proxy * add proxy * debug * update * try different file * new test * update var name * update proxy * update proxies
1 parent 690536c commit dd47651

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

.github/workflows/python-app.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ jobs:
1616
build:
1717

1818
runs-on: ubuntu-latest
19-
19+
env:
20+
PROXY: "http://51.83.140.52:16301"
2021
steps:
22+
- name: Checking env
23+
run: env
2124
- uses: actions/checkout@v4
2225
- name: Set up Python 3.10
2326
uses: actions/setup-python@v3

tests/test_api_request.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22
from binance.exceptions import BinanceAPIException, BinanceRequestException
33
import pytest
44
import requests_mock
5+
import os
56

7+
proxies = {}
8+
proxy = os.getenv("PROXY")
9+
if proxy:
10+
proxies = {"http": proxy, 'https': proxy } # tmp: improve this in the future
11+
else:
12+
print("No proxy set")
613

7-
client = Client("api_key", "api_secret")
8-
14+
client = Client("api_key", "api_secret", {'proxies': proxies})
915

1016
def test_invalid_json():
1117
"""Test Invalid response Exception"""

tests/test_cryptography.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
from binance.client import Client
2+
import os
3+
4+
proxies = {}
5+
proxy = os.getenv("PROXY")
6+
if proxy:
7+
proxies = {"http": proxy, 'https': proxy } # tmp: improve this in the future
8+
else:
9+
print("No proxy set")
10+
211

312
test_cases = [
413
{
@@ -43,6 +52,7 @@ def test_encryption():
4352
api_secret="api_secret",
4453
private_key=case["private_key"],
4554
private_key_pass=case["password"],
55+
requests_params={'proxies': proxies}
4656
)
4757
signature = client._generate_signature(data)
4858
assert signature == case["expected_signature"], f"Test failed: {case['description']}"

tests/test_historical_klines.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@
44
from binance.client import Client
55
import pytest
66
import requests_mock
7+
import os
78

9+
proxies = {}
10+
proxy = os.getenv("PROXY")
811

9-
client = Client("api_key", "api_secret")
12+
if proxy:
13+
proxies = {"http": proxy, 'https': proxy } # tmp: improve this in the future
14+
else:
15+
print("No proxy set")
16+
17+
client = Client("api_key", "api_secret", {'proxies': proxies})
1018

1119

1220
def test_exact_amount():

0 commit comments

Comments
 (0)