9
9
10
10
11
11
def _rel_path (* args ):
12
- """Forms a path relative to this file's directory."""
12
+ """Returns a path relative to config.py file's directory."""
13
13
return os .path .join (os .path .dirname (__file__ ), * args )
14
14
15
15
def get_path (directory , filename = None ):
16
+ """Returns an absolute path as seen from your current working directory.
17
+ If a file is passed as argument, returns an aboslute path including the
18
+ file."""
16
19
path = os .path .join (os .path .dirname ( __file__ ), '..' , directory )
17
20
if filename :
18
21
path = os .path .join (os .path .dirname ( __file__ ), '..' , directory , filename )
@@ -21,16 +24,12 @@ def get_path(directory, filename=None):
21
24
def jsondump (data ):
22
25
return simplejson .dumps (data , sort_keys = True , indent = 4 * ' ' )
23
26
24
- # URL of the default site to be used for testing
27
+ # URL of the default site to be used for testing.
25
28
BASE_URL = "http://localhost"
26
- # URL of the actual Codebender website
29
+ # URL of the actual Codebender website.
27
30
LIVE_SITE_URL = "https://codebender.cc"
28
31
STAGING_SITE_URL = "https://staging.codebender.cc"
29
32
30
- # Names of sources (i.e. repositories) used to generate the codebender site.
31
- SOURCE_BACHELOR = 'bachelor'
32
- SOURCE_CODEBENDER_CC = 'codebender_cc'
33
-
34
33
# User whose projects we'd like to compile in our compile_tester
35
34
# test case(s).
36
35
COMPILE_TESTER_URL = "/user/cb_compile_tester"
@@ -41,42 +40,42 @@ def jsondump(data):
41
40
# be formatted appropriately.
42
41
LOGFILE_PREFIX = _rel_path (".." , "logs" , "%Y-%m-%d_%H-%M-%S-{log_name}.json" )
43
42
44
- # Logfile for COMPILE_TESTER compilation results
43
+ # Logfile for COMPILE_TESTER compilation results.
45
44
COMPILE_TESTER_LOGFILE = LOGFILE_PREFIX .format (log_name = "cb_compile_tester" )
46
45
COMPILE_TESTER_LOGFILE_STAGING = LOGFILE_PREFIX .format (log_name = "staging_cb_compile_tester" )
47
46
48
- # Logfile for /libraries compilation results
47
+ # Logfile for /libraries compilation results.
49
48
LIBRARIES_TEST_LOGFILE = LOGFILE_PREFIX .format (log_name = "libraries_test" )
50
49
51
- # Logfile for /libraries fetch results
50
+ # Logfile for /libraries fetch results.
52
51
LIBRARIES_FETCH_LOGFILE = LOGFILE_PREFIX .format (log_name = "libraries_fetch" )
53
52
53
+ # Directory in which Firefox and Chrome extensions are stored.
54
54
_EXTENSIONS_DIR = _rel_path ('..' , 'extensions' )
55
+
56
+ # Firefox plugin for all Firefox versions.
55
57
_FIREFOX_EXTENSION_FNAME = 'codebender.xpi'
58
+ # Chrome extension for Chrome versions < 42.
56
59
_CHROME_EXTENSION_FNAME = 'codebendercc-extension.crx'
60
+ # Chrome extension for Chrome versions >= 42.
61
+ _CHROME_APP_FNAME = 'chrome-app-1.0.0.8.zip'
57
62
58
63
# Maximum version number that we can use the Chrome extension with.
59
- # For versions higher than this, we need to use the newer Codebender app
64
+ # For versions higher than this, we need to use the newer Codebender app.
60
65
CHROME_EXT_MAX_CHROME_VERSION = 41
61
66
62
- # Path to YAML file specifying capability list
67
+ # Path to YAML file specifying capability list.
63
68
DEFAULT_CAPABILITIES_FILE = os .getenv ('CAPABILITIES' , 'capabilities.yaml' )
64
69
DEFAULT_CAPABILITIES_FILE_PATH = _rel_path (DEFAULT_CAPABILITIES_FILE )
65
70
66
- # Files used for testing
71
+ # Files used for testing.
67
72
TEST_DATA_DIR = _rel_path ('..' , 'test_data' )
68
73
TEST_DATA_INO = os .path .join (TEST_DATA_DIR , 'upload_ino.ino' )
69
74
TEST_DATA_ZIP = os .path .join (TEST_DATA_DIR , 'upload_zip.zip' )
70
75
71
76
# Directory in which the local compile tester files are stored.
72
77
COMPILE_TESTER_DIR = os .path .join (TEST_DATA_DIR , 'cb_compile_tester' )
73
78
74
- # Credentials to use when logging into the bachelor site
75
- TEST_CREDENTIALS = {
76
- "username" : "tester" ,
77
- "password" : "testerPASS"
78
- }
79
-
80
79
TEST_PROJECT_NAME = "test_project"
81
80
82
81
TIMEOUT = {
@@ -86,7 +85,12 @@ def jsondump(data):
86
85
DEFAULT_USER_AGENT = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0 codebender-selenium'
87
86
TESTS_USER_AGENT = os .getenv ('SELENIUM_USER_AGENT' , DEFAULT_USER_AGENT )
88
87
89
- # Set up Selenium Webdrivers to be used for selenium tests
88
+ DEFAULT_USER_AGENT_CHROME = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36'
89
+ TESTS_USER_AGENT_CHROME = os .getenv ('SELENIUM_USER_AGENT_CHROME' , DEFAULT_USER_AGENT_CHROME )
90
+
91
+ BROWSER = "firefox"
92
+
93
+ # Set up Selenium Webdrivers to be used for selenium tests.
90
94
def _get_firefox_profile ():
91
95
"""Returns the Firefox profile to be used for the FF webdriver.
92
96
Specifically, we're equipping the webdriver with the Codebender
@@ -131,26 +135,20 @@ def create_webdriver(command_executor, desired_capabilities):
131
135
browser_profile_path = None
132
136
133
137
if browser_name == "chrome" :
138
+ BROWSER = "chrome"
134
139
desired_capabilities = DesiredCapabilities .CHROME .copy ()
135
140
desired_capabilities .update (_capabilities )
136
-
137
- # NOTE: the following logic is disabled since the remote webdriver is
138
- # not properly installing the codebender extension. It is kept for
139
- # reference until we can figure out how to properly add the Chrome
140
- # extension.
141
-
142
- # # Add chrome extension to capabilities
143
- # options = chrome.options.Options()
144
- # options.add_extension(os.path.join(_EXTENSIONS_DIR, _CHROME_EXTENSION_FNAME))
145
- # desired_capabilities.update(options.to_capabilities())
146
- # # Right now we only support up to v41 for this testing suite.
147
- # if "version" in desired_capabilities:
148
- # if desired_capabilities["version"] > CHROME_EXT_MAX_CHROME_VERSION:
149
- # raise ValueError("The testing suite only supports Chrome versions up to v%d, "
150
- # "but v%d was specified. Please specify a lower version "
151
- # "number." % (CHROME_EXT_MAX_CHROME_VERSION, desired_capabilities["version"]))
152
- # else:
153
- # desired_capabilities["version"] = CHROME_EXT_MAX_CHROME_VERSION
141
+ if desired_capabilities ["version" ] > CHROME_EXT_MAX_CHROME_VERSION :
142
+ # Add new chrome extension to capabilities.
143
+ options = chrome .options .Options ()
144
+ options .add_extension (os .path .join (_EXTENSIONS_DIR , _CHROME_APP_FNAME ))
145
+ options .add_argument ("--user-agent=" + TESTS_USER_AGENT_CHROME )
146
+ desired_capabilities .update (options .to_capabilities ())
147
+ desired_capabilities .update (_capabilities )
148
+ else :
149
+ raise ValueError ("The testing suite only supports Chrome versions greater than v%d, "
150
+ "but v%d was specified. Please specify a higher version number."
151
+ % (CHROME_EXT_MAX_CHROME_VERSION , desired_capabilities ["version" ]))
154
152
155
153
elif browser_name == "firefox" :
156
154
desired_capabilities = DesiredCapabilities .FIREFOX .copy ()
0 commit comments