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
@@ -12,7 +12,7 @@ class ListLibrarysetsCommandTest < 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_SETS_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
 
@@ -15,7 +15,7 @@ class ListObjectrolesCommandTest < Test::Unit::TestCase
15
15
  @mock_client.expects(:get).with(EPC::Config::ROLES_PATH + "/for_object/Solution/1").
16
16
  returns([404, {:message => "Not Found"}, {}])
17
17
 
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
 
@@ -11,7 +11,7 @@ class ListPermissiongroupsCommandTest < Test::Unit::TestCase
11
11
 
12
12
  should "show reason for request failure" do
13
13
  @mock_client.expects(:get).with(EPC::Config::PERMISSIONS_PATH).returns([500, {:message => "System Exception"}, {}])
14
- @command.expects(:say).with("Request failed: [System Exception]")
14
+ @command.expects(:say_err).with("Request failed: [System Exception]")
15
15
  assert_equal(@command.execute, 500)
16
16
  end
17
17
 
@@ -13,7 +13,7 @@ class ListPermissionsCommandTest < Test::Unit::TestCase
13
13
  @mock_client.expects(:get).with(EPC::Config::PERMISSIONS_PATH).
14
14
  returns([404, {:message => "Not Found"}, {}])
15
15
 
16
- @command.expects(:say).with("Request failed: [Not Found]")
16
+ @command.expects(:say_err).with("Request failed: [Not Found]")
17
17
  assert_equal(@command.execute, 404)
18
18
 
19
19
  end
@@ -17,7 +17,7 @@ class ListPluginsCommandTest < Test::Unit::TestCase
17
17
 
18
18
  should "report reason for request failure" do
19
19
  @mock_client.expects(:get).with(EPC::Config::PLUGINS_PATH).returns([500, {:message => "System Exception"}, {}])
20
- @command.expects(:say).with("Request failed: [System Exception]")
20
+ @command.expects(:say_err).with("Request failed: [System Exception]")
21
21
  @command.execute("")
22
22
  end
23
23
 
@@ -14,7 +14,7 @@ class ListProjectsCommandTest < 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/projects").
16
16
  returns([400, {:message => "Not Found"}, {}])
17
- @command.expects(:say).with("Projects retrieval failed with [Not Found]")
17
+ @command.expects(:say_err).with("Projects retrieval failed with [Not Found]")
18
18
 
19
19
  assert_equal(@command.execute, 400)
20
20
  end
@@ -12,7 +12,7 @@ class ListProjecttypesCommandTest < Test::Unit::TestCase
12
12
  should "show exception message status is not 201" do
13
13
  @mock_client.expects(:get).with(EPC::Config::PROJECT_TYPES_PATH).
14
14
  returns([400, {:message => "Not Found"}, {}])
15
- @command.expects(:say).with("Request failed: [Not Found]")
15
+ @command.expects(:say_err).with("Request failed: [Not Found]")
16
16
 
17
17
  assert_equal(@command.execute, 400)
18
18
  end
@@ -13,7 +13,7 @@ class ListRolesCommandTest < Test::Unit::TestCase
13
13
  @mock_client.expects(:get).with(EPC::Config::ROLES_PATH + "?system_roles=true").
14
14
  returns([404, {:message => "Not Found"}, {}])
15
15
 
16
- @command.expects(:say).with("Request failed: [Not Found]")
16
+ @command.expects(:say_err).with("Request failed: [Not Found]")
17
17
  assert_equal(@command.execute, 404)
18
18
  end
19
19
 
@@ -34,6 +34,14 @@ class ListRolesCommandTest < Test::Unit::TestCase
34
34
  assert_equal(@command.execute, 200)
35
35
  end
36
36
 
37
+ should "only allow a user target" do
38
+ assert_raise EPC::Error::InputError do
39
+ @command.target_type = "Role"
40
+ @command.target_id = 1
41
+ @command.execute
42
+ end
43
+ end
44
+
37
45
  should "retrieve roles for the user" do
38
46
  @command.target_type = "User"
39
47
  @command.target_id = 1
@@ -12,7 +12,7 @@ class ListRuntimesCommandTest < Test::Unit::TestCase
12
12
  should "show exception message status is not 201" do
13
13
  @mock_client.expects(:get).with(EPC::Config::RUNTIMES_PATH).
14
14
  returns([400, {:message => "Not Found"}, {}])
15
- @command.expects(:say).with("Request failed with: [Not Found]")
15
+ @command.expects(:say_err).with("Request failed with: [Not Found]")
16
16
 
