Skip to content

Commit 9934a00

Browse files
committed
mirrors: add conftest for mirrors
1 parent c47aacb commit 9934a00

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

mirrors/tests/conftest.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import pytest
2+
3+
from mirrors.models import CheckLocation, MirrorUrl, MirrorProtocol, Mirror
4+
5+
6+
NAME = 'mirror1'
7+
ADMIN_EMAIL = '[email protected]'
8+
HOSTNAME = 'archlinux.org'
9+
SOURCE_IP = '127.0.0.1'
10+
COUNTRY = 'DE'
11+
PROTOCOL = 'https'
12+
URL = '{}://{}'.format(PROTOCOL, HOSTNAME)
13+
14+
15+
@pytest.fixture
16+
def mirror(db, name=NAME, admin_email=ADMIN_EMAIL):
17+
mirror = Mirror.objects.create(name=name,
18+
admin_email=admin_email)
19+
yield mirror
20+
mirror.delete()
21+
22+
23+
@pytest.fixture
24+
def checklocation(db, hostname=HOSTNAME, source_ip=SOURCE_IP, country=COUNTRY):
25+
checkloc = CheckLocation.objects.create(hostname=hostname,
26+
source_ip=source_ip,
27+
country=country)
28+
yield checkloc
29+
checkloc.delete()
30+
31+
32+
@pytest.fixture
33+
def mirrorprotocol(db, protocol=PROTOCOL):
34+
mirror_protocol = MirrorProtocol.objects.create(protocol=protocol)
35+
yield mirror_protocol
36+
mirror_protocol.delete()
37+
38+
39+
@pytest.fixture
40+
def mirrorurl(db, mirror, mirrorprotocol, country=COUNTRY,
41+
url=URL):
42+
mirror_url = MirrorUrl.objects.create(url=url,
43+
protocol=mirrorprotocol,
44+
mirror=mirror,
45+
country=country)
46+
yield mirror_url
47+
mirror_url.delete()

0 commit comments

Comments
 (0)