Skip to content

Commit ed135b4

Browse files
author
konstantina
committed
Fixed issue: Disqus comment is not created when library has no examples.
Modified test_target_libraries.py in order to collect all libraries (with and without examples) and examples urls of target libraries.
1 parent a07320d commit ed135b4

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

tests/target_libraries/test_target_libraries.py

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
LOG_FILE = LOGFILE_PREFIX.format(log_name="test_target_libraries")
88

9+
GET_ALL_LIBRARIES_URLS_SCRIPT = "return $('.library_link').map(function() {{ return this.href; }}).toArray();"
10+
911
GET_ALL_LIBRARIES_SCRIPT = """
1012
var libraries = {};
1113
$('#mycontainer').find('.library-expand-handle').map(function () {
@@ -23,27 +25,48 @@
2325
return examples;
2426
"""
2527

26-
2728
class TestLibraryExamples(SeleniumTestCase):
2829

2930
def test_compile_target_libraries(self):
3031
targets = pytest.config.getoption("--libraries").split(',')
3132

3233
self.open('/libraries')
34+
# Collects all libraries names.
3335
libraries = self.execute_script(GET_ALL_LIBRARIES_SCRIPT, '$')
34-
36+
# Collects all libraries urls.
37+
libraries_urls = self.execute_script(GET_ALL_LIBRARIES_URLS_SCRIPT, '$')
38+
# List containing all the urls (libraries_urls and examples_urls) that we should comment and compile.
3539
urls_to_follow = []
40+
# List containing library's examples urls.
41+
library_examples_urls =[]
42+
library_examples_urls_dic ={}
43+
3644
for target in targets:
37-
target = target.lower()
38-
if target in libraries:
39-
library_url = libraries[target]
40-
self.open(library_url)
41-
urls_to_follow += self.execute_script(GET_LIBRARY_EXAMPLES_SCRIPT, '$')
45+
for url in libraries_urls:
46+
library_url_name=url.split('/')[-1]
47+
if ( library_url_name != target):
48+
continue
49+
else:
50+
library_url = url
51+
# Updates urls_to_follow list with library's url.
52+
urls_to_follow.append(library_url)
53+
target = target.lower()
54+
if target in libraries:
55+
library = libraries[target]
56+
self.open(library)
57+
# Get library's name.
58+
library_name =library.split('/')[2]
59+
# Collect library's examples, if any.
60+
library_examples_urls = self.execute_script(GET_LIBRARY_EXAMPLES_SCRIPT, '$')
61+
# Add library with examples urls in a dictionary.
62+
library_examples_urls_dic[library_name]=library_examples_urls
63+
# Updates urls_to_follow list with library's examples urls.
64+
urls_to_follow += self.execute_script(GET_LIBRARY_EXAMPLES_SCRIPT, '$')
4265

4366
if len(urls_to_follow) > 0:
4467
"""Tests that specific library examples compile successfully."""
45-
self.compile_sketches(urls_to_follow,
46-
compile_type='target_library',
47-
iframe=False, project_view=True,
48-
create_report=True, logfile=LOG_FILE,
49-
comment=True)
68+
self.comment_compile_libraries_examples(urls_to_follow, library_examples_urls_dic,
69+
compile_type='target_library',
70+
iframe=False, project_view=True,
71+
create_report=True, logfile=LOG_FILE,
72+
comment=True)

0 commit comments

Comments
 (0)