Skip to content

Commit d5a2f1b

Browse files
committed
Setup test-account email generation fixtures
Add an test-account email address generating fixture to conftest.py
1 parent c3a2b67 commit d5a2f1b

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

tests/api/test_licenses.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-

tests/conftest.py

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
# -*- coding: utf-8 -*-
2-
32
"""pytest configuration and top-level fixtures."""
43

5-
import pytest
64

5+
import string
76

8-
EMAIL_ADDRESSES = [
9-
10-
11-
]
7+
import pytest
128

139

1410
pytest_plugins = [
@@ -21,11 +17,48 @@
2117
'tests.api.test_teammemberships',
2218
'tests.api.test_teams',
2319
'tests.api.test_webhooks',
20+
'tests.api.test_organizations',
21+
'tests.api.test_licenses',
22+
'tests.api.test_roles',
2423
]
2524

2625

26+
TEST_DOMAIN = "cmlccie.com"
27+
28+
email_template = string.Template("test${number}@" + TEST_DOMAIN)
29+
_email_addresses = []
30+
31+
32+
# Helper Functions
33+
def new_email_generator():
34+
i = 0
35+
while True:
36+
email_address = email_template.substitute(number=i)
37+
_email_addresses.append(email_address)
38+
i += 1
39+
yield email_address
40+
41+
2742
# pytest Fixtures
2843

2944
@pytest.fixture(scope="session")
3045
def email_addresses():
31-
return EMAIL_ADDRESSES
46+
return _email_addresses
47+
48+
49+
@pytest.fixture(scope="session")
50+
def get_email_addresses():
51+
def inner_function(num):
52+
if len(email_addresses) < num:
53+
for i in range(num - len(email_addresses)):
54+
new_email_address()
55+
return email_addresses[:num]
56+
return inner_function
57+
58+
59+
@pytest.fixture(scope="session")
60+
def get_new_email_address():
61+
generator = new_email_generator()
62+
def inner_function():
63+
return generator.next()
64+
return inner_function

0 commit comments

Comments
 (0)