Skip to content

Commit 341d67c

Browse files
committed
Added check to detect if we are on a library or example page,
when visiting all libraries an examples. Replaced hard-coded URLs with regular expressions, to be flexible in the test domain.
1 parent fcd5a0c commit 341d67c

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

codebender_testing/utils.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -532,21 +532,24 @@ def open_all_libraries_and_examples(self, url, logfile):
532532
compile_type = 'fetch'
533533
urls_to_visit, log_entry, log_file, log_time = self.resume_log(logfile, compile_type, examples_libraries)
534534

535-
library_re = re.compile(r'^https://codebender.cc/library/.+$')
536-
example_re = re.compile(r'^https://codebender.cc/example/.+/.+$')
535+
libraries_re = re.compile(r'/libraries$')
536+
library_re = re.compile(r'/library/.+$')
537+
example_re = re.compile(r'/example/.+/.+$')
537538

538539
print '\nVisiting:', len(urls_to_visit), 'URLs'
539540
tic = time.time()
540541
for url in urls_to_visit:
541542
self.open(url)
542-
url_name = url.split('/')[-1]
543-
name = self.get_element(By.CSS_SELECTOR, '#mycontainer h1 small').text
544-
name = re.sub('[()]', '', name).split('.')[0]
545-
if (name != url_name):
546-
print "Didn't open url: ", url
543+
self.get_element(By.CSS_SELECTOR, '#mycontainer h1')
544+
if library_re.match(url):
545+
url_name = url.split('/')[-1]
546+
name = self.get_element(By.CSS_SELECTOR, '#mycontainer h1 small').text
547+
name = re.sub('[()]', '', name).split('.')[0]
548+
if (name != url_name):
549+
print "Didn't open url: ", url
547550

548551
test_status = True
549-
if library_re.match(url) and self.driver.current_url == 'https://codebender.cc/libraries':
552+
if library_re.match(url) and libraries_re.match(self.driver.current_url):
550553
test_status = False
551554
elif example_re.match(url) and 'Sorry! The example could not be fetched.' in self.driver.page_source:
552555
test_status = False

0 commit comments

Comments
 (0)