Skip to content

Commit 279ced9

Browse files
committed
Corrected resume of examples test.
Using the full URL when logging the comments into the libraries.
1 parent 9552276 commit 279ced9

File tree

2 files changed

+36
-33
lines changed

2 files changed

+36
-33
lines changed

codebender_testing/disqus.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ def update_comment(self, sketch, results, current_date, log_entry, openFailFlag,
6363
`self.last_library`: The library in which belongs the previously compiled example.
6464
`library_to_comment`: The library in which a comment should be added.
6565
"""
66-
library_match = re.match(r'.+\/example\/(.+)\/.+', sketch)
66+
library_match = re.match(r'(.+)\/example\/(.+)\/.+', sketch)
6767
library = None
6868
library_to_comment = None
6969

7070
# Set the library in which belongs the currently compiled example.
7171
if library_match:
72-
library = library_match.group(1)
72+
library = library_match.group(2)
73+
domain = library_match.group(1)
7374

7475
# Check if the currently compiled example belongs to the same library as the previous one.
7576
# To do so we check if value of library is the same with self.last library value which is updated
@@ -79,7 +80,7 @@ def update_comment(self, sketch, results, current_date, log_entry, openFailFlag,
7980

8081
# Check if we should add a comment to the library.
8182
if library_to_comment and library not in self.examples_without_library:
82-
log_entry = self.handle_library_comment(library_to_comment, current_date, log_entry)
83+
log_entry = self.handle_library_comment(library_to_comment, domain, current_date, log_entry)
8384

8485
self.last_library = library
8586
# Add a comment to the currently compiled library example.
@@ -88,14 +89,15 @@ def update_comment(self, sketch, results, current_date, log_entry, openFailFlag,
8889

8990
return log_entry
9091

91-
def handle_library_comment(self, library, current_date, log, examples=True):
92+
def handle_library_comment(self, library, domain, current_date, log, examples=True):
9293
url = '/library/' + library
9394
identifier = 'ident:' + url
95+
full_url = domain + url
9496

9597
if url not in log:
96-
log[url] = {}
98+
log[full_url] = {}
9799
try:
98-
log[url]['comment'] = False
100+
log[full_url]['comment'] = False
99101

100102
""" Returns a Paginator object that matches the desired criteria:
101103
`self.disqus.api.threads.list`: Returns a list containg all urls in which Disqus loaded.
@@ -122,17 +124,17 @@ def handle_library_comment(self, library, current_date, log, examples=True):
122124

123125
# If library already has a comment, update it.
124126
if post_id and existing_message:
125-
log[url]['comment'] = self.update_post(post_id, new_message)
127+
log[full_url]['comment'] = self.update_post(post_id, new_message)
126128
comment_updated = True
127129
break
128130

129131
# If library doesn't have a comment, create it.
130132
if not comment_updated:
131-
log[url]['comment'] = self.create_post(identifier, new_message)
133+
log[full_url]['comment'] = self.create_post(identifier, new_message)
132134

133135
except Exception as error:
134136
print 'Error:', error
135-
log[url]['comment'] = False
137+
log[full_url]['comment'] = False
136138

137139
return log
138140

codebender_testing/utils.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -643,33 +643,34 @@ def comment_compile_libraries_examples(self, sketches, library_examples_dic={},
643643

644644
total_sketches = len(urls_to_visit)
645645
tic = time.time()
646-
library_re = re.compile(r'^.+/library/.+$')
646+
library_re = re.compile(r'^(.+)/library/.+$')
647647

648648
for url in urls_to_visit:
649-
if library_re.match(url):
649+
library_match = library_re.match(url)
650+
if library_match:
650651
library = url.split('/')[-1]
651-
try:
652-
# Comment libraries without examples
653-
if len(library_examples_dic[library]) == 0:
654-
if logfile is None or not self.run_full_compile_tests:
655-
toc = time.time()
656-
continue
657-
658-
# Update Disqus comments.
659-
current_date = strftime('%Y-%m-%d', log_time)
660-
if comment and compile_type in ['library', 'target_library']:
661-
self.open(url)
662-
self.get_element(By.CSS_SELECTOR, '#mycontainer h1')
663-
examples = False
664-
log_entry = disqus_wrapper.handle_library_comment(library, current_date, log_entry, examples)
665-
self.create_log(log_file, log_entry, compile_type)
666-
667-
test_status = '.'
668-
if not log_entry[url]['comment']:
669-
test_status = 'F'
670-
display_progress(test_status)
671-
except Exception as error:
672-
print error
652+
653+
# Comment libraries without examples
654+
if len(library_examples_dic[library]) == 0:
655+
if logfile is None or not self.run_full_compile_tests:
656+
toc = time.time()
657+
continue
658+
659+
test_status = 'F'
660+
661+
# Update Disqus comments.
662+
current_date = strftime('%Y-%m-%d', log_time)
663+
if comment and compile_type in ['library', 'target_library']:
664+
self.open(url)
665+
self.get_element(By.CSS_SELECTOR, '#mycontainer h1')
666+
examples = False
667+
domain = library_match.group(1)
668+
log_entry = disqus_wrapper.handle_library_comment(library, domain, current_date, log_entry, examples)
669+
if url in log_entry and log_entry[url]['comment']:
670+
test_status = '.'
671+
self.create_log(log_file, log_entry, compile_type)
672+
673+
display_progress(test_status)
673674

674675
toc = time.time()
675676
if (toc - tic) >= SAUCELABS_TIMEOUT_SECONDS:

0 commit comments

Comments
 (0)