1
1
from codebender_testing .config import LIBRARIES_TEST_LOGFILE
2
2
from codebender_testing .utils import SeleniumTestCase
3
3
4
+ GET_SKETCHES_SCRIPT = "return $('{selector}').map(function() {{ return this.href; }}).toArray();"
4
5
6
+ GET_ALL_LIBRARIES_EXAMPLES_URLS_SCRIPT = """
7
+ var librariesMap = {};
8
+ var machineNameFilter = /.+\(\s(.+)\.h\s\)/;
9
+ var accordionHeadings = $('#mycontainer').find('.accordion-heading');
10
+ $.each(accordionHeadings, function (key, value) {{
11
+ var libraryName = $(value).text().trim();
12
+ if (machineNameFilter.test(libraryName)) {{
13
+ libraryName = libraryName.match(machineNameFilter)[1].trim();
14
+ }}
15
+ if (!librariesMap.hasOwnProperty(libraryName)) {{
16
+ librariesMap[libraryName] = [];
17
+ }}
18
+
19
+ var examples = $(value).parent().find('.accordion-body').find('li a');
20
+
21
+ $.each(examples, function (k, v) {{
22
+ var href = $(v).attr('href');
23
+ librariesMap[libraryName].push(href);
24
+ }});
25
+ }});
26
+ console.log(librariesMap);
27
+ return librariesMap;
28
+ """
5
29
class TestLibraryExamples (SeleniumTestCase ):
6
30
7
31
def test_compile_all_libraries (self ):
8
- """Tests that all library examples compile successfully."""
9
- self .compile_all_sketches ('/libraries' , '.accordion li a' ,
10
- compile_type = 'library' ,
11
- iframe = False , project_view = True ,
12
- create_report = True , logfile = LIBRARIES_TEST_LOGFILE ,
13
- comment = True )
32
+ url = '/libraries'
33
+ self .open (url )
34
+
35
+ examples = self .execute_script (GET_SKETCHES_SCRIPT .format (selector = '.accordion li a' ), '$' )
36
+ assert len (examples ) > 0
37
+ libraries = self .execute_script (GET_SKETCHES_SCRIPT .format (selector = '.library_link' ), '$' )
38
+ assert len (libraries ) > 0
39
+ examples_libraries = examples + libraries
40
+
41
+ """Tests that all library examples compile successfully and comments on library url page and on its examples."""
42
+ library_examples_urls = self .execute_script (GET_ALL_LIBRARIES_EXAMPLES_URLS_SCRIPT , '$' )
43
+
44
+ self .comment_compile_libraries_examples (examples_libraries , library_examples_urls ,
45
+ compile_type = 'library' , iframe = False ,
46
+ project_view = True , create_report = True ,
47
+ logfile = LIBRARIES_TEST_LOGFILE , comment = True )
0 commit comments