epc 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. data/lib/epc.rb +3 -0
  2. data/lib/epc/client/base_client.rb +2 -1
  3. data/lib/epc/client/json_client.rb +22 -0
  4. data/lib/epc/command/archive_command.rb +1 -1
  5. data/lib/epc/command/attachto_command.rb +1 -1
  6. data/lib/epc/command/base_command.rb +35 -25
  7. data/lib/epc/command/build_command.rb +2 -2
  8. data/lib/epc/command/config/create_config_command.rb +1 -1
  9. data/lib/epc/command/config/delete_config_command.rb +4 -4
  10. data/lib/epc/command/config/list_configs_command.rb +1 -1
  11. data/lib/epc/command/config/update_config_command.rb +3 -3
  12. data/lib/epc/command/copy_command.rb +1 -1
  13. data/lib/epc/command/create_command.rb +1 -1
  14. data/lib/epc/command/delete_command.rb +2 -2
  15. data/lib/epc/command/deploy_command.rb +4 -3
  16. data/lib/epc/command/deployment/copy_deployment_command.rb +1 -1
  17. data/lib/epc/command/deployment/create_deployment_command.rb +3 -3
  18. data/lib/epc/command/deployment/list_deployments_command.rb +1 -1
  19. data/lib/epc/command/deployment/show_deployment_command.rb +1 -1
  20. data/lib/epc/command/deployment/submit_deployment_command.rb +1 -1
  21. data/lib/epc/command/deployment/update_deployment_command.rb +1 -1
  22. data/lib/epc/command/deployment/vote_deployment_command.rb +1 -1
  23. data/lib/epc/command/deploymentstage/list_deploymentstages_command.rb +1 -1
  24. data/lib/epc/command/detachfrom_command.rb +1 -1
  25. data/lib/epc/command/group/create_group_command.rb +1 -1
  26. data/lib/epc/command/group/delete_group_command.rb +1 -1
  27. data/lib/epc/command/group/list_groups_command.rb +1 -1
  28. data/lib/epc/command/group/show_group_command.rb +2 -1
  29. data/lib/epc/command/group/update_group_command.rb +1 -1
  30. data/lib/epc/command/library/create_library_command.rb +2 -2
  31. data/lib/epc/command/library/delete_library_command.rb +1 -1
  32. data/lib/epc/command/library/list_libraries_command.rb +1 -1
  33. data/lib/epc/command/librarylanguage/create_librarylanguage_command.rb +1 -1
  34. data/lib/epc/command/librarylanguage/delete_librarylanguage_command.rb +1 -1
  35. data/lib/epc/command/librarylanguage/list_librarylanguages_command.rb +1 -1
  36. data/lib/epc/command/librarylanguage/update_librarylanguage_command.rb +1 -1
  37. data/lib/epc/command/libraryset/create_libraryset_command.rb +2 -2
  38. data/lib/epc/command/libraryset/delete_libraryset_command.rb +1 -1
  39. data/lib/epc/command/libraryset/list_librarysets_command.rb +1 -1
  40. data/lib/epc/command/libraryset/show_libraryset_command.rb +1 -1
  41. data/lib/epc/command/libraryset/update_libraryset_command.rb +3 -3
  42. data/lib/epc/command/list_command.rb +1 -1
  43. data/lib/epc/command/objectrole/create_objectrole_command.rb +2 -1
  44. data/lib/epc/command/objectrole/list_objectroles_command.rb +1 -1
  45. data/lib/epc/command/objectrole/update_objectrole_command.rb +5 -1
  46. data/lib/epc/command/permission/list_permissions_command.rb +1 -1
  47. data/lib/epc/command/permissiongroup/list_permissiongroups_command.rb +1 -1
  48. data/lib/epc/command/plugin/create_plugin_command.rb +1 -1
  49. data/lib/epc/command/plugin/delete_plugin_command.rb +1 -1
  50. data/lib/epc/command/plugin/list_plugins_command.rb +1 -1
  51. data/lib/epc/command/plugin/show_plugin_command.rb +1 -1
  52. data/lib/epc/command/plugin/update_plugin_command.rb +2 -2
  53. data/lib/epc/command/project/archive_project_command.rb +1 -1
  54. data/lib/epc/command/project/attachto_project_command.rb +3 -3
  55. data/lib/epc/command/project/create_project_command.rb +2 -2
  56. data/lib/epc/command/project/delete_project_command.rb +1 -1
  57. data/lib/epc/command/project/detachfrom_project_command.rb +4 -4
  58. data/lib/epc/command/project/list_projects_command.rb +1 -1
  59. data/lib/epc/command/project/show_project_command.rb +2 -1
  60. data/lib/epc/command/project/unarchive_project_command.rb +1 -2
  61. data/lib/epc/command/project/update_project_command.rb +2 -2
  62. data/lib/epc/command/projecttype/create_projecttype_command.rb +3 -3
  63. data/lib/epc/command/projecttype/delete_projecttype_command.rb +2 -1
  64. data/lib/epc/command/projecttype/list_projecttypes_command.rb +1 -1
  65. data/lib/epc/command/projecttype/show_projecttype_command.rb +2 -1
  66. data/lib/epc/command/projecttype/update_projecttype_command.rb +4 -3
  67. data/lib/epc/command/pull_command.rb +12 -10
  68. data/lib/epc/command/push_command.rb +45 -29
  69. data/lib/epc/command/role/create_role_command.rb +1 -1
  70. data/lib/epc/command/role/delete_role_command.rb +2 -1
  71. data/lib/epc/command/role/list_roles_command.rb +2 -5
  72. data/lib/epc/command/role/show_role_command.rb +2 -2
  73. data/lib/epc/command/role/update_role_command.rb +1 -1
  74. data/lib/epc/command/runtime/create_runtime_command.rb +1 -1
  75. data/lib/epc/command/runtime/delete_runtime_command.rb +2 -1
  76. data/lib/epc/command/runtime/list_runtimes_command.rb +1 -1
  77. data/lib/epc/command/runtime/update_runtime_command.rb +4 -3
  78. data/lib/epc/command/runtimetype/list_runtimetypes_command.rb +1 -1
  79. data/lib/epc/command/servicedefinition/create_servicedefinition_command.rb +2 -2
  80. data/lib/epc/command/servicedefinition/delete_servicedefinition_command.rb +1 -1
  81. data/lib/epc/command/servicedefinition/list_servicedefinitions_command.rb +1 -1
  82. data/lib/epc/command/servicetype/list_servicetypes_command.rb +1 -1
  83. data/lib/epc/command/serviceversion/create_serviceversion_command.rb +2 -2
  84. data/lib/epc/command/serviceversion/delete_serviceversion_command.rb +3 -1
  85. data/lib/epc/command/serviceversion/list_serviceversions_command.rb +1 -1
  86. data/lib/epc/command/show_command.rb +1 -1
  87. data/lib/epc/command/solution/archive_solution_command.rb +1 -1
  88. data/lib/epc/command/solution/create_solution_command.rb +2 -2
  89. data/lib/epc/command/solution/delete_solution_command.rb +1 -1
  90. data/lib/epc/command/solution/list_solutions_command.rb +1 -1
  91. data/lib/epc/command/solution/show_solution_command.rb +1 -1
  92. data/lib/epc/command/solution/unarchive_solution_command.rb +1 -1
  93. data/lib/epc/command/solution/update_solution_command.rb +1 -1
  94. data/lib/epc/command/submit_command.rb +1 -1
  95. data/lib/epc/command/unarchive_command.rb +1 -1
  96. data/lib/epc/command/update_command.rb +1 -1
  97. data/lib/epc/command/user/create_user_command.rb +1 -1
  98. data/lib/epc/command/user/delete_user_command.rb +1 -1
  99. data/lib/epc/command/user/list_users_command.rb +1 -1
  100. data/lib/epc/command/user/show_user_command.rb +2 -1
  101. data/lib/epc/command/user/update_user_command.rb +3 -3
  102. data/lib/epc/command/userproperty/delete_user_property_command.rb +48 -0
  103. data/lib/epc/command/userproperty/get_user_property_command.rb +61 -0
  104. data/lib/epc/command/userproperty/list_user_properties_command.rb +1 -1
  105. data/lib/epc/command/userproperty/set_user_property_command.rb +52 -0
  106. data/lib/epc/command/vote_command.rb +1 -1
  107. data/lib/epc/config.rb +12 -0
  108. data/lib/epc/help.rb +20 -8
  109. data/lib/epc/runner.rb +22 -11
  110. data/lib/epc/version.rb +1 -1
  111. data/test/command/archive_project_command_test.rb +1 -1
  112. data/test/command/archive_solution_command_test.rb +1 -1
  113. data/test/command/build_command_test.rb +1 -1
  114. data/test/command/copy_deployment_command_test.rb +1 -1
  115. data/test/command/create_config_command_test.rb +1 -1
  116. data/test/command/create_deployment_command_test.rb +3 -3
  117. data/test/command/create_group_command_test.rb +1 -1
  118. data/test/command/create_library_command_test.rb +1 -1
  119. data/test/command/create_librarylanguage_command_test.rb +2 -2
  120. data/test/command/create_libraryset_command_test.rb +2 -2
  121. data/test/command/create_objectrole_command_test.rb +1 -1
  122. data/test/command/create_project_command_test.rb +2 -2
  123. data/test/command/create_projecttypes_command_test.rb +33 -0
  124. data/test/command/create_role_command_test.rb +10 -1
  125. data/test/command/create_runtime_command_test.rb +1 -1
  126. data/test/command/create_servicedefinition_command_test.rb +1 -1
  127. data/test/command/create_serviceversion_command_test.rb +1 -1
  128. data/test/command/create_solution_command_test.rb +2 -2
  129. data/test/command/create_user_command_test.rb +1 -1
  130. data/test/command/delete_config_command_test.rb +3 -3
  131. data/test/command/delete_library_command_test.rb +1 -1
  132. data/test/command/delete_librarylanguage_command_test.rb +1 -1
  133. data/test/command/delete_libraryset_command_test.rb +1 -1
  134. data/test/command/delete_plugin_command_test.rb +1 -1
  135. data/test/command/delete_project_command_test.rb +1 -1
  136. data/test/command/delete_projecttype_command_test.rb +1 -1
  137. data/test/command/delete_role_command_test.rb +1 -1
  138. data/test/command/delete_runtime_command_test.rb +1 -1
  139. data/test/command/delete_servicedefinition_command_test.rb +1 -1
  140. data/test/command/delete_serviceversion_command_test.rb +1 -1
  141. data/test/command/delete_solution_command_test.rb +1 -1
  142. data/test/command/delete_user_command_test.rb +1 -1
  143. data/test/command/delete_user_property_command_test.rb +60 -0
  144. data/test/command/deploy_command_test.rb +14 -6
  145. data/test/command/get_user_property_command_test.rb +58 -0
  146. data/test/command/list_command_test.rb +28 -0
  147. data/test/command/list_config_command_test.rb +1 -1
  148. data/test/command/list_deployments_command_test.rb +1 -1
  149. data/test/command/list_deploymentstages_command_test.rb +1 -1
  150. data/test/command/list_libraries_command_test.rb +1 -1
  151. data/test/command/list_librarylanguages_command_test.rb +1 -1
  152. data/test/command/list_librarysets_command_test.rb +1 -1
  153. data/test/command/list_objectroles_command_test.rb +1 -1
  154. data/test/command/list_permissiongroups_command_test.rb +1 -1
  155. data/test/command/list_permissions_command_test.rb +1 -1
  156. data/test/command/list_plugins_command_test.rb +1 -1
  157. data/test/command/list_projects_command_test.rb +1 -1
  158. data/test/command/list_projecttypes_command_test.rb +1 -1
  159. data/test/command/list_roles_command_test.rb +9 -1
  160. data/test/command/list_runtimes_command_test.rb +1 -1
  161. data/test/command/list_runtimetypes_command_test.rb +1 -1
  162. data/test/command/list_service_types_command_test.rb +1 -1
  163. data/test/command/list_servicedefinitions_command_test.rb +1 -1
  164. data/test/command/list_serviceversions_command_test.rb +1 -1
  165. data/test/command/list_solutions_command_test.rb +1 -1
  166. data/test/command/list_userproperties_command_test.rb +3 -3
  167. data/test/command/list_users_command_test.rb +1 -1
  168. data/test/command/pull_command_test.rb +8 -8
  169. data/test/command/push_command_test.rb +38 -8
  170. data/test/command/set_user_property_command_test.rb +50 -0
  171. data/test/command/show_command_test.rb +28 -0
  172. data/test/command/show_deployment_command_test.rb +1 -1
  173. data/test/command/show_group_command_test.rb +1 -1
  174. data/test/command/show_libraryset_command_test.rb +1 -1
  175. data/test/command/show_plugin_command_test.rb +1 -1
  176. data/test/command/show_project_command_test.rb +1 -1
  177. data/test/command/show_projecttype_command_test.rb +1 -1
  178. data/test/command/show_role_command_test.rb +1 -1
  179. data/test/command/show_solution_command_test.rb +1 -1
  180. data/test/command/show_user_command_test.rb +1 -1
  181. data/test/command/submit_deployment_command_test.rb +1 -1
  182. data/test/command/unarchive_project_command_test.rb +1 -1
  183. data/test/command/unarchive_solution_command_test.rb +1 -1
  184. data/test/command/update_config_command_test.rb +2 -2
  185. data/test/command/update_deployment_command_test.rb +1 -1
  186. data/test/command/update_group_command_test.rb +1 -1
  187. data/test/command/update_librarylanguage_command_test.rb +1 -1
  188. data/test/command/update_libraryset_command_test.rb +3 -3
  189. data/test/command/update_plugin_command_test.rb +2 -2
  190. data/test/command/update_project_command_test.rb +2 -2
  191. data/test/command/update_solution_command_test.rb +1 -1
  192. data/test/command/update_user_command_test.rb +2 -2
  193. data/test/command/vote_deployment_command_test.rb +1 -1
  194. metadata +38 -23
