Skip to content

Commit

Permalink
feat(actions): add live tests [wip] (#1432)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
carlosmiei authored Oct 19, 2024
1 parent 690536c commit dd47651
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ jobs:
build:

runs-on: ubuntu-latest

env:
PROXY: "http://51.83.140.52:16301"
steps:
- name: Checking env
run: env
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
Expand Down
10 changes: 8 additions & 2 deletions tests/test_api_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
from binance.exceptions import BinanceAPIException, BinanceRequestException
import pytest
import requests_mock
import os

proxies = {}
proxy = os.getenv("PROXY")
if proxy:
proxies = {"http": proxy, 'https': proxy } # tmp: improve this in the future
else:
print("No proxy set")

client = Client("api_key", "api_secret")

client = Client("api_key", "api_secret", {'proxies': proxies})

def test_invalid_json():
"""Test Invalid response Exception"""
Expand Down
10 changes: 10 additions & 0 deletions tests/test_cryptography.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
from binance.client import Client
import os

proxies = {}
proxy = os.getenv("PROXY")
if proxy:
proxies = {"http": proxy, 'https': proxy } # tmp: improve this in the future
else:
print("No proxy set")


test_cases = [
{
Expand Down Expand Up @@ -43,6 +52,7 @@ def test_encryption():
api_secret="api_secret",
private_key=case["private_key"],
private_key_pass=case["password"],
requests_params={'proxies': proxies}
)
signature = client._generate_signature(data)
assert signature == case["expected_signature"], f"Test failed: {case['description']}"
10 changes: 9 additions & 1 deletion tests/test_historical_klines.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@
from binance.client import Client
import pytest
import requests_mock
import os

proxies = {}
proxy = os.getenv("PROXY")

client = Client("api_key", "api_secret")
if proxy:
proxies = {"http": proxy, 'https': proxy } # tmp: improve this in the future
else:
print("No proxy set")

client = Client("api_key", "api_secret", {'proxies': proxies})


def test_exact_amount():
Expand Down

0 comments on commit dd47651

Please sign in to comment.