17
17
  assert_equal(@command.execute, 400)
18
18
  end
@@ -12,7 +12,7 @@ class ListRuntimetypesCommandTest < Test::Unit::TestCase
12
12
  should "show exception message status is not 201" do
13
13
  @mock_client.expects(:get).with(EPC::Config::RUNTIMES_PATH + "_types").
14
14
  returns([400, {:message => "Not Found"}, {}])
15
- @command.expects(:say).with("Request failed: [Not Found]")
15
+ @command.expects(:say_err).with("Request failed: [Not Found]")
16
16
 
17
17
  assert_equal(@command.execute, 400)
18
18
  end
@@ -13,7 +13,7 @@ class ListServicetypesCommandTest < Test::Unit::TestCase
13
13
  should "show exception message status is not 201" do
14
14
  @mock_client.expects(:get).with(EPC::Config::SERVICE_TYPES_PATH).
15
15
  returns([400, {:message => "Not Found"}, {}])
16
- @command.expects(:say).with("Service types retrieval failed with [Not Found]")
16
+ @command.expects(:say_err).with("Service types retrieval failed with [Not Found]")
17
17
 
18
18
  assert_equal(@command.execute, 400)
19
19
  end
@@ -12,7 +12,7 @@ class ListServicedefinitionsCommandTest < Test::Unit::TestCase
12
12
  should "show exception message status is not 200" do
13
13
  @mock_client.expects(:get).with(EPC::Config::SERVICE_DEFINITIONS_PATH).
14
14
  returns([400, {'message' => "Not Found"}, {}])
15
- @command.expects(:say).with("Request failed with: [Not Found]")
15
+ @command.expects(:say_err).with("Request failed with: [Not Found]")
16
16
 
17
17
  assert_equal(@command.execute, 400)
18
18
  end
@@ -13,7 +13,7 @@ class ListServiceversionsCommandTest < Test::Unit::TestCase
13
13
  should "show exception message status is not 201" do
14
14
  @mock_client.expects(:get).with(EPC::Config::SERVICE_VERSIONS_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
@@ -13,7 +13,7 @@ class ListSolutionsCommandTest < Test::Unit::TestCase
13
13
  should "show exception message status is not 201" do
14
14
  @mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH).
15
15
  returns([400, {:message => "Not Found"}, {}])
16
- @command.expects(:say).with("Solutions retrieval failed with [Not Found]")
16
+ @command.expects(:say_err).with("Solutions retrieval failed with [Not Found]")
17
17
 
18
18
  assert_equal(@command.execute, 400)
19
19
  end
@@ -1,4 +1,4 @@
1
- class ListUsersCommandTest < Test::Unit::TestCase
1
+ class ListUserpropertiesCommandTest < Test::Unit::TestCase
2
2
  should_require_login
3
3
 
4
4
  context "execute" do
@@ -11,7 +11,7 @@ class ListUsersCommandTest < Test::Unit::TestCase
11
11
 
12
12
  should "fail if the user cannot be found" do
13
13
  @mock_client.expects(:get).with(EPC::Config::ENTITY_PROPERTIES_PATH + "/for/User/#{@user_id}").returns([404, {:message => "Entity was not found."}, {}])
14
- @command.expects(:say).with("Request failed with [Entity was not found.]")
14
+ @command.expects(:say_err).with("Request failed with [Entity was not found.]")
15
15
  assert_equal 404, @command.execute
16
16
  end
17
17
 
@@ -30,4 +30,4 @@ class ListUsersCommandTest < Test::Unit::TestCase
30
30
 
31
31
  end
32
32
 
33
- end
33
+ end
@@ -12,7 +12,7 @@ class ListUsersCommandTest < 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::USERS_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
 
@@ -98,7 +98,7 @@ class PullCommandTest < Test::Unit::TestCase
98
98
 
99
99
  @mock_client.expects(:put).with("/api/v1/pulls/1/confirm", { :pulled => 'yes' }).
100
100
  returns([400, { :message => "bad request" }, {}])
101
- command.expects(:say).with("Pull confirmation failed [bad request].")
101
+ command.expects(:say_err).with("Pull confirmation failed [bad request].")
102
102
 
103
103
  confirmed = command.send(:confirm_pull, 1)
104
104
 
@@ -150,7 +150,7 @@ class PullCommandTest < Test::Unit::TestCase
150
150
 
151
151
  should "notify if solutions wasn't found" do
152
152
  @command.expects(:get_resource_id).returns(nil)