@@ -27,7 +27,7 @@ class CreateRuntimeCommandTest < Test::Unit::TestCase
27
27
  should "report reason for request failure" do
28
28
  @command.expects(:retrieve_identifier_for).returns(1)
29
29
  @mock_client.expects(:post).with(EPC::Config::RUNTIMES_PATH, {:name => "runtime", :target => "runtime_target", :runtime_env_type_id => 1, :deployment_stage_id => 1, :username => "user", :password => "pass"}).returns([500, {:message => "System Exception"}, {}])
30
- @command.expects(:say).with("Request failed: [System Exception]")
30
+ @command.expects(:say_err).with("Request failed: [System Exception]")
31
31
  @command.execute(["runtime", "runtime_target", "Development", "user", "pass" ])
32
32
  end
33
33
 
@@ -16,7 +16,7 @@ class CreateServicedefinitionCommandTest < Test::Unit::TestCase
16
16
 
17
17
  should "fail if status is not 201" do
18
18
  @mock_client.expects(:post).with(EPC::Config::SERVICE_DEFINITIONS_PATH, {:name => "service", :type_id => 1}).returns([400, {:message => 'Not Found'}])
19
- @command.expects(:say).with("Service definition failed with: [Not Found]")
19
+ @command.expects(:say_err).with("Service definition failed with: [Not Found]")
20
20
  @command.execute(["service", "MySQL"])
