This repository has been archived by the owner on Jan 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
pavement.py
153 lines (123 loc) · 3.65 KB
/
pavement.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import os
import sys
sys.path.insert(0, os.path.dirname(__file__))
from path import Path as path # noqa
from pavelib.paver_utils import TestRunCommand, PaverTestCommand # noqa
from paver.easy import task, needs, consume_args, sh, BuildFailure # noqa
from pavelib.paver_consts import (
LOG_DIR,
REPORT_DIR,
E2E_TEST_REPORT,
SCREENSHOT_DIR,
BASELINE_DIR,
PAVER_TEST_REPORT_DIR,
UPLOAD_FILE_DIR,
WHITE_LABEL_TEST_REPORT,
ENTERPRISE_TEST_REPORT
) # noqa
@task
def configure_e2e_tests_pre_reqs():
# Make sure environment variables are set.
env_vars = [
'BASIC_AUTH_USER',
'BASIC_AUTH_PASSWORD',
'USER_LOGIN_EMAIL',
'USER_LOGIN_PASSWORD',
'COURSE_ORG',
'COURSE_NUMBER',
'COURSE_RUN',
'COURSE_DISPLAY_NAME'
]
for env_var in env_vars:
try:
os.environ[env_var]
except Exception:
raise BuildFailure(
"Please set the environment variable :" + env_var)
# Set environment variables for screen shots.
os.environ['NEEDLE_OUTPUT_DIR'] = SCREENSHOT_DIR
os.environ['NEEDLE_BASELINE_DIR'] = BASELINE_DIR
os.environ['UPLOAD_FILE_DIR'] = UPLOAD_FILE_DIR
# Create log directory
LOG_DIR.makedirs_p()
# Create report directory
REPORT_DIR.makedirs_p()
@task
@needs('configure_e2e_tests_pre_reqs')
@consume_args
def e2e_test(args):
sh(TestRunCommand.command(E2E_TEST_REPORT, args))
@task
def create_paver_report_directory():
PAVER_TEST_REPORT_DIR.makedirs_p()
@task
@needs('create_paver_report_directory')
@consume_args
def paver_cmd_test(args):
commandline_arg = ''
if not not args:
commandline_arg = path(args[0])
sh(PaverTestCommand.command(commandline_arg, 'paver_cmd_report.xml'))
@task
def wl_test_config():
# Make sure environment variables are set.
env_vars = [
'GLOBAL_PASSWORD'
]
for env_var in env_vars:
try:
os.environ[env_var]
except Exception:
raise BuildFailure(
"Please set the environment variable :" + env_var)
# Set environment variables for screen shots.
os.environ['NEEDLE_OUTPUT_DIR'] = SCREENSHOT_DIR
os.environ['NEEDLE_BASELINE_DIR'] = BASELINE_DIR
os.environ['UPLOAD_FILE_DIR'] = UPLOAD_FILE_DIR
# Create log directory
LOG_DIR.makedirs_p()
# Create report directory
REPORT_DIR.makedirs_p()
@task
@needs('wl_test_config')
@consume_args
def e2e_wl_test(args):
sh(TestRunCommand.command(WHITE_LABEL_TEST_REPORT, args, test_type='wl'))
@task
def configure_enterprise_tests_pre_reqs():
# Make sure environment variables are set.
env_vars = [
'BASIC_AUTH_USER',
'BASIC_AUTH_PASSWORD',
'ENT_PORTAL_USERNAME',
'ENT_PORTAL_PASSWORD',
'ENT_COURSE_TITLE',
'ENT_COURSE_ORG',
'ENT_COURSE_PRICE',
'ENT_COURSE_START_DATE'
]
for env_var in env_vars:
try:
os.environ[env_var]
except Exception:
raise BuildFailure(
"Please set the environment variable :" + env_var)
# Set environment variables for screen shots.
os.environ['NEEDLE_OUTPUT_DIR'] = SCREENSHOT_DIR
os.environ['NEEDLE_BASELINE_DIR'] = BASELINE_DIR
os.environ['UPLOAD_FILE_DIR'] = UPLOAD_FILE_DIR
# Create log directory
LOG_DIR.makedirs_p()
# Create report directory
REPORT_DIR.makedirs_p()
@task
@needs('configure_enterprise_tests_pre_reqs')
@consume_args
def enterprise_test(args):
sh(
TestRunCommand.command(
ENTERPRISE_TEST_REPORT,
args,
test_type='enterprise'
)
)