153
- @command.expects(:say).returns("Solution not found")
153
+ @command.expects(:say_err).returns("Solution not found")
154
154
  assert_equal(@command.send(:prep_solution_directory, "path_to_dir", "FirstSolution"), false)
155
155
 
156
156
  end
@@ -158,7 +158,7 @@ class PullCommandTest < Test::Unit::TestCase
158
158
  should "notify if directory creation fails" do
159
159
  @command.expects(:get_resource_id).returns(1)
160
160
  Dir.expects(:mkdir).raises(Exception)
161
- @command.expects(:say)
161
+ @command.expects(:say_err)
162
162
  assert_equal(@command.send(:prep_solution_directory, "path_to_dir", "FirstSolution"), false)
163
163
  end
164
164
 
@@ -166,7 +166,7 @@ class PullCommandTest < Test::Unit::TestCase
166
166
  @command.expects(:get_resource_id).returns(1)
167
167
  Dir.expects(:mkdir)
168
168
  File.expects(:open).raises(Exception)
169
- @command.expects(:say)
169
+ @command.expects(:say_err)
170
170
  assert_equal(@command.send(:prep_solution_directory, "path_to_dir", "FirstSolution"), false)
171
171
  end
172
172
  end
@@ -184,7 +184,7 @@ class PullCommandTest < Test::Unit::TestCase
184
184
 
185
185
  should "notify when there's an error in polling" do
186
186
  @command.expects(:sign_pull).returns([500, {}, nil])
187
- @command.expects(:say).with("Poller failed to get the pull URL. Aborting.")
187
+ @command.expects(:say_err).with("Poller failed to get the pull URL. Aborting.")
188
188
  assert_equal(@command.send(:poll_for_pull_url, 1), [false, nil, nil])
189
189
  end
190
190
 
@@ -198,14 +198,14 @@ class PullCommandTest < Test::Unit::TestCase
198
198
 
199
199
  should "fail if path doesn't exists" do
200
200
  File.expects(:exists?).returns(false)
201
- @command.expects(:say).with("Pull path does not exist")
201
+ @command.expects(:say_err).with("Pull path does not exist")
202
202
  @command.send(:check_pull_directory, "path")
203
203
  end
204
204
 
205
205
  should "fail if path isn't a directory" do
206
206
  File.expects(:exists?).returns(true)
207
207
  File.expects(:directory?).returns(false)
208
- @command.expects(:say).with("Pull path is not a directory")
208
+ @command.expects(:say_err).with("Pull path is not a directory")
209
209
  @command.send(:check_pull_directory, "path")
210
210
  end
211
211
  end
@@ -226,7 +226,7 @@ class PullCommandTest < Test::Unit::TestCase
226
226
 
227
227
  should "notify if pull fails" do
228
228
  @command.send(:http_client).expects(:get).returns([500, "response", {}])
229
- @command.expects(:say).with("Failed to pull the zip file from the build repository [status = 500]. Aborting pull command.")
229
+ @command.expects(:say_err).with("Failed to pull the zip file from the build repository [status = 500]. Aborting pull command.")
230
230
  @command.send(:pull_zip, "url", "path_to_zip")
231
231
  end
232
232
  end
@@ -38,7 +38,7 @@ class PushCommandTest < Test::Unit::TestCase
38
38
  should "push only the specified project from the solution directory" do
39
39
  @command.expects(:infer_solution_context).returns([1, "FirstSolution"])
40
40
  EPC::Config.expects(:is_solution_dir?).with(File.expand_path(".")).returns(true)
41
- @command.expects(:infer_project_context).with("MyProj", File.expand_path("."), 1, {:get_project_name => true}).returns([1, "FirstProject"])
41
+ # @command.expects(:infer_project_context).returns([1, "FirstProject"])
42
42
 
43
43
  @command.expects(:ask_yn).returns('n')
44
44
 
@@ -63,15 +63,45 @@ class PushCommandTest < Test::Unit::TestCase
63
63
  command.expects(:infer_project_context).returns([1, "FirstProject"])
64
64
  command.expects(:say).with("\nPushing FirstProject...")
65
65
  command.expects(:zip_source).with(expected_path).returns(expected_zip_path)
66
+ File.expects(:exists?).returns(true)
66
67
  command.expects(:sha1).with(expected_zip_path).returns('aabbcc')
