Skip to content

Commit 67af529

Browse files
Add integration tests
1 parent d3b900d commit 67af529

5 files changed

Lines changed: 70 additions & 0 deletions

File tree

.env.test.template

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
API_BASE=""
2+
CLIENT_ID=""
3+
CLIENT_SECRET=""
4+
ORGANIZATION_SLUG=""

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ __pycache__
1616

1717
helloasso_api_wrapper.egg-info
1818
build
19+
20+
.env.test

tests/__init__.py

Whitespace-only changes.

tests/commons.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from pydantic_settings import BaseSettings, SettingsConfigDict
2+
3+
from helloasso_api_wrapper import HelloAssoAPIWrapper
4+
5+
6+
class Dotenv(BaseSettings):
7+
model_config = SettingsConfigDict(
8+
env_file=".env.test",
9+
env_file_encoding="utf-8",
10+
case_sensitive=False,
11+
extra="ignore",
12+
)
13+
14+
API_BASE: str
15+
CLIENT_ID: str
16+
CLIENT_SECRET: str
17+
ORGANIZATION_SLUG: str
18+
19+
20+
dotenv = Dotenv()
21+
22+
hello_asso = HelloAssoAPIWrapper(
23+
api_base=dotenv.API_BASE,
24+
client_id=dotenv.CLIENT_ID,
25+
client_secret=dotenv.CLIENT_SECRET,
26+
timeout=60,
27+
)
28+
29+
30+
organization_slug = dotenv.ORGANIZATION_SLUG
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from datetime import UTC, datetime
2+
3+
from helloasso_api_wrapper.models.carts import CheckoutPayer, InitCheckoutBody
4+
from tests.commons import hello_asso, organization_slug
5+
6+
checkout_intent_id: int
7+
8+
9+
def test_init_a_checkout() -> None:
10+
init_checkout_body = InitCheckoutBody(
11+
totalAmount=100,
12+
initialAmount=100,
13+
itemName="test",
14+
backUrl="https://google.fr",
15+
errorUrl="https://google.fr",
16+
returnUrl="https://google.fr",
17+
containsDonation=False,
18+
payer=CheckoutPayer(dateOfBirth=datetime(1990, 1, 1, tzinfo=UTC)),
19+
)
20+
21+
response = hello_asso.checkout_intents_management.init_a_checkout(
22+
organization_slug,
23+
init_checkout_body,
24+
)
25+
26+
global checkout_intent_id
27+
checkout_intent_id = response.id
28+
29+
30+
def test_retrieve_a_checkout_intent() -> None:
31+
hello_asso.retrieve_a_checkout_intent(
32+
organization_slug,
33+
checkout_intent_id,
34+
)

0 commit comments

Comments
 (0)