Skip to content

Commit e5a5151

Browse files
committed
Merge pull request #24 from codebendercc/tests_improvements
Tests improvements
2 parents 1bfefe5 + 90982c7 commit e5a5151

File tree

11 files changed

+178
-80
lines changed

11 files changed

+178
-80
lines changed

bin/config.cfg.template

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ SAUCELABS_USER: ~
44
SAUCELABS_KEY: ~
55
SAUCELABS_HUB_URL: http://SAUCELABS_USER:[email protected]:80/wd/hub
66
LOCAL_HUB_URL: http://127.0.0.1:4444/wd/hub
7-
DISQUS_SSO_ID: ~
8-
DISQUS_SSO_USERNAME: ~
9-
DISQUS_SSO_EMAIL: ~
107
CODEBENDER_TEST_USER: ~
118
CODEBENDER_TEST_PASS: ~
129
EMAIL: ~
@@ -17,13 +14,19 @@ DISQUS_ACCESS_TOKEN: ~
1714
DISQUS_API_SECRET: ~
1815
DISQUS_API_PUBLIC: ~
1916
DISQUS_FORUM: ~
17+
DISQUS_SSO_ID: ~
18+
DISQUS_SSO_USERNAME: ~
19+
DISQUS_SSO_EMAIL: ~
2020
AUTHOR_URL: ~
2121

2222
[staging]
2323
DISQUS_ACCESS_TOKEN: ~
2424
DISQUS_API_SECRET: ~
2525
DISQUS_API_PUBLIC: ~
2626
DISQUS_FORUM: ~
27+
DISQUS_SSO_ID: ~
28+
DISQUS_SSO_USERNAME: ~
29+
DISQUS_SSO_EMAIL: ~
2730
AUTHOR_URL: ~
2831

2932
[local]

bin/seleniumbender.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ def __init__(self, url, environment):
2121
'.gitignore'
2222
]
2323

24-
def run(self, operation, libraries=None):
24+
def run(self, operation, test=None, libraries=None):
2525
if operation == 'common':
26-
self.common()
26+
self.common(test)
2727
elif operation == 'libraries':
2828
self.libraries()
2929
elif operation == 'examples':
@@ -38,6 +38,8 @@ def run(self, operation, libraries=None):
3838
self.walkthrough()
3939
elif operation == 'staging':
4040
self.staging()
41+
elif operation == 'delete':
42+
self.delete()
4143

4244
def run_command(self, command):
4345
command = ' '.join(command)
@@ -79,8 +81,11 @@ def send_mail_with_logs(self, identifier):
7981
def create_command(self, test_directory, *extra_arguments):
8082
return ['tox', 'tests/' + test_directory, '--', '--url={}'.format(TARGETS[self.url])] + list(extra_arguments)
8183

82-
def common(self, identifier='common'):
83-
command = self.create_command('common', '--plugin')
84+
def common(self, test, identifier='common'):
85+
test_directory = 'common'
86+
if test:
87+
test_directory = os.path.join(test_directory, test)
88+
command = self.create_command(test_directory, '--plugin')
8489
retval = self.run_command(command)
8590
if retval != 0:
8691
self.send_mail_no_logs(identifier)
@@ -128,6 +133,10 @@ def staging(self):
128133
command = self.create_command('compile_tester', '-F', '--plugin')
129134
self.run_command(command)
130135

136+
def delete(self):
137+
command = self.create_command('delete_sketches')
138+
self.run_command(command)
139+
131140
OPERATIONS = {
132141
'common':'\tTest site common functionality',
133142
'libraries': 'Visit all libraries and their examples',
@@ -136,7 +145,8 @@ def staging(self):
136145
'compile': '\tCompile specific examples',
137146
'noplugin': 'Run tests without app/plugin installed',
138147
'walkthrough': 'Run tests for walkthrough',
139-
'staging': '\tRun tests for staging only'
148+
'staging': '\tRun tests for staging only',
149+
'delete': '\tDelete all sketches from test user'
140150
}
141151

142152
TARGETS = {
@@ -189,9 +199,12 @@ def main():
189199
parser.add_argument('--config',
190200
default='config.cfg',
191201
help='Configuration file to load (default: config.cfg).')
202+
parser.add_argument('--test',
203+
default=None,
204+
help='Common test to run when using operation: common (default: all)')
192205
parser.add_argument('--libraries',
193206
default=None,
194-
help='Libraries to test (comma separated machine names) when using option: target')
207+
help='Libraries to test (comma separated machine names) when using operation: target')
195208
parser.add_argument('--saucelabs',
196209
action='store_true',
197210
default=False,
@@ -214,6 +227,8 @@ def main():
214227
parser.print_help()
215228
sys.exit()
216229

230+
test = args.test
231+
217232
libraries = args.libraries
218233
if operation == 'target' and not libraries:
219234
print('No target libraries specified!\n')
@@ -258,7 +273,7 @@ def main():
258273

259274
# Run tests
260275
tests = Tests(target, config)
261-
tests.run(operation, libraries=libraries)
276+
tests.run(operation, test=test, libraries=libraries)
262277

263278
if __name__ == '__main__':
264279
main()

codebender_testing/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ def jsondump(data):
8181

8282
TIMEOUT = {
8383
'LOCATE_ELEMENT': 30,
84-
'FLASH_FAIL': 30
84+
'FLASH_FAIL': 30,
85+
'VERIFY': 30,
86+
'FLASH': 30,
8587
}
8688

8789
DEFAULT_USER_AGENT_FIREFOX = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0 codebender-selenium'

codebender_testing/disqus.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,30 @@ def get_disqus_sso(self, user):
5858
return "{0} {1} {2}".format(message, sig, timestamp)
5959

6060
def update_comment(self, sketch, results, current_date, log_entry, openFailFlag, total_sketches):
61-
# Comment libraries
61+
"""A comment is added to the library as soon as its first example is compiled.
62+
`library`: The library in which belongs the currently compiled example.
63+
`self.last_library`: The library in which belongs the previously compiled example.
64+
`library_to_comment`: The library in which a comment should be added.
65+
"""
66+
6267
library_match = re.match(r'.+\/example\/(.+)\/.+', sketch)
6368
library = None
6469
library_to_comment = None
70+
6571
if library_match:
6672
library = library_match.group(1)
67-
if not self.last_library:
68-
self.last_library = library
69-
library_to_comment = library
7073

74+
#Check if the currently compiled example belongs to the same library as the previous one.
7175
if library != self.last_library:
7276
library_to_comment = library
7377

78+
#Check if we should add a comment to the library.
7479
if library_to_comment:
7580
log_entry = self.handle_library_comment(library_to_comment, current_date, log_entry)
7681

7782
self.last_library = library
7883

79-
# Comment examples
84+
#Add a comment to the currently compiled library example.
8085
if not openFailFlag:
8186
log_entry = self.handle_example_comment(sketch, results, current_date, log_entry)
8287

0 commit comments

Comments
 (0)