67
- command.expects(:create_push).with("FirstProject", "FirstSolution", "aabbcc", nil).returns([202, expected_url, 'ddeeff', 1])
68
- command.expects(:push_zip).with(expected_zip_path, expected_url, 'ddeeff').returns(true)
68
+ command.expects(:create_push).with("FirstProject", "FirstSolution", "aabbcc", nil, nil).returns([202, expected_url, 'ddeeff', 1])
69
+ command.expects(:push_zip).with(expected_zip_path, expected_url, 'ddeeff', nil).returns(true)
69
70
  command.expects(:confirm_push).with(1).returns({:id => 1, :build_id=> 1, :project_version => 2})
70
71
  command.expects(:poll_for_build_status).with(1)
71
72
 
72
73
  command.execute
73
74
  end
74
75
 
76
+ should "zip, push, confirm and poll for build status for direct deploy" do
77
+ expected_file = "pushed.zip"
78
+ expected_path = File.expand_path(".")
79
+ expected_zip_path = File.join(expected_path, expected_file)
80
+ expected_url = "http://www.there.com/solution/project/version/pushed.zip"
81
+
82
+ options = { direct_deploy: expected_zip_path }
83
+ command = EPC::Command::PushCommand.new(@mock_client, options)
84
+
85
+ command.expects(:infer_solution_context).returns([1, "FirstSolution"])
86
+
87
+ EPC::Config.expects(:is_solution_dir?).returns(false)
88
+ EPC::Config.expects(:is_project_dir?).returns(true)
89
+ command.expects(:infer_project_context).returns([1, "FirstProject"])
90
+
91
+ command.expects(:ask_yn).returns('Y')
92
+
93
+ command.expects(:infer_project_context).returns([1, "FirstProject"])
94
+ command.expects(:say).with("\nPushing FirstProject...")
95
+ File.expects(:exists?).returns(true)
96
+ command.expects(:sha1).with(expected_zip_path).returns('aabbcc')
97
+ command.expects(:create_push).with("FirstProject", "FirstSolution", "aabbcc", nil, expected_file).returns([202, expected_url, 'ddeeff', 1])
98
+ command.expects(:push_zip).with(expected_zip_path, expected_url, 'ddeeff', expected_zip_path).returns(true)
99
+ command.expects(:confirm_push).with(1).returns({:id => 1, :build_id=> 1, :project_version => 2})
100
+ command.expects(:poll_for_build_status).with(1)
101
+
102
+ command.execute
103
+ end
104
+
75
105
  end
76
106
 
77
107
  context "create_push" do
@@ -85,7 +115,7 @@ class PushCommandTest < Test::Unit::TestCase
85
115
  command = EPC::Command::PushCommand.new(@mock_client)
86
116
 
87
117
  @mock_client.expects(:post).with("/api/v1/pushes",
88
- { :project_name => 'Test Project', :solution_name => "Test Solution", :sha1 => "abcdef", :note => nil}).
118
+ { :project_name => 'Test Project', :solution_name => "Test Solution", :sha1 => "abcdef", :note => nil, :direct_deploy => nil}).
89
119
  returns([202, { :url => "http://there.com/repo", :signature => "xxyyzz", :id => 1 }, {}])
90
120
  command.expects(:say).with("Successfully created a push with [http://localhost:3000]")
91
121
 
@@ -101,7 +131,7 @@ class PushCommandTest < Test::Unit::TestCase
101
131
  command = EPC::Command::PushCommand.new(@mock_client)
102
132
 
103
133
  @mock_client.expects(:post).with("/api/v1/pushes",
104
- { :project_name => 'Test Project', :solution_name => "Test Solution", :sha1 => "abcdef", :note => nil }).
134
+ { :project_name => 'Test Project', :solution_name => "Test Solution", :sha1 => "abcdef", :note => nil, :direct_deploy => nil }).
105
135
  returns([404, { :message => "Not Found" }, {}])
106
136
  # command.expects(:say).with("Push creation failed [Not Found]. Aborting push command.")
107
137
 
@@ -135,7 +165,7 @@ class PushCommandTest < Test::Unit::TestCase
135
165
 
136
166
  @mock_client.expects(:put).with("/api/v1/pushes/1/confirm",
137
167
  { :pushed => "yes" }).returns([404, { :message => "Not Found" }, {}])
138
- command.expects(:say).with("Push confirmation failed [Not Found].")
168
+ command.expects(:say_err).with("Push confirmation failed [Not Found].")
139
169
 
140
170
  confirmed = command.send(:confirm_push, 1)
141
171
 
@@ -230,14 +260,14 @@ class PushCommandTest < Test::Unit::TestCase
230
260
 
231
261
  should "notify if path does not exist" do
232
262
  File.expects(:exists?).returns(false)
