PageRenderTime 43ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test.sh

http://googlecl.googlecode.com/
Shell | 138 lines | 117 code | 15 blank | 6 comment | 19 complexity | dc50d3991e459fb2d25fb8bc2c43e7cc MD5 | raw file
  1. #!/bin/bash
  2. TOUCH_PREFIX="tested_"
  3. GOOGLE_SH=./google.py
  4. # List of commands to set by each function
  5. declare -a commands
  6. # Commands to run for cleaning up test account
  7. #declare -a cleanup_commands
  8. function blogger {
  9. echo 'This is my post from a file\nIt contains a few line breaks, but not much else.' > test_post.txt
  10. commands[0]='blogger post --tags delete test_post.txt'
  11. commands[1]='blogger list --fields title,author'
  12. commands[2]='blogger post -n CL_post_test "This is my post from a command line"'
  13. commands[3]='blogger tag CL_post_ delete'
  14. commands[4]='blogger delete CL_post_test test_post ^New post$ --yes'
  15. }
  16. function calendar {
  17. commands[0]='calendar add "test event at 5pm on 10/10/10"'
  18. commands[1]='calendar add "test event at midnight on 10/10/10"'
  19. commands[2]='calendar add "test event today at 3" --reminder 1h'
  20. commands[3]='calendar today'
  21. commands[4]='calendar list --date 2010-10-10'
  22. commands[5]='calendar delete --date 10/10/10 test --yes'
  23. commands[6]='calendar delete --date today@3 test'
  24. }
  25. function contacts {
  26. echo -e 'contacts csv1, test_csv1@eh.com\ncontacts csv2, test_csv2@eh.com' > contacts.csv
  27. # commands[0]='contacts add "contacts test1,test_email1@nowhere.com" "contacts test2,test_email2@nowhere.com"'
  28. commands[1]='contacts add contacts.csv'
  29. commands[2]='contacts add "contacts test1,test_email1@nowhere.com"'
  30. commands[3]='contacts list contacts' # Assumes that "fields" is specified in config file
  31. commands[4]='contacts add-groups test_group'
  32. commands[5]='contacts list-groups'
  33. commands[6]='contacts delete-groups test_group --yes'
  34. commands[7]='contacts delete test[0-9]?_?'
  35. }
  36. function docs {
  37. echo -e 'This is a document that I am about to upload.' > test_doc.txt
  38. commands[0]='docs upload test_doc.txt'
  39. commands[1]='docs get test_doc test_download.txt'
  40. commands[2]='docs list --fields title,url-direct --delimiter ": "'
  41. commands[3]='docs edit test_doc --editor vim'
  42. commands[4]='docs delete test_doc'
  43. }
  44. function finance {
  45. commands[0]='finance create my_empty_pfl USD'
  46. commands[1]='finance create-pos my_empty_pfl NASDAQ:MSFT'
  47. commands[2]='finance create-txn my_empty_pfl NASDAQ:MSFT Sell'
  48. commands[3]='finance list'
  49. commands[4]='finance list-pos --title=.*'
  50. commands[5]='finance list-txn --title=.* --ticker=NASDAQ:MSFT'
  51. commands[6]='finance delete-txn'
  52. commands[7]='finance delete-pos'
  53. commands[8]='finance delete my_empty'
  54. }
  55. function picasa {
  56. commands[0]='picasa create test_album --tags "test, Disney World, florida, vacation" ~/testphotos/IMG_9882.JPG'
  57. commands[1]='picasa create test_album2'
  58. commands[2]='picasa list --fields title,url-site -q test'
  59. commands[3]='picasa list-albums'
  60. commands[4]='picasa delete "nosuchalbumexists"'
  61. commands[5]='picasa get "test_album" .'
  62. commands[6]='picasa post -n "test_album" --tags "Disney World, florida, vacation" ~/testphotos/IMG_9883.JPG'
  63. commands[7]='picasa tag "nosuchalbumexists" -t tag1,tag2'
  64. commands[8]='picasa tag "test_album" -t --,tag1,tag2'
  65. commands[9]='picasa delete test_album'
  66. }
  67. function youtube {
  68. commands[0]='youtube post ~/testclips/fighting_cats4.mp4 -n "New test cat movie" -s "More cats on youtube" Education --tags test,cats'
  69. commands[1]='youtube list'
  70. commands[2]='youtube tag cat optionless_tag'
  71. commands[3]='youtube tag -n "D_N_E" -t wontgothrough'
  72. commands[4]='youtube post ~/D_N_E -n failure -c Education'
  73. commands[5]='youtube delete New'
  74. }
  75. function goog_help {
  76. commands[0]="help"
  77. }
  78. prompt_quit() {
  79. echo Hit Ctrl-C again to exit, enter to skip current command
  80. read junk
  81. }
  82. trap prompt_quit INT
  83. if [ ${#@} -eq 1 ] && [ $@ == all ]; then
  84. TASKS=( blogger calendar contacts docs picasa youtube )
  85. else
  86. TASKS=$@
  87. fi
  88. for task in ${TASKS[*]}
  89. do
  90. unset commands
  91. echo -e "\n"
  92. echo ===$task===
  93. if [ $task == blogger ]; then
  94. blogger
  95. fi
  96. if [ $task == calendar ]; then
  97. calendar
  98. fi
  99. if [ $task == contacts ]; then
  100. contacts
  101. fi
  102. if [ $task == docs ]; then
  103. docs
  104. fi
  105. if [ $task == finance ]; then
  106. finance
  107. fi
  108. if [ $task == picasa ]; then
  109. picasa
  110. fi
  111. if [ $task == youtube ]; then
  112. youtube
  113. fi
  114. if [ $task == help ]; then
  115. goog_help
  116. fi
  117. # Make note of which tasks have been run, for cleanup later
  118. eval touch "$TOUCH_PREFIX$task"
  119. for index in ${!commands[*]}; do
  120. echo -e "\n===${commands[$index]}"
  121. eval $GOOGLE_SH ${commands[$index]}
  122. done
  123. done