Skip to content

Commit 0a15db6

Browse files
author
Robert Segal
committed
Reorganized fixtures in e2e accounts
1 parent d9af1e6 commit 0a15db6

File tree

9 files changed

+207
-199
lines changed

9 files changed

+207
-199
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import pytest
2+
3+
4+
@pytest.fixture
5+
def invalid_account_id():
6+
return "ACC-0000-0000"
7+
8+
9+
@pytest.fixture
10+
def account_factory():
11+
def _account(
12+
name: str = "E2E Test Api Client Vendor",
13+
):
14+
return {
15+
"name": name,
16+
"address": {
17+
"addressLine1": "123 Test St",
18+
"city": "San Francisco",
19+
"state": "CA",
20+
"postCode": "12345",
21+
"country": "US",
22+
},
23+
"type": "Vendor",
24+
"status": "Active",
25+
}
26+
27+
return _account
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import pytest
2+
3+
4+
@pytest.fixture
5+
def api_token_id(e2e_config):
6+
return e2e_config["accounts.api_token.id"]
7+
8+
9+
@pytest.fixture
10+
def invalid_api_token_id():
11+
return "TKN-0000-0000"
12+
13+
14+
@pytest.fixture
15+
def api_token_factory(account_id, module_id):
16+
def _api_token(
17+
name: str = "E2E Test API Token",
18+
description: str = "E2E API Token created during E2E tests",
19+
):
20+
return {
21+
"account": {"id": account_id},
22+
"name": name,
23+
"description": description,
24+
"icon": "",
25+
"modules": [{"id": module_id}],
26+
}
27+
28+
return _api_token
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import pytest
2+
3+
4+
@pytest.fixture
5+
def invalid_buyer_id():
6+
return "BUY-0000-0000"
7+
8+
9+
@pytest.fixture
10+
def buyer_account_id(e2e_config):
11+
return e2e_config["accounts.buyer.account.id"]
12+
13+
14+
@pytest.fixture
15+
def buyer_factory(buyer_account_id):
16+
def _buyer(
17+
name="E2E Created Buyer",
18+
account_id: str = buyer_account_id,
19+
):
20+
return {
21+
"name": name,
22+
"account": {
23+
"id": account_id,
24+
},
25+
"contact": {
26+
"firstName": "first",
27+
"lastName": "last",
28+
"email": "created.buyer@example.com",
29+
},
30+
"address": {
31+
"addressLine1": "123 Main St",
32+
"city": "Anytown",
33+
"state": "CA",
34+
"postCode": "12345",
35+
"country": "US",
36+
},
37+
}
38+
39+
return _buyer

tests/e2e/accounts/conftest.py

Lines changed: 15 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -19,79 +19,33 @@ def currencies():
1919

2020

2121
@pytest.fixture
22-
def seller_factory(currencies):
23-
def _seller(
24-
external_id: str, # Must be unique in Marketplace
25-
name="E2E Test Seller",
26-
currencies=currencies,
27-
):
28-
return {
29-
"name": name,
30-
"address": {
31-
"addressLine1": "123 Main St",
32-
"city": "Anytown",
33-
"state": "CA",
34-
"postCode": "12345",
35-
"country": "US",
36-
},
37-
"currencies": currencies,
38-
"externalId": external_id,
39-
}
40-
41-
return _seller
22+
def account_id(e2e_config):
23+
return e2e_config["accounts.account.id"]
4224

4325

4426
@pytest.fixture
45-
def account_factory():
46-
def _account(
47-
name: str = "E2E Test Api Client Vendor",
48-
):
49-
return {
50-
"name": name,
51-
"address": {
52-
"addressLine1": "123 Test St",
53-
"city": "San Francisco",
54-
"state": "CA",
55-
"postCode": "12345",
56-
"country": "US",
57-
},
58-
"type": "Vendor",
59-
"status": "Active",
60-
}
27+
def seller_id(e2e_config):
28+
return e2e_config["accounts.seller.id"]
6129

62-
return _account
30+
31+
@pytest.fixture
32+
def buyer_id(e2e_config):
33+
return e2e_config["accounts.buyer.id"]
6334

6435

6536
@pytest.fixture
66-
def buyer_factory(buyer_account_id):
67-
def _buyer(
68-
name="E2E Created Buyer",
69-
account_id: str = buyer_account_id,
70-
):
71-
return {
72-
"name": name,
73-
"account": {
74-
"id": account_id,
75-
},
76-
"contact": {
77-
"firstName": "first",
78-
"lastName": "last",
79-
"email": "created.buyer@example.com",
80-
},
81-
"address": {
82-
"addressLine1": "123 Main St",
83-
"city": "Anytown",
84-
"state": "CA",
85-
"postCode": "12345",
86-
"country": "US",
87-
},
88-
}
37+
def user_group_id(e2e_config):
38+
return e2e_config["accounts.user_group.id"]
39+
8940

90-
return _buyer
41+
@pytest.fixture
42+
def module_id(e2e_config):
43+
return e2e_config["accounts.module.id"]
9144

9245

9346
@pytest.fixture
9447
def user_group_factory(account_id, module_id):
48+
# Used in user group and licensee fixtures
9549
def _user_group(
9650
name: str = "E2E Test Api Client User Group",
9751
user_group_account_id: str = account_id,
@@ -106,51 +60,3 @@ def _user_group(
10660
}
10761

10862
return _user_group
109-
110-
111-
@pytest.fixture
112-
def api_token_factory(account_id, module_id):
113-
def _api_token(
114-
name: str = "E2E Test API Token",
115-
description: str = "E2E API Token created during E2E tests",
116-
):
117-
return {
118-
"account": {"id": account_id},
119-
"name": name,
120-
"description": description,
121-
"icon": "",
122-
"modules": [{"id": module_id}],
123-
}
124-
125-
return _api_token
126-
127-
128-
@pytest.fixture
129-
def licensee_factory(seller_id, buyer_id, user_group_factory, licensee_account_id):
130-
def _licensee(
131-
name: str = "Test E2E Licensee",
132-
licensee_type: str = "Client",
133-
):
134-
group = user_group_factory(user_group_account_id=licensee_account_id)
135-
136-
return {
137-
"name": name,
138-
"address": {
139-
"addressLine1": "456 Licensee St",
140-
"city": "Los Angeles",
141-
"state": "CA",
142-
"postCode": "67890",
143-
"country": "US",
144-
},
145-
"useBuyerAddress": False,
146-
"seller": {"id": seller_id},
147-
"buyer": {"id": buyer_id},
148-
"account": {"id": licensee_account_id},
149-
"eligibility": {"client": True, "partner": False},
150-
"groups": [group],
151-
"type": licensee_type,
152-
"status": "Enabled",
153-
"defaultLanguage": "en-US",
154-
}
155-
156-
return _licensee
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import pytest
2+
3+
4+
@pytest.fixture
5+
def licensee_account_id(e2e_config):
6+
return e2e_config["accounts.licensee.account.id"]
7+
8+
9+
@pytest.fixture
10+
def licensee_group_id(e2e_config):
11+
return e2e_config["accounts.licensee.group.id"]
12+
13+
14+
@pytest.fixture
15+
def licensee_id(e2e_config):
16+
return e2e_config["accounts.licensee.id"]
17+
18+
19+
@pytest.fixture
20+
def invalid_licensee_id():
21+
return "LCE-0000-0000-0000"
22+
23+
24+
@pytest.fixture
25+
def licensee_factory(seller_id, buyer_id, user_group_factory, licensee_account_id):
26+
def _licensee(
27+
name: str = "Test E2E Licensee",
28+
licensee_type: str = "Client",
29+
):
30+
group = user_group_factory(user_group_account_id=licensee_account_id)
31+
32+
return {
33+
"name": name,
34+
"address": {
35+
"addressLine1": "456 Licensee St",
36+
"city": "Los Angeles",
37+
"state": "CA",
38+
"postCode": "67890",
39+
"country": "US",
40+
},
41+
"useBuyerAddress": False,
42+
"seller": {"id": seller_id},
43+
"buyer": {"id": buyer_id},
44+
"account": {"id": licensee_account_id},
45+
"eligibility": {"client": True, "partner": False},
46+
"groups": [group],
47+
"type": licensee_type,
48+
"status": "Enabled",
49+
"defaultLanguage": "en-US",
50+
}
51+
52+
return _licensee
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
3+
4+
@pytest.fixture
5+
def invalid_module_id():
6+
return "MOD-0000"
7+
8+
9+
@pytest.fixture
10+
def module_name(e2e_config):
11+
return e2e_config["accounts.module.name"]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import pytest
2+
3+
4+
@pytest.fixture
5+
def invalid_seller_id():
6+
return "SEL-0000-0000"
7+
8+
9+
@pytest.fixture
10+
def seller_factory(currencies):
11+
def _seller(
12+
external_id: str, # Must be unique in Marketplace
13+
name="E2E Test Seller",
14+
currencies=currencies,
15+
):
16+
return {
17+
"name": name,
18+
"address": {
19+
"addressLine1": "123 Main St",
20+
"city": "Anytown",
21+
"state": "CA",
22+
"postCode": "12345",
23+
"country": "US",
24+
},
25+
"currencies": currencies,
26+
"externalId": external_id,
27+
}
28+
29+
return _seller
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import pytest
2+
3+
4+
@pytest.fixture
5+
def invalid_user_group_id():
6+
return "UGR-0000-0000"

0 commit comments

Comments
 (0)