-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_multiple_libraries.py
More file actions
49 lines (39 loc) · 1.31 KB
/
Copy pathtest_multiple_libraries.py
File metadata and controls
49 lines (39 loc) · 1.31 KB
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
import aiohttp
import fastapi
import pytest
import sqlalchemy
import numpy as np
import pandas as pd
from typing import Optional
app = fastapi.FastAPI()
@app.get('/')
async def root():
return {'message': 'Hello World'}
# Test using multiple libraries to increase chances of hitting the 10% rollout
async def test_aiohttp_client():
connector = aiohttp.TCPConnector(limit=30, limit_per_host=10)
async with aiohttp.ClientSession(connector=connector) as session:
async with session.get('https://httpbin.org/get') as response:
return await response.json()
def test_pytest_fixture():
@pytest.fixture
def sample_data():
return {"key": "value"}
return sample_data
def test_sqlalchemy_usage():
from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(String)
engine = create_engine('sqlite:///:memory:')
Base.metadata.create_all(engine)
return engine
def test_numpy_operations():
arr = np.array([1, 2, 3, 4, 5])
return np.mean(arr)
def test_pandas_operations():
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
return df.describe()