21
21
  end
22
22
 
@@ -16,7 +16,7 @@ class CreateServiceversionCommandTest < Test::Unit::TestCase
16
16
  should "show a message if status is not 201" do
17
17
  @mock_client.expects(:post).with(EPC::Config::SERVICE_VERSIONS_PATH, {:label => "main_db", :service_definition_id => 1, :up_script => nil, :down_script => nil, :backwards_compatible => "false", :reversible => "false"}).
18
18
  returns([404, {:message => "Not Found"}, {}])
19
- @command.expects(:say).with("Request failed: [Not Found]")
19
+ @command.expects(:say_err).with("Request failed: [Not Found]")
20
20
 
21
21
  assert_equal(@command.execute(["main_db"]), 404)
22
22
  end
@@ -53,7 +53,7 @@ class CreateSolutionCommandTest < Test::Unit::TestCase
53
53
  command = EPC::Command::CreateSolutionCommand.new(@mock_client)
54
54
 
55
55
  @mock_client.expects(:post).with("/api/v1/solutions", { :name => "Test Solution" }).returns([400, { :message => "Bad Request" }, {}])
56
- command.expects(:say).with("Solution creation failed [Bad Request].")
56
+ command.expects(:say_err).with("Solution creation failed [Bad Request].")
57
57
 