233
- @command.expects(:say)
263
+ @command.expects(:say_err)
234
264
  assert_equal(@command.send(:check_push_directory, "path"), false)
235
265
  end
236
266
 
237
267
  should "notify if path is not a directory" do
238
268
  File.expects(:exists?).returns(true)
239
269
  File.expects(:directory?).returns(false)
240
- @command.expects(:say)
270
+ @command.expects(:say_err)
241
271
  assert_equal(@command.send(:check_push_directory, "path"), false)
242
272
  end
243
273
 
@@ -0,0 +1,50 @@
1
+ class SetUserPropertyCommandTest < Test::Unit::TestCase
2
+ should_require_login
3
+
4
+ context "execute" do
5
+ setup do
6
+ @mock_client = mock("Client")
7
+ @command = EPC::Command::SetUserPropertyCommand.new(@mock_client)
8
+ @user_id = 1
9
+ @property_id = "1"
10
+ @property_name = "color"
11
+ end
12
+
13
+ should "set a single user property" do
14
+ @command.expects(:retrieve_identifier_for).with("User",'user@domain.com').returns(@user_id)
15
+ @command.expects(:retrieve_identifier_for).with("EntityProperty", "name:#{@user_id}:User")
16
+ @mock_client.expects(:post).with(EPC::Config::ENTITY_PROPERTIES_PATH, {:name => 'name', :value => 'value', :entity_id => 1, :entity_type => 'User'}).returns([201, {:id => 1}, {}])
17
+ @command.expects(:say).with("Successfully set the user properties.")
18
+ assert_equal 201, @command.execute(0, "name=value")
19
+ end
20
+
21
+ should "return a error if the user property cannot be saved" do
22
+ @command.expects(:retrieve_identifier_for).with("User",'user@domain.com').returns(@user_id)
23
+ @command.expects(:retrieve_identifier_for).with("EntityProperty", "name:#{@user_id}:User")
24
+ @mock_client.expects(:post).with(EPC::Config::ENTITY_PROPERTIES_PATH, {:name => 'name', :value => 'value', :entity_id => 1, :entity_type => 'User'}).returns([400, {:message => "Entity property could not be saved"}, {}])
25
+ @command.expects(:say_err).with("User properties could not be set [Entity property could not be saved].")
26
+ assert_equal 400, @command.execute(0, "name=value")
27
+ end
28
+
29
+ should "set multiple properties" do
30
+ @command.options[:file] = "testing_file"
31
+ File.expects(:exists?).with("testing_file").returns(true)
32
+ File.expects(:open).with("testing_file").returns({:name => 'name', :value => 'value'}.to_json + "\n")
33
+ @command.expects(:retrieve_identifier_for).with("User",'user@domain.com').returns(@user_id)
34
+ @mock_client.expects(:put).with(EPC::Config::ENTITY_PROPERTIES_PATH + "/for/User/#{@user_id}", {:entity_properties => [{'name' => 'name', 'value' => 'value'}]}).returns([201, {:id => 1}, {}])
35
+ @command.expects(:say).with("Successfully set the user properties.")
36
+ assert_equal 201, @command.execute(0)
37
+ end
38
+
39
+ should "return a error if the file doesn't exist" do
40
+ @command.options[:file]= "testing_file"
41
+ File.expects(:exists?).with("testing_file").returns(false)
42
+ @command.expects(:retrieve_identifier_for).with("User",'user@domain.com').returns(@user_id)
43
+ @command.expects(:say_err).with("File testing_file was not found")
44
+ assert_equal 1, @command.execute(0)
45
+ end
46
+
47
+
48
+ end
49
+
50
+ end
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+
3
+ class ShowCommandTest < 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::ShowCommand.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
@@ -13,7 +13,7 @@ class ShowDeploymentCommandTest < Test::Unit::TestCase
13
13
 
14
14
  should "notify if retrieval fails" do
15
15
  @mock_client.expects(:get).returns([404, {:message => "Resource not found"}, {}])
16
- @command.expects(:say).with("Request failed: [Resource not found]")
16
+ @command.expects(:say_err).with("Request failed: [Resource not found]")
17
17
 
18
18
  assert_equal(@command.execute([]), 404)
19
19
  end
@@ -14,7 +14,7 @@ class ShowGroupCommandTest < Test::Unit::TestCase
14
14
  should "fail if status is not 200" do
15
15
  @mock_client.expects(:get).with(EPC::Config::GROUPS_PATH + "/1?include=users").
16
16
  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
  assert_equal(@command.execute(1), 1)
19
19
  end
20
20