Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies and their usages #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 5 additions & 7 deletions aiograph/api.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import asyncio

import contextlib
from contextvars import ContextVar

import os
import secrets
import ssl
from contextvars import ContextVar
from pathlib import Path
from typing import List, Optional, Union

Expand Down Expand Up @@ -112,19 +110,19 @@ def __init__(self,
ssl_context = ssl.create_default_context(cafile=certifi.where())

if isinstance(proxy, str) and (proxy.startswith('socks5://') or proxy.startswith('socks4://')):
from aiohttp_socks import SocksConnector
from aiohttp_socks import ProxyConnector
from aiohttp_socks.utils import parse_proxy_url

socks_ver, host, port, username, password = parse_proxy_url(proxy)
proxy_type, host, port, username, password = parse_proxy_url(proxy)
if proxy_auth:
if not username:
username = proxy_auth.login
if not password:
password = proxy_auth.password

connector = SocksConnector(socks_ver=socks_ver, host=host, port=port,
connector = ProxyConnector(proxy_type=proxy_type, host=host, port=port,
username=username, password=password,
limit=connections_limit, ssl_context=ssl_context,
limit=connections_limit, ssl=ssl_context,
rdns=True, loop=self.loop)

self.proxy = None
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
aiohttp>=3.4.4
aiohttp>=3.9.5
certifi>=2018.11.29
attrs>=19.3.0
attrs>=23.2.0
5 changes: 2 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from pathlib import Path

import pytest
import pytest_asyncio

sys.path.insert(0, str(Path(__file__).parent.parent))

Expand All @@ -10,8 +10,7 @@
access_token = None


@pytest.yield_fixture()
@pytest.mark.asyncio
@pytest_asyncio.fixture
async def telegraph():
aiograph = Telegraph(token=access_token)
yield aiograph
Expand Down
14 changes: 7 additions & 7 deletions tests/test_features.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from aiohttp import BasicAuth
from aiohttp_socks import SocksConnector, SocksVer
from aiohttp_socks import SocksVer, ProxyConnector

from aiograph import Telegraph, types
from aiograph.utils import exceptions
Expand Down Expand Up @@ -94,9 +94,9 @@ def test_socks5_proxy():
telegraph = Telegraph(proxy='socks5://example.com:1050', proxy_auth=BasicAuth('username', 'password'))
connector = telegraph.session._connector

assert isinstance(connector, SocksConnector)
assert connector._socks_ver.value == SocksVer.SOCKS5
assert connector._socks_host == 'example.com'
assert connector._socks_port == 1050
assert connector._socks_username == 'username'
assert connector._socks_password == 'password'
assert isinstance(connector, ProxyConnector)
assert connector._proxy_type.value == SocksVer.SOCKS5
assert connector._proxy_host == 'example.com'
assert connector._proxy_port == 1050
assert connector._proxy_username == 'username'
assert connector._proxy_password == 'password'