58
58
  assert_equal(command.execute(["Test Solution"]), 400)
59
59
  end
@@ -62,7 +62,7 @@ class CreateSolutionCommandTest < Test::Unit::TestCase
62
62
  command = EPC::Command::CreateSolutionCommand.new(@mock_client)
63
63
 
64
64
  @mock_client.expects(:post).with("/api/v1/solutions", { :name => "Test Solution" }).raises(StandardError.new("failed"))
65
- command.expects(:say).with("Solution creation failed [failed].")
65
+ command.expects(:say_err).with("Solution creation failed [failed].")
66
66
 
67
67
  assert_equal(command.execute(["Test Solution"]), 1)
68
68
  end
@@ -44,7 +44,7 @@ class CreateUserCommandTest < Test::Unit::TestCase
44
44
 
45
45
  @mock_client.expects(:post).with("/api/v1/users", { :email => 'me@there.com', :password => 'testpass' }).
46
46
  returns([400, { :message => "Bad Request" }, {}])
47
- command.expects(:say).with("User creation failed [Bad Request].")
47
+ command.expects(:say_err).with("User creation failed [Bad Request].")
48
48
 
49
49
  assert_equal(command.execute(["me@there.com"]), 400)
50
50
  end
@@ -16,7 +16,7 @@ class DeleteConfigCommandTest < Test::Unit::TestCase
16
16
  @command.expects(:extract_configuration_level).returns(["Project", 1])
17
17
  @mock_client.expects(:get).with(EPC::Config::CONFIGURATIONS_PATH + "/Project/1").
18
18
  returns([200, {:name => "key1", :id => 1}, {}])
19
- @command.expects(:say).with("key1 is not defined.")
19
+ @command.expects(:say_err).with("key1 is not defined.")
20
20
  @command.execute
21
21
  end
22
22
 
@@ -33,7 +33,7 @@ class DeleteConfigCommandTest < Test::Unit::TestCase
33
33
  @command.expects(:extract_configuration_level).returns(["Project", 1])
34
34
  @mock_client.expects(:get).with(EPC::Config::CONFIGURATIONS_PATH + "/Project/1").
35
35
  returns([200, {:name => "key1", :id => 1}, {}])
36
- @command.expects(:say).with("key2 is not defined.")
36
+ @command.expects(:say_err).with("key2 is not defined.")
37
37
  @command.execute
38
38
  end
39
39
 
@@ -55,7 +55,7 @@ class DeleteConfigCommandTest < Test::Unit::TestCase
55
55
  @command.expects(:ask_yn).returns("Y")
56
56
  @mock_client.expects(:delete).with(EPC::Config::CONFIGURATIONS_PATH + "/1").
57
57
  returns([500, {:message => "System Exception"}, {}])
58
- @command.expects(:say).with("Request failed: [System Exception]")
58
+ @command.expects(:say_err).with("Request failed: [System Exception]")
59
59
  @command.execute
60
60
  end
61
61
  end
@@ -14,7 +14,7 @@ class DeleteLibraryCommandTest < Test::Unit::TestCase
14
14
 
15
15
  should "fail if status is not 200" do
16
16
  @mock_client.expects(:delete).with(EPC::Config::LIBRARIES_PATH + "/1").returns([404, {:message => "Not Found"}, {}])
17
- @command.expects(:say).with("Request failed: [Not Found]")
17
+ @command.expects(:say_err).with("Request failed: [Not Found]")
18
18
 
19
19
  assert_equal(@command.execute("1"), 404)
20
20
  end
@@ -15,7 +15,7 @@ class DeleteLibrarylanguageCommandTest < Test::Unit::TestCase
15
15
  should "fail if status is not 200" do
16
16
  @mock_client.expects(:delete).with(EPC::Config::LIBRARY_LANGUAGES_PATH + "/1").
17
17
  returns([404, {:message => "Not Found"}, {}])
18
- @command.expects(:say).with("Request failed: [Not Found]")
18
+ @command.expects(:say_err).with("Request failed: [Not Found]")
19
19
  assert_equal(@command.execute(1), 404)
20
20
  end
21
21
 
@@ -16,7 +16,7 @@ class DeleteLibrarysetCommand < Test::Unit::TestCase
16
16
  should "fail if status is not 200" do
17
17
  @mock_client.expects(:delete).with(EPC::Config::LIBRARY_SETS_PATH + "/1").
18
18
  returns([404, {:message => "Not Found"}, {}])
19
- @command.expects(:say).with("Request failed: [Not Found]")
19
+ @command.expects(:say_err).with("Request failed: [Not Found]")
20
20
  assert_equal(@command.execute(1), 404)
21
21
  end
22
22
 
@@ -15,7 +15,7 @@ class DeletePluginCommandTest < Test::Unit::TestCase
15
15
  should "fail if status is not 200" do
16
16
  @mock_client.expects(:delete).with(EPC::Config::PLUGINS_PATH + "/1").
17
17
  returns([404, {:message => "Not Found"}, {}])
18
- @command.expects(:say).with("Request failed: [Not Found]")
18
+ @command.expects(:say_err).with("Request failed: [Not Found]")
19
19
  assert_equal(@command.execute(1), 404)
20
20
  end
21
21
 
@@ -18,7 +18,7 @@ class DeleteProjectCommandTest < Test::Unit::TestCase
18
18
  @mock_client.expects(:delete).with(EPC::Config::PROJECTS_PATH + "/1").
19
19
  returns([404, {:message => "Not Found"}, {}])
20
20
 
21
- @command.expects(:say).with("Project could not be deleted. Delete failed with: [Not Found]")
21
+ @command.expects(:say_err).with("Project could not be deleted. Delete failed with: [Not Found]")
22
22
  assert_equal(@command.execute, 404)
23
23
  end
24
24
 
@@ -15,7 +15,7 @@ class DeleteProjecttypeCommandTest < Test::Unit::TestCase
15
15
  should "fail if status is not 200" do
16
16
  @mock_client.expects(:delete).with(EPC::Config::PROJECT_TYPES_PATH + "/1").
17
17
  returns([404, {:message => "Not Found"}, {}])
18
- @command.expects(:say).with("Request failed: [Not Found]")
18
+ @command.expects(:say_err).with("Request failed: [Not Found]")
19
19
  assert_equal(@command.execute(1), 404)
20
20
  end
21
21
 
@@ -15,7 +15,7 @@ class DeleteRoleCommandTest < Test::Unit::TestCase
15
15
  should "fail if status is not 200" do
16
16
  @mock_client.expects(:delete).with(EPC::Config::ROLES_PATH + "/1/system/true").
17
17
  returns([404, {:message => "Not Found"}, {}])
18
- @command.expects(:say).with("Request failed: [Not Found]")
18
+ @command.expects(:say_err).with("Request failed: [Not Found]")
19
19
  assert_equal(@command.execute, 404)
20
20
  end
21
21
 
@@ -15,7 +15,7 @@ class DeleteRuntimeCommandTest < Test::Unit::TestCase
15
15
  should "fail if status is not 200" do
16
16
  @mock_client.expects(:delete).with(EPC::Config::RUNTIMES_PATH + "/1").
17
17
  returns([404, {:message => "Not Found"}, {}])
18
- @command.expects(:say).with("Request failed: [Not Found]")
18
+ @command.expects(:say_err).with("Request failed: [Not Found]")
19
19
  assert_equal(@command.execute(1), 404)
20
20
  end
21
21
 
@@ -17,7 +17,7 @@ class DeleteServicedefinitionCommandTest < Test::Unit::TestCase
17
17
 
18
18
  should "fail if status is not 201" do
19
19
  @mock_client.expects(:delete).with(EPC::Config::SERVICE_DEFINITIONS_PATH + "/1").returns([400, {:message => 'Not Found'}])
20
- @command.expects(:say).with("Request failed: [Not Found]")
20
+ @command.expects(:say_err).with("Request failed: [Not Found]")
21
21
  assert_equal(@command.execute, 400)
22
22
  end
23
23
 
@@ -17,7 +17,7 @@ class DeleteServiceversionCommandTest < Test::Unit::TestCase
17
17
  @mock_client.expects(:delete).with(EPC::Config::SERVICE_VERSIONS_PATH + "/1").
18
18
  returns([404, {:message => "Not Found"}, {}])
19
19
 
20
- @command.expects(:say).with("Request failed: [Not Found]")
20
+ @command.expects(:say_err).with("Request failed: [Not Found]")
21
21
  assert_equal(@command.execute(1), 404)
22
22
  end
23
23
 
@@ -18,7 +18,7 @@ class DeleteSolutionCommandTest < Test::Unit::TestCase
18
18
  @mock_client.expects(:delete).with(EPC::Config::SOLUTIONS_PATH + "/1").
19
19
  returns([404, {:message => "Not Found"}, {}])
20
20
 
21
- @command.expects(:say).with("Solution could not be deleted. Delete failed with: [Not Found]")
21
+ @command.expects(:say_err).with("Solution could not be deleted. Delete failed with: [Not Found]")
22
22
  assert_equal(@command.execute, 404)
23
23
  end
24
24
 
@@ -15,7 +15,7 @@ class DeleteUserCommandTest < Test::Unit::TestCase
15
15
  @command.expects(:ask_yn).returns("Y")
16
16
  @mock_client.expects(:delete).with(EPC::Config::USERS_PATH + "/1").
17
17
  returns([404, {:message => "Not Found"}, {}])
18
- @command.expects(:say).with("Request failed: [Not Found]")
18
+ @command.expects(:say_err).with("Request failed: [Not Found]")
19
19
  assert_equal(@command.execute(1), 404)
20
20
  end
21
21
 
@@ -0,0 +1,60 @@
1
+ require 'test_helper'
2
+
3
+ class DeleteUserpropertyCommandTest < Test::Unit::TestCase
4
+ should_require_login
5
+
6
+ context "execute" do
7
+ setup do
8
+ @mock_client = mock("Client")
9
+ @command = EPC::Command::DeleteUserpropertyCommand.new(@mock_client)
10
+ @command.object_id = 1
11
+ @command.object_type = "UserProperty"
12
+ @user_id = 1
13
+ end
14
+
15
+ should "fail if the user property is not found" do
16
+ @command.expects(:ask_yn).returns("Y")
17
+ @mock_client.expects(:delete).with((EPC::Config::ENTITY_PROPERTIES_PATH + "/1")).
18
+ returns([404, {:message => "Resource Not Found"}, {}])
19
+ @command.expects(:say_err).with("User property could not be deleted. Delete failed with: [Resource Not Found]")
20
+ assert_equal(@command.execute(1), 404)
21
+ end
22
+
23
+ should "fail if the entity property identifier is not supplied" do
24
+ @command.object_id = nil
25
+ @command.expects(:say).with("User property identifier is missing.")
26
+ assert_equal(@command.execute([]), 1)
27
+ end
28
+
29
+ should "fail if the entity is not found" do
30
+ @command.expects(:ask_yn).returns("Y")
31
+ @command.options[:all] = true
32
+ @command.expects(:retrieve_identifier_for).with("User", "user@domain.com").returns(@user_id)
33
+ @mock_client.expects(:delete).with((EPC::Config::ENTITY_PROPERTIES_PATH + "/for/User/#{@user_id}")).returns([404, {:message => "Resource not found - Entity was not found."}, {}])
34
+ @command.expects(:say_err).with("User properties could not be deleted. Delete failed with: [Resource not found - Entity was not found.]")
35
+ assert_equal(@command.execute([]), 404)
36
+
37
+ end
38
+
39
+ should "delete multiple user properties" do
40
+ @command.expects(:ask_yn).returns("Y")
41
+ @command.options[:all] = true
42
+ @command.expects(:retrieve_identifier_for).with("User", "user@domain.com").returns(@user_id)
43
+ @command.expects(:say).with("User properties deleted.")
44
+ @mock_client.expects(:delete).with((EPC::Config::ENTITY_PROPERTIES_PATH + "/for/User/#{@user_id}")).returns([200, [{:id => 1}, {:id => 2}], {}])
45
+
46
+ assert_equal(@command.execute([]), 200)
47
+ end
48
+
49
+ should "delete a user property" do
50
+ @command.expects(:ask_yn).returns("Y")
51
+ @mock_client.expects(:delete).with(EPC::Config::ENTITY_PROPERTIES_PATH + "/1").
52
+ returns([200, {:id => 1}, {}])
53
+ @command.expects(:say).with("User property deleted.")
54
+
55
+ assert_equal(@command.execute(1), 200)
56
+ end
57
+
58
+
59
+ end
60
+ end
@@ -15,7 +15,7 @@ class DeployCommandTest < Test::Unit::TestCase
15
15
  EPC::Config.expects(:is_solution_dir?).returns(false)
16
16
  EPC::Config.expects(:is_project_dir?).returns(false)
17
17
 
18
- @command.expects(:say).with("This is not a solution directory.")
18
+ @command.expects(:say_err).with("This is not a solution directory.")
19
19
  @command.execute
20
20
  end
21
21
 
@@ -72,7 +72,7 @@ class DeployCommandTest < Test::Unit::TestCase
72
72
  @command.expects(:deploy).with(1)
73
73
  @command.expects(:say).with("Deploying - ")
74
74
  @command.expects(:display_statuses).never
75
- @command.expects(:say).with("Deploy failed [failed].")
75
+ @command.expects(:say_err).with("Deploy failed [failed].")
76
76
 
77
77
  assert_equal(@command.execute, 1)
78
78
  end
@@ -115,16 +115,24 @@ class DeployCommandTest < Test::Unit::TestCase
115
115
  context "display_statuses" do
116
116
  setup do
117
117
  @mock_client = mock("Client")
118
+ @command = EPC::Command::DeployCommand.new(@mock_client)
118
119
  @deployment_hash = { :id => 1, :status => "running", :projects => [{ :id => 7, :status => "running", :uris => ["uri_to_app"], :project_name => "FirstProject"}] }
119
120
  end
120
121
 
121
122
  should "display the status of everything in the deployment" do
122
- command = EPC::Command::DeployCommand.new(@mock_client)
123
123
 
124
- command.expects(:say).with("\nStatus = running\n")
125
- command.expects(:say).with("FirstProject -> uri_to_app\n")
124
+ @command.expects(:say).with("\nStatus = running\n")
125
+ @command.expects(:say).with("FirstProject -> uri_to_app\n")
126
+
127
+ @command.send(:display_statuses, @deployment_hash[:status], @deployment_hash[:projects])
128
+ end
129
+
130
+ should "skip displaying uris in no uris present" do
131
+ @deployment_hash[:projects][0][:uris] = nil
132
+ @command.expects(:say).with("\nStatus = running\n")
133
+ @command.expects(:say).with("FirstProject -> N/A\n")
126
134
 
127
- command.send(:display_statuses, @deployment_hash[:status], @deployment_hash[:projects])
135
+ @command.send(:display_statuses, @deployment_hash[:status], @deployment_hash[:projects])
128
136
  end
129
137
  end
130
138
 
@@ -0,0 +1,58 @@
1
+ class GetUserPropertyCommandTest < Test::Unit::TestCase
2
+ should_require_login
3
+
4
+ context "execute" do
5
+ setup do
6
+ @mock_client = mock("Client")
7
+ @command = EPC::Command::GetUserPropertyCommand.new(@mock_client)
8
+ @user_id = 1
9
+ @property_id = "1"
10
+ @property_name = "color"
11
+ end
12
+
13
+ should "return an error if the identifier is missing" do
14
+ @command.expects(:say_err).with("User property identifier is missing.")
15
+ assert_equal 1, @command.execute(0)
16
+ end
17
+
18
+ should "return a list of property details if the --all parameter is used" do
19
+ @command.options[:all] = true
20
+ @command.expects(:retrieve_identifier_for).with("User",'user@domain.com').returns(@user_id)
21
+ @mock_client.expects(:get).with(EPC::Config::ENTITY_PROPERTIES_PATH + "/for/User/#{@user_id}").returns([200, [{:id => 3, :name => "favorite_color", :value => "red"},{:id => 1, :name => "color", :value => "blue"}], {}])
22
+ @command.expects(:say)
23
+ assert_equal(200, @command.execute(0))
24
+ end
25
+
26
+ should "return the property details if the name is used" do
27
+ @command.expects(:retrieve_identifier_for).with("User",'user@domain.com').returns(@user_id)
28
+ @command.expects(:retrieve_identifier_for).with("EntityProperty", "#{@property_name}:#{@user_id}:User").returns(@property_id)
29
+ @mock_client.expects(:get).with(EPC::Config::ENTITY_PROPERTIES_PATH + "/#{@property_id}").returns([200, {:id => 1, :name => "color", :value => "blue"}, {}])
30
+ @command.expects(:say)
31
+ assert_equal 200, @command.execute(0, @property_name)
32
+ end
33
+
34
+ should "return the property details if the id is used" do
35
+ @mock_client.expects(:get).with(EPC::Config::ENTITY_PROPERTIES_PATH + "/#{@property_id}").returns([200, {:id => 1, :name => "color", :value => "blue"}, {}])
36
+ @command.expects(:say)
37
+ assert_equal 200, @command.execute(0, @property_id)
38
+ end
39
+
40
+ should "save the property details to a file if the --file attribute is used" do
41
+ @command.options[:file] = "testing_file"
42
+ @mock_client.expects(:get).with(EPC::Config::ENTITY_PROPERTIES_PATH + "/#{@property_id}").returns([200, {:id => 1, :name => "color", :value => "blue"}, {}])
43
+ File.expects(:open).with("testing_file", "w+")
44
+ @command.expects(:say).with("User properties were saved to testing_file")
45
+ assert_equal 200, @command.execute(0, @property_id)
46
+ end
47
+
48
+ should "return a error if the save to a file fails" do
49
+ @command.options[:file] = "testing_file"
50
+ @mock_client.expects(:get).with(EPC::Config::ENTITY_PROPERTIES_PATH + "/#{@property_id}").returns([200, {:id => 1, :name => "color", :value => "blue"}, {}])
51
+ File.expects(:open).raises(Exception, 'Surprise!')
52
+ @command.expects(:say_err).with("User properties could not be saved (Surprise!)")
53
+ assert_equal 1, @command.execute(0, @property_id)
54
+ end
55
+
56
+ end
57
+
58
+ end
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+
3
+ class ListCommandTest < Test::Unit::TestCase
4
+ should_require_login
5
+
6
+ context "list command" do
7
+ setup do
8
+ @mock_client = mock("Client")
9
+ @command = EPC::Command::ListCommand.new(@mock_client)
10
+ end
11
+
12
+ should "fail if no object specified" do
13
+ assert_raise EPC::Error::InputError do
14
+ @command.execute
15
+ end
16
+ end
17
+
18
+
19
+ should "fail if object can't be determined during context resolution" do
20
+ assert_raise EPC::Error::FatalError do
21
+ @command.expects(:resolve_context)
22
+ @command.object_type = nil
23
+ @command.execute("User")
24
+ end
25
+ end
26
+
27
+ end
28
+ end
@@ -28,7 +28,7 @@ class ListConfigsCommandTest < Test::Unit::TestCase
28
28
  should "show exception message status is not 201" do
29
29
  @mock_client.expects(:get).with(EPC::Config::CONFIGURATIONS_PATH + "/User/1").
30
30
  returns([400, {:message => "Not Found"}, {}])
31
- @command.expects(:say).with("Configuration retrieval failed with [Not Found]")
31
+ @command.expects(:say_err).with("Configuration retrieval failed with [Not Found]")
32
32
 
33
33
  assert_equal(@command.execute, 400)
34
34
  end
@@ -14,7 +14,7 @@ class ListDeploymentsCommandTest < Test::Unit::TestCase
14
14
  should "show exception message status is not 201" do
15
15
  @mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH + "/1/deployments").
16
16
  returns([400, {:message => "Not Found"}, {}])
17
- @command.expects(:say).with("Deployments retrieval failed with [Not Found]")
17
+ @command.expects(:say_err).with("Deployments retrieval failed with [Not Found]")
18
18
 
19
19
  assert_equal(@command.execute("Solution:1"), 400)
20
20
  end
@@ -13,7 +13,7 @@ class ListDeploymentstagesCommandTest < Test::Unit::TestCase
13
13
  should "show exception message status is not 201" do
14
14
  @mock_client.expects(:get).with(EPC::Config::DEPLOYMENT_STAGES_PATH).
15
15
  returns([400, {:message => "Not Found"}, {}])
16
- @command.expects(:say).with("Request failed: [Not Found]")
16
+ @command.expects(:say_err).with("Request failed: [Not Found]")
17
17
 
18
18
  assert_equal(@command.execute, 400)
19
19
  end
@@ -12,7 +12,7 @@ class ListLibrariesCommandTest < Test::Unit::TestCase
12
12
  should "show exception message status is not 201" do
13
13
  @mock_client.expects(:get).with(EPC::Config::LIBRARIES_PATH).
14
14
  returns([404, {:message => "Not Found"}, {}])
15
- @command.expects(:say).with("Libraries retrieval failed with [Not Found]")
15
+ @command.expects(:say_err).with("Libraries retrieval failed with [Not Found]")
16
16
 
17
17
  assert_equal(@command.execute, 404)
18
18
  end
@@ -12,7 +12,7 @@ class ListLibrarylanguagesCommandTest < Test::Unit::TestCase
12
12
 
13
13
  should "fail if status is not 200(ok)" do
14
14
  @mock_client.expects(:get).with(EPC::Config::LIBRARY_LANGUAGES_PATH).returns([500, {:message => "System exception encountered"}, {}])
15
- @command.expects(:say).with("Request failed: [System exception encountered]")
15
+ @command.expects(:say_err).with("Request failed: [System exception encountered]")
16
16
  assert_equal 500, @command.execute
17
17
  end
18
18