Guest User

Untitled

a guest
Jun 22nd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. # June 20, 2018
  2. # Script to update browser test files
  3. # Darko
  4. ASYNC_PATH = '/Users/jmortenson/Code/zendesk/support-rule-admin/spec/browser/async/scenarios'
  5. SYNC_PATH = '/Users/jmortenson/Code/zendesk/support-rule-admin/spec/browser/scenarios'
  6.  
  7. # os.walk(path) returns a triple with: (full_path, list of subdirectories, list of files in path directory)
  8.  
  9. import os
  10.  
  11. for child in os.walk(ASYNC_PATH):
  12. if child[2] == []:
  13. continue
  14. for filename in child[2]:
  15. lines = []
  16. with open(child[0] + '/' + filename, 'r') as f:
  17. lines = f.readlines()
  18. for linenumber, line in enumerate(lines):
  19. if 'beforeEach(() => browser.respondWithAccount());' in line or 'beforeEach(() => browser.respondWithUser());' in line:
  20. indent = line[0:line.find('b')].count(' ') * ' '
  21. lines.insert(linenumber, indent + 'beforeEach(() => browser.respondWithTimezones());' + '\n')
  22. break
  23. with open(child[0] + '/' + filename, 'w') as f:
  24. f.writelines(lines)
  25.  
  26. for child in os.walk(SYNC_PATH):
  27. if child[2] == []:
  28. continue
  29. for filename in child[2]:
  30. lines = []
  31. with open(child[0] + '/' + filename, 'r') as f:
  32. lines = f.readlines()
  33. for linenumber, line in enumerate(lines):
  34. if 'browser.respondWithAccount();' in line or 'browser.respondWithUser();' in line:
  35. indent = line[0:line.find('b')].count(' ') * ' '
  36. lines.insert(linenumber, indent + 'browser.respondWithTimezones();' + '\n')
  37. break
  38. with open(child[0] + '/' + filename, 'w') as f:
  39. f.writelines(lines)
Add Comment
Please, Sign In to add comment