Advertisement
marksweb

fabfile.py

Jun 21st, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.14 KB | None | 0 0
  1. from fabric.api import *
  2. from fabric.contrib.console import confirm
  3. from fabric.decorators import hosts
  4. import os
  5.  
  6. def git_server():
  7.     env.hosts = ['github.com']
  8.     env.user = 'user'
  9.     env.passowrd = 'pass'
  10.  
  11. ## Selenium Tests                                            
  12. ##  | run test alone from cmd line with "fab function()"  
  13. ########################################################
  14. def addEmployer():
  15.     antTask = "addEmployer_git"
  16.     runAntTask(antTask)
  17.  
  18. def addEmployee():
  19.     antTask = "addEmployee_git"
  20.     runAntTask(antTask)
  21.  
  22. def deleteEmployee():
  23.     antTask = "deleteEmployee_git"
  24.     runAntTask(antTask)
  25.  
  26. def editEmployee():
  27.     antTask = "editEmployee_git"
  28.     runAntTask(antTask)
  29.  
  30. def viewEmployee():
  31.     antTask = "viewEmployee_git"
  32.     runAntTask(antTask)
  33.  
  34. # Run ANT task for Selenium process
  35. ####################################
  36. def runAntTask(command):
  37.     os.chdir('\\Work\main\employer_toolkit')
  38.     with settings(warn_only=True):
  39.         result = local('ant %s' % (command), capture=True)
  40.     if result.failed and not confirm("Tests failed. Continue anyway?"):
  41.         abort("Aborting at user request.")
  42.  
  43. ## Commit & Push to GitHub
  44. ###########################
  45. def deploy(process):
  46.     os.chdir('\\Documents and Settings\markw\GitTest')
  47.     local('git fetch')
  48.     local('git add -A')
  49.     commit = local('git commit -m "Latest Selenium screenshots for %s"' % (process))
  50.     if commit.failed:
  51.         sys.exit("%s files already up to date. Exiting." % process)
  52.     else:
  53.         local('git push --all')
  54.  
  55. ## Run Selenium Test & Deploy to Git                 
  56. ##  | run from cmd line with "fab function()"
  57. #############################################
  58. def addEmployerGit():
  59.     process = 'Add Employer'
  60.     addEmployer()
  61.     deploy(process)
  62.  
  63. def addEmployeeGit():
  64.     process = 'Add Employee'
  65.     addEmployee()
  66.     deploy(process)
  67.  
  68. def deleteEmployeeGit():
  69.     process = 'Delete Employee'
  70.     deleteEmployee()
  71.     deploy(process)
  72.  
  73. def editEmployeeGit():
  74.     process = 'Edit Employee'
  75.     editEmployee()
  76.     deploy(process)
  77.  
  78. def viewEmployeeGit():
  79.     process = 'View Employee'
  80.     viewEmployee()
  81.     deploy(process)
  82.  
  83. def allEmployeeGit():
  84.     process = 'All Employee Tests'
  85.     addEmployee()
  86.     viewEmployee()
  87.     editEmployee() 
  88.     deleteEmployee()
  89.     deploy(process)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement