epc 1.0.2 → 1.0.3

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 (152) hide show
  1. data/lib/epc.rb +71 -54
  2. data/lib/epc/command/archive_command.rb +12 -0
  3. data/lib/epc/command/attach_libraryset_command.rb +1 -2
  4. data/lib/epc/command/attach_runtime_command.rb +0 -1
  5. data/lib/epc/command/base_command.rb +52 -63
  6. data/lib/epc/command/config/delete_config_command.rb +57 -0
  7. data/lib/epc/command/{list_config_command.rb → config/list_configs_command.rb} +1 -1
  8. data/lib/epc/command/config/update_config_command.rb +56 -0
  9. data/lib/epc/command/create_command.rb +0 -1
  10. data/lib/epc/command/delete_command.rb +16 -0
  11. data/lib/epc/command/{delete_dependency_command.rb → dependency/delete_dependency_command.rb} +14 -16
  12. data/lib/epc/command/deploy_command.rb +1 -2
  13. data/lib/epc/command/deployment/list_deployments_command.rb +49 -0
  14. data/lib/epc/command/deployment/show_deployment_command.rb +61 -0
  15. data/lib/epc/command/{update_deploymentproject_command.rb → deployment/update_deployment_command.rb} +3 -3
  16. data/lib/epc/command/{list_stages_command.rb → deploymentstage/list_deploymentstages_command.rb} +1 -1
  17. data/lib/epc/command/group/delete_group_command.rb +25 -0
  18. data/lib/epc/command/{list_groups_command.rb → group/list_groups_command.rb} +1 -1
  19. data/lib/epc/command/{show_group_command.rb → group/show_group_command.rb} +2 -9
  20. data/lib/epc/command/{update_group_command.rb → group/update_group_command.rb} +3 -20
  21. data/lib/epc/command/library/create_library_command.rb +2 -5
  22. data/lib/epc/command/library/delete_library_command.rb +23 -0
  23. data/lib/epc/command/{list_libraries_command.rb → library/list_libraries_command.rb} +1 -1
  24. data/lib/epc/command/librarylanguage/delete_librarylanguage_command.rb +24 -0
  25. data/lib/epc/command/{list_librarylanguages_command.rb → librarylanguage/list_librarylanguages_command.rb} +1 -1
  26. data/lib/epc/command/{update_librarylanguage_command.rb → librarylanguage/update_librarylanguage_command.rb} +6 -10
  27. data/lib/epc/command/libraryset/create_libraryset_command.rb +1 -6
  28. data/lib/epc/command/{delete_libraryset_command.rb → libraryset/delete_libraryset_command.rb} +2 -18
  29. data/lib/epc/command/{list_librarysets_command.rb → libraryset/list_librarysets_command.rb} +1 -1
  30. data/lib/epc/command/{show_libraryset_command.rb → libraryset/show_libraryset_command.rb} +2 -17
  31. data/lib/epc/command/{update_libraryset_command.rb → libraryset/update_libraryset_command.rb} +4 -16
  32. data/lib/epc/command/list_command.rb +22 -0
  33. data/lib/epc/command/list_metrics_command.rb +25 -0
  34. data/lib/epc/command/list_objecttypes_command.rb +2 -4
  35. data/lib/epc/command/list_versions_command.rb +0 -1
  36. data/lib/epc/command/{list_objectroles_command.rb → objectrole/list_objectroles_command.rb} +3 -3
  37. data/lib/epc/command/objectrole/update_objectrole_command.rb +14 -0
  38. data/lib/epc/command/{list_rolepermissions_command.rb → permission/list_permissions_command.rb} +2 -2
  39. data/lib/epc/command/{list_permissiongroups_command.rb → permissiongroup/list_permissiongroups_command.rb} +1 -1
  40. data/lib/epc/command/plugin/create_plugin_command.rb +42 -0
  41. data/lib/epc/command/plugin/delete_plugin_command.rb +26 -0
  42. data/lib/epc/command/plugin/list_plugins_command.rb +19 -0
  43. data/lib/epc/command/plugin/show_plugin_command.rb +29 -0
  44. data/lib/epc/command/plugin/update_plugin_command.rb +53 -0
  45. data/lib/epc/command/{archive_project_command.rb → project/archive_project_command.rb} +4 -3
  46. data/lib/epc/command/{delete_project_command.rb → project/delete_project_command.rb} +11 -7
  47. data/lib/epc/command/{list_projects_command.rb → project/list_projects_command.rb} +8 -9
  48. data/lib/epc/command/{show_project_command.rb → project/show_project_command.rb} +64 -29
  49. data/lib/epc/command/{unarchive_project_command.rb → project/unarchive_project_command.rb} +5 -4
  50. data/lib/epc/command/{update_project_command.rb → project/update_project_command.rb} +11 -5
  51. data/lib/epc/command/{list_projecttypes_command.rb → projecttype/list_projecttypes_command.rb} +1 -1
  52. data/lib/epc/command/{show_projecttype_command.rb → projecttype/show_projecttype_command.rb} +4 -3
  53. data/lib/epc/command/pull_command.rb +33 -35
  54. data/lib/epc/command/{delete_role_command.rb → role/delete_role_command.rb} +3 -4
  55. data/lib/epc/command/{list_roles_command.rb → role/list_roles_command.rb} +4 -3
  56. data/lib/epc/command/{show_role_command.rb → role/show_role_command.rb} +18 -10
  57. data/lib/epc/command/role/update_role_command.rb +95 -0
  58. data/lib/epc/command/{list_runtimes_command.rb → runtime/list_runtimes_command.rb} +0 -0
  59. data/lib/epc/command/servicedefinition/create_servicedefinition_command.rb +23 -0
  60. data/lib/epc/command/{list_servicedefinitions_command.rb → servicedefinition/list_servicedefinitions_command.rb} +1 -0
  61. data/lib/epc/command/{list_service_types_command.rb → servicetype/list_servicetypes_command.rb} +0 -0
  62. data/lib/epc/command/serviceversion/delete_serviceversion_command.rb +24 -0
  63. data/lib/epc/command/{list_serviceversions_command.rb → serviceversion/list_serviceversions_command.rb} +1 -1
  64. data/lib/epc/command/show_command.rb +27 -0
  65. data/lib/epc/command/show_instances_command.rb +33 -0
  66. data/lib/epc/command/show_metrics_command.rb +55 -0
  67. data/lib/epc/command/{archive_solution_command.rb → solution/archive_solution_command.rb} +2 -1
  68. data/lib/epc/command/solution/create_solution_command.rb +0 -1
  69. data/lib/epc/command/{delete_solution_command.rb → solution/delete_solution_command.rb} +5 -10
  70. data/lib/epc/command/solution/list_solutions_command.rb +1 -1
  71. data/lib/epc/command/{show_solution_command.rb → solution/show_solution_command.rb} +12 -7
  72. data/lib/epc/command/{unarchive_solution_command.rb → solution/unarchive_solution_command.rb} +1 -1
  73. data/lib/epc/command/solution/update_solution_command.rb +2 -1
  74. data/lib/epc/command/unarchive_command.rb +12 -0
  75. data/lib/epc/command/update_command.rb +15 -0
  76. data/lib/epc/command/update_rolepermissions_command.rb +2 -2
  77. data/lib/epc/command/{delete_user_command.rb → user/delete_user_command.rb} +4 -12
  78. data/lib/epc/command/{list_users_command.rb → user/list_users_command.rb} +1 -1
  79. data/lib/epc/command/{show_user_command.rb → user/show_user_command.rb} +3 -17
  80. data/lib/epc/command/{update_user_command.rb → user/update_user_command.rb} +2 -4
  81. data/lib/epc/config.rb +4 -1
  82. data/lib/epc/help.rb +50 -35
  83. data/lib/epc/runner.rb +16 -5
  84. data/lib/epc/version.rb +1 -1
  85. data/lib/epc/vertical_bar.rb +40 -0
  86. data/test/command/create_library_command_test.rb +5 -2
  87. data/test/command/create_libraryset_command_test.rb +1 -1
  88. data/test/command/create_plugin_command_test.rb +44 -0
  89. data/test/command/create_servicedefinition_command_test.rb +43 -0
  90. data/test/command/delete_config_command_test.rb +0 -11
  91. data/test/command/delete_dependency_command_test.rb +3 -11
  92. data/test/command/delete_library_command_test.rb +2 -15
  93. data/test/command/delete_librarylanguage_command_test.rb +2 -24
  94. data/test/command/delete_libraryset_command_test.rb +2 -24
  95. data/test/command/delete_plugin_command_test.rb +32 -0
  96. data/test/command/delete_project_command_test.rb +0 -6
  97. data/test/command/delete_role_command_test.rb +1 -1
  98. data/test/command/delete_serviceversion_command_test.rb +0 -22
  99. data/test/command/delete_solution_command_test.rb +4 -4
  100. data/test/command/delete_user_command_test.rb +2 -24
  101. data/test/command/list_config_command_test.rb +3 -3
  102. data/test/command/list_deployments_command_test.rb +17 -20
  103. data/test/command/list_deploymentstages_command_test.rb +2 -2
  104. data/test/command/list_metrics_command_test.rb +40 -0
  105. data/test/command/{list_rolepermissions_command_test.rb → list_permissions_command_test.rb} +2 -2
  106. data/test/command/list_plugins_command_test.rb +27 -0
  107. data/test/command/list_projects_command_test.rb +3 -5
  108. data/test/command/list_roles_command_test.rb +2 -3
  109. data/test/command/pull_command_test.rb +13 -9
  110. data/test/command/show_group_command_test.rb +1 -23
  111. data/test/command/show_instances_command_test.rb +33 -0
  112. data/test/command/show_libraryset_command_test.rb +0 -11
  113. data/test/command/show_metrics_command_test.rb +51 -0
  114. data/test/command/show_plugin_command_test.rb +28 -0
  115. data/test/command/show_project_command_test.rb +1 -1
  116. data/test/command/show_projecttype_command_test.rb +0 -5
  117. data/test/command/show_role_command_test.rb +1 -1
  118. data/test/command/show_solution_command_test.rb +1 -1
  119. data/test/command/show_user_command_test.rb +2 -22
  120. data/test/command/update_config_command_test.rb +3 -9
  121. data/test/command/{update_deploymentproject_command_test.rb → update_deployment_command_test.rb} +6 -11
  122. data/test/command/update_group_command_test.rb +1 -20
  123. data/test/command/update_librarylanguage_command_test.rb +0 -15
  124. data/test/command/update_libraryset_command_test.rb +0 -13
  125. data/test/command/update_plugin_command_test.rb +41 -0
  126. data/test/command/update_project_command_test.rb +3 -3
  127. data/test/command/update_role_command_test.rb +2 -1
  128. data/test/command/update_solution_command_test.rb +3 -9
  129. data/test/command/update_user_command_test.rb +0 -6
  130. metadata +177 -165
  131. data/lib/epc/command/define_service_command.rb +0 -37
  132. data/lib/epc/command/delete_config_command.rb +0 -63
  133. data/lib/epc/command/delete_group_command.rb +0 -40
  134. data/lib/epc/command/delete_library_command.rb +0 -30
  135. data/lib/epc/command/delete_librarylanguage_command.rb +0 -40
  136. data/lib/epc/command/delete_serviceversion_command.rb +0 -52
  137. data/lib/epc/command/list_approvals_command.rb +0 -27
  138. data/lib/epc/command/list_attachedlibraries_command.rb +0 -42
  139. data/lib/epc/command/list_boundservices_command.rb +0 -40
  140. data/lib/epc/command/list_dependencies_command.rb +0 -43
  141. data/lib/epc/command/list_deployments_command.rb +0 -68
  142. data/lib/epc/command/list_solutions_command.rb +0 -25
  143. data/lib/epc/command/show_deployment_command.rb +0 -57
  144. data/lib/epc/command/update_config_command.rb +0 -62
  145. data/lib/epc/command/update_role_command.rb +0 -47
  146. data/lib/epc/command/update_solution_command.rb +0 -45
  147. data/test/command/define_service_command_test.rb +0 -55
  148. data/test/command/delete_group_command_test.rb +0 -56
  149. data/test/command/list_approvals_command_test.rb +0 -41
  150. data/test/command/list_boundservices_command_test.rb +0 -46
  151. data/test/command/list_dependencies_command_test.rb +0 -46
  152. data/test/command/update_rolepermissions_command_test.rb +0 -54
@@ -0,0 +1,43 @@
1
+ require File.expand_path "../../../lib/epc", __FILE__
2
+ require "test/unit"
3
+ require 'shoulda'
4
+ require 'mocha'
5
+
6
+ class CreateServicedefinitionCommandTest < Test::Unit::TestCase
7
+ should_require_login
8
+
9
+ context "execution" do
10
+ setup do
11
+ @mock_client = mock('Client')
12
+ end
13
+
14
+ should "require both the name and service type" do
15
+ @command = EPC::Command::CreateServicedefinitionCommand.new(@mock_client)
16
+ assert_raise EPC::Error::FatalError do
17
+ @command.execute("")
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ context "service definition" do
24
+ setup do
25
+ @mock_client = stub('Client')
26
+ @command = EPC::Command::CreateServicedefinitionCommand.new(@mock_client, {:service_type => "MySQL"})
27
+ @command.expects(:retrieve_identifier_for).returns(1)
28
+ end
29
+
30
+ should "fail if status is not 201" do
31
+ @mock_client.expects(:post).with(EPC::Config::SERVICE_DEFINITIONS_PATH, {:name => "service", :type_id => 1}).returns([400, {:message => 'Not Found'}])
32
+ @command.expects(:say).with("Service definition failed with: [Not Found]")
33
+ @command.execute("", "service", "MySQL")
34
+ end
35
+
36
+ should "define a service" do
37
+ @mock_client.expects(:post).with(EPC::Config::SERVICE_DEFINITIONS_PATH, {:name => "service", :type_id => 1}).returns([201, {'id' => 1}])
38
+ @command.expects(:say).with("service has been defined.")
39
+ @command.execute("", "service", "MySQL")
40
+ end
41
+ end
42
+ end
43
+
@@ -3,17 +3,6 @@ require 'test_helper'
3
3
  class DeleteConfigCommandTest < Test::Unit::TestCase
4
4
  should_require_login
5
5
 
6
- context "invalid commands" do
7
- setup do
8
- @mock_client = mock("Client")
9
- @command = EPC::Command::DeleteConfigCommand.new(@mock_client)
10
- end
11
-
12
- should "fail when no key is specified" do
13
- @command.expects(:say).with("You must specify the key you wish to delete.")
14
- @command.execute()
15
- end
16
- end
17
6
 
18
7
  context "valid commands" do
19
8
  setup do
@@ -9,18 +9,10 @@ class DeleteDependencyCommandTest < Test::Unit::TestCase
9
9
  @command = EPC::Command::DeleteDependencyCommand.new(@mock_client)
10
10
  end
11
11
 
12
- should "fail if no dependency id specified" do
13
- @command.expects(:say).with("You must specify a dependency_id")
14
- @command.expects(:say).with(EPC::Help::COMMAND_USAGES[:delete_dependency])
15
-
16
- assert_equal(@command.execute, 1)
17
- end
18
-
19
12
  should "fail if project id can't be determined" do
20
- @command.expects(:infer_project_context).returns(nil)
21
- @command.expects(:say).with("Project could not be inferred")
22
- @command.expects(:say).with(EPC::Help::COMMAND_USAGES[:delete_dependency])
23
- assert_equal(@command.execute("1"), 1)
13
+ assert_raise EPC::Error::FatalError do
14
+ assert_equal(@command.execute("1"), 1)
15
+ end
24
16
  end
25
17
 
26
18
  context "deletion" do
@@ -9,22 +9,8 @@ class DeleteLibraryCommandTest < Test::Unit::TestCase
9
9
  @command = EPC::Command::DeleteLibraryCommand.new(@mock_client)
10
10
  end
11
11
 
12
- should "fail if no library name of id specified" do
13
- assert_raise EPC::Error::FatalError do
14
- assert_equal(@command.execute, 1)
15
- end
16
- end
17
-
18
- should "fail if library id can't be determined" do
19
- assert_raise EPC::Error::FatalError do
20
- @command.expects(:ask_yn).returns("Y")
21
- @command.expects(:retrieve_libraries).returns(nil)
22
-
23
- assert_equal(@command.execute("libmath"), 1)
24
- end
25
- end
26
-
27
12
  should "fail if status is not 200" do
13
+ @command.expects(:retrieve_identifier_for).returns(1)
28
14
  @command.expects(:ask_yn).returns("Y")
29
15
  @mock_client.expects(:delete).with(EPC::Config::LIBRARIES_PATH + "/1").returns([404, {:message => "Not Found"}, {}])
30
16
  @command.expects(:say).with("Request failed: [Not Found]")
@@ -33,6 +19,7 @@ class DeleteLibraryCommandTest < Test::Unit::TestCase
33
19
  end
34
20
 
35
21
  should "delete a library" do
22
+ @command.expects(:retrieve_identifier_for).returns(1)
36
23
  @command.expects(:ask_yn).returns("Y")
37
24
  @mock_client.expects(:delete).with(EPC::Config::LIBRARIES_PATH + "/1").returns([200, {}, {}])
38
25
  @command.expects(:say).with("Library deleted")
@@ -9,21 +9,8 @@ class DeleteLibrarylanguageCommandTest < Test::Unit::TestCase
9
9
  @command = EPC::Command::DeleteLibrarylanguageCommand.new(@mock_client)
10
10
  end
11
11
 
12
- should "fail if no names are specified" do
13
- @command.expects(:say).with("You need to specify a language id/name")
14
- @command.expects(:say).with(EPC::Help::COMMAND_USAGES[:delete_librarylanguage])
15
- assert_equal(@command.execute, 1)
16
- end
17
-
18
- should "fail if language id can't be determined" do
19
- @command.expects(:ask_yn).returns("Y")
20
- @command.expects(:get_resource_id).with(EPC::Config::LIBRARY_LANGUAGES_PATH, :name, "ruby").returns(nil)
21
- @command.expects(:say).with("Language could not be determined")
22
-
23
- assert_equal(@command.execute("ruby"), 1)
24
- end
25
-
26
12
  should "fail if status is not 200" do
13
+ @command.expects(:retrieve_identifier_for).returns(1)
27
14
  @command.expects(:ask_yn).returns("Y")
28
15
  @mock_client.expects(:delete).with(EPC::Config::LIBRARY_LANGUAGES_PATH + "/1").
29
16
  returns([404, {:message => "Not Found"}, {}])
@@ -33,6 +20,7 @@ class DeleteLibrarylanguageCommandTest < Test::Unit::TestCase
33
20
 
34
21
 
35
22
  should "delete a language specified by id" do
23
+ @command.expects(:retrieve_identifier_for).returns(1)
36
24
  @command.expects(:ask_yn).returns("Y")
37
25
  @mock_client.expects(:delete).with(EPC::Config::LIBRARY_LANGUAGES_PATH + "/1").
38
26
  returns([200, {}, {}])
@@ -41,15 +29,5 @@ class DeleteLibrarylanguageCommandTest < Test::Unit::TestCase
41
29
  assert_equal(@command.execute(1), 200)
42
30
  end
43
31
 
44
-
45
- should "delete a language specified by name" do
46
- @command.expects(:ask_yn).returns("Y")
47
- @command.expects(:get_resource_id).with(EPC::Config::LIBRARY_LANGUAGES_PATH, :name, "ruby").returns(1)
48
- @mock_client.expects(:delete).with(EPC::Config::LIBRARY_LANGUAGES_PATH + "/1").
49
- returns([200, {}, {}])
50
- @command.expects(:say).with("Language deleted")
51
-
52
- assert_equal(@command.execute("ruby"), 200)
53
- end
54
32
  end
55
33
  end
@@ -9,21 +9,9 @@ class DeleteLibrarysetCommand < Test::Unit::TestCase
9
9
  @command = EPC::Command::DeleteLibrarysetCommand.new(@mock_client)
10
10
  end
11
11
 
12
- should "fail if no names are specified" do
13
- @command.expects(:say).with("You need to specify a set id/name")
14
- @command.expects(:say).with(EPC::Help::COMMAND_USAGES[:delete_libraryset])
15
- assert_equal(@command.execute, 1)
16
- end
17
-
18
- should "fail if set id can't be determined" do
19
- @command.expects(:ask_yn).returns("Y")
20
- @command.expects(:get_resource_id).with(EPC::Config::LIBRARY_SETS_PATH, :name, "rubyset").returns(nil)
21
- @command.expects(:say).with("Set could not be determined")
22
-
23
- assert_equal(@command.execute("rubyset"), 1)
24
- end
25
12
 
26
13
  should "fail if status is not 200" do
14
+ @command.expects(:retrieve_identifier_for).returns(1)
27
15
  @command.expects(:ask_yn).returns("Y")
28
16
  @mock_client.expects(:delete).with(EPC::Config::LIBRARY_SETS_PATH + "/1").
29
17
  returns([404, {:message => "Not Found"}, {}])
@@ -33,6 +21,7 @@ class DeleteLibrarysetCommand < Test::Unit::TestCase
33
21
 
34
22
 
35
23
  should "delete a set specified by id" do
24
+ @command.expects(:retrieve_identifier_for).returns(1)
36
25
  @command.expects(:ask_yn).returns("Y")
37
26
  @mock_client.expects(:delete).with(EPC::Config::LIBRARY_SETS_PATH + "/1").
38
27
  returns([200, {}, {}])
@@ -40,16 +29,5 @@ class DeleteLibrarysetCommand < Test::Unit::TestCase
40
29
 
41
30
  assert_equal(@command.execute(1), 200)
42
31
  end
43
-
44
-
45
- should "delete a set specified by name" do
46
- @command.expects(:ask_yn).returns("Y")
47
- @command.expects(:get_resource_id).with(EPC::Config::LIBRARY_SETS_PATH, :name, "rubyset").returns(1)
48
- @mock_client.expects(:delete).with(EPC::Config::LIBRARY_SETS_PATH + "/1").
49
- returns([200, {}, {}])
50
- @command.expects(:say).with("Set deleted")
51
-
52
- assert_equal(@command.execute("rubyset"), 200)
53
- end
54
32
  end
55
33
  end
@@ -0,0 +1,32 @@
1
+ require 'test_helper'
2
+
3
+ class DeletePluginCommandTest < Test::Unit::TestCase
4
+ should_require_login
5
+
6
+ context "execute" do
7
+ setup do
8
+ @mock_client = mock("Client")
9
+ @command = EPC::Command::DeletePluginCommand.new(@mock_client)
10
+ end
11
+
12
+ should "fail if status is not 200" do
13
+ @command.expects(:retrieve_identifier_for).returns(1)
14
+ @command.expects(:ask_yn).returns("Y")
15
+ @mock_client.expects(:delete).with(EPC::Config::PLUGINS_PATH + "/1").
16
+ returns([404, {:message => "Not Found"}, {}])
17
+ @command.expects(:say).with("Request failed: [Not Found]")
18
+ assert_equal(@command.execute(1), 404)
19
+ end
20
+
21
+
22
+ should "delete a plugin specified by id" do
23
+ @command.expects(:retrieve_identifier_for).returns(1)
24
+ @command.expects(:ask_yn).returns("Y")
25
+ @mock_client.expects(:delete).with(EPC::Config::PLUGINS_PATH + "/1").
26
+ returns([200, {}, {}])
27
+ @command.expects(:say).with("Plugin deleted")
28
+
29
+ assert_equal(@command.execute(1), 200)
30
+ end
31
+ end
32
+ end
@@ -10,12 +10,6 @@ class DeleteProjectCommandTest < Test::Unit::TestCase
10
10
  @command = EPC::Command::DeleteProjectCommand.new(@mock_client)
11
11
  end
12
12
 
13
- should "fail no project specified" do
14
- @command.expects(:infer_project_context).returns(nil)
15
- @command.expects(:say).with("Project name could not be inferred")
16
- @command.expects(:say).with(EPC::Help::COMMAND_USAGES[:delete_project])
17
- assert_equal(@command.execute, 1)
18
- end
19
13
  end
20
14
  context "deletion" do
21
15
  setup do
@@ -30,7 +30,7 @@ class DeleteRoleCommandTest < Test::Unit::TestCase
30
30
 
31
31
  should "delete a role specified by name" do
32
32
  @command.expects(:ask_yn).returns("Y")
33
- @command.expects(:retrieve_system_role_identifier).returns(1)
33
+ @command.expects(:retrieve_identifier_for).returns(1)
34
34
  @mock_client.expects(:delete).with(EPC::Config::ROLES_PATH + "/1/system/true").
35
35
  returns([200, {}, {}])
36
36
  @command.expects(:say).with("Role deleted")
@@ -9,28 +9,6 @@ class DeleteServiceversionCommandTest < Test::Unit::TestCase
9
9
  @command = EPC::Command::DeleteServiceversionCommand.new(@mock_client)
10
10
  end
11
11
 
12
- should "fail if no service version identifier specified" do
13
- @command.expects(:say).with("You must specify a service version identifier")
14
- @command.expects(:say).with(EPC::Help::COMMAND_USAGES[:delete_serviceversion])
15
-
16
- assert_equal(@command.execute, 1)
17
- end
18
-
19
- should "fail if service label specified without definition_name" do
20
- @command.expects(:ask_yn).returns("Y")
21
- @command.expects(:say).with("You must specify the definition name")
22
-
23
- @command.expects(:say).with(EPC::Help::COMMAND_USAGES[:delete_serviceversion])
24
- assert_equal(@command.execute("main_db"), 1)
25
- end
26
-
27
- should "query core for service-version id and show a message if it can't be found" do
28
- @command.expects(:ask_yn).returns("Y")
29
- @mock_client.expects(:get)
30
- @command.expects(:say).with("Service version not found.")
31
-
32
- assert_equal(@command.execute("main_db", "definition"), 1)
33
- end
34
12
 
35
13
  should "fail if status is not 200" do
36
14
  @command.expects(:ask_yn).returns("Y")
@@ -12,10 +12,10 @@ class DeleteSolutionCommandTest < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  should "fail if solution id can't be determined" do
15
- @command.expects(:infer_solution_context).returns(nil)
16
- @command.expects(:say).with("Solution could not be inferred")
17
-
18
- assert_equal(@command.execute("FirstSolution"), 1)
15
+ assert_raise EPC::Error::FatalError do
16
+ @command.expects(:infer_solution_context).returns(nil)
17
+ assert_equal(@command.execute("FirstSolution"), 1)
18
+ end
19
19
  end
20
20
  end
21
21
 
@@ -9,13 +9,8 @@ class DeleteUserCommandTest < Test::Unit::TestCase
9
9
  @command = EPC::Command::DeleteUserCommand.new(@mock_client)
10
10
  end
11
11
 
12
- should "fail if no user is specified" do
13
- assert_raise EPC::Error::FatalError do
14
- assert_equal(@command.execute, 1)
15
- end
16
- end
17
-
18
12
  should "fail if status is not 200" do
13
+ @command.expects(:retrieve_identifier_for).returns(1)
19
14
  @command.expects(:ask_yn).returns("Y")
20
15
  @mock_client.expects(:delete).with(EPC::Config::USERS_PATH + "/1").
21
16
  returns([404, {:message => "Not Found"}, {}])
@@ -23,17 +18,9 @@ class DeleteUserCommandTest < Test::Unit::TestCase
23
18
  assert_equal(@command.execute(1), 404)
24
19
  end
25
20
 
26
- should "fail if user_id can't be determined" do
27
- @command.expects(:ask_yn).returns("Y")
28
- @command.expects(:get_resource_id).with(EPC::Config::USERS_PATH, :email, "admin").returns(nil)
29
- assert_raise EPC::Error::FatalError do
30
- assert_equal(@command.execute("admin"), 1)
31
- end
32
- end
33
-
34
-
35
21
 
36
22
  should "delete a user specified by id" do
23
+ @command.expects(:retrieve_identifier_for).returns(1)
37
24
  @command.expects(:ask_yn).returns("Y")
38
25
  @mock_client.expects(:delete).with(EPC::Config::USERS_PATH + "/1").
39
26
  returns([200, {}, {}])
@@ -43,14 +30,5 @@ class DeleteUserCommandTest < Test::Unit::TestCase
43
30
  end
44
31
 
45
32
 
46
- should "delete a user specified by name" do
47
- @command.expects(:ask_yn).returns("Y")
48
- @command.expects(:get_resource_id).with(EPC::Config::USERS_PATH, :email, "admin").returns(1)
49
- @mock_client.expects(:delete).with(EPC::Config::USERS_PATH + "/1").
50
- returns([200, {}, {}])
51
- @command.expects(:say).with("User deleted")
52
-
53
- assert_equal(@command.execute("admin"), 200)
54
- end
55
33
  end
56
34
  end
@@ -1,12 +1,12 @@
1
1
  require 'test_helper'
2
2
 
3
- class ListConfigCommandTest < Test::Unit::TestCase
3
+ class ListConfigsCommandTest < Test::Unit::TestCase
4
4
  should_require_login
5
5
 
6
6
  context "execution" do
7
7
  should "fail if configuration context can't be determined" do
8
8
  @mock_client = mock("Client")
9
- @command = EPC::Command::ListConfigCommand.new(@mock_client)
9
+ @command = EPC::Command::ListConfigsCommand.new(@mock_client)
10
10
  @command.expects(:extract_configuration_level).returns(nil)
11
11
 
12
12
  assert_raise EPC::Error::FatalError do
@@ -19,7 +19,7 @@ class ListConfigCommandTest < Test::Unit::TestCase
19
19
  setup do
20
20
  @mock_client = mock("Client")
21
21
  @names_hash = {:solution => "S1", :project => "P1"}
22
- @command = EPC::Command::ListConfigCommand.new(@mock_client)
22
+ @command = EPC::Command::ListConfigsCommand.new(@mock_client)
23
23
  @command.expects(:extract_configuration_level).returns(["User", 1])
24
24
  end
25
25
 
@@ -11,92 +11,89 @@ class ListDeploymentsCommandTest < Test::Unit::TestCase
11
11
 
12
12
 
13
13
  should "show exception message status is not 201" do
14
- @command.options[:solution_name] = 1
14
+ @command.expects(:retrieve_identifier_for).returns(1)
15
15
  @mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH + "/1/deployments").
16
16
  returns([400, {:message => "Not Found"}, {}])
17
17
  @command.expects(:say).with("Deployments retrieval failed with [Not Found]")
18
18
 
19
- assert_equal(@command.execute, 400)
19
+ assert_equal(@command.execute("Solution:1"), 400)
20
20
  end
21
21
 
22
22
  should "show a message if there are no deployments" do
23
- @command.options[:solution_name] = 1
23
+ @command.expects(:retrieve_identifier_for).returns(1)
24
24
  @mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH + "/1/deployments").
25
25
  returns([200, {}, {}])
26
26
 
27
27
  @command.expects(:say).returns("You have no deployments created.You can create them with epc create deployment.")
28
28
 
29
- assert_equal(@command.execute, 200)
29
+ assert_equal(@command.execute("Solution:1"), 200)
30
30
  end
31
31
 
32
32
  should "list available deployments for solutions specified with name" do
33
- @command.options[:solution_name] = "FirstSolution"
34
- @command.expects(:get_resource_id).with(EPC::Config::SOLUTIONS_PATH, :name, "FirstSolution").returns(1)
33
+ @command.expects(:retrieve_identifier_for).returns(1)
35
34
  @mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH + "/1/deployments").
36
35
  returns([200,
37
36
  [
38
37
  {:id => 1, :deployer_name => "deployer_name", :solution_name => "FirstSolution", :deployment_stage_name => "development", :status => "RUNNING"}
39
38
  ], {}])
40
39
  @command.expects(:say).at_least_once
41
- assert_equal(@command.execute, 200)
40
+ assert_equal(@command.execute("Solution:FirstSolution"), 200)
42
41
  end
43
42
 
44
43
  should "list available deployments for solutions specified with id" do
45
- @command.options[:solution_name] = 1
44
+ @command.expects(:retrieve_identifier_for).returns(1)
46
45
  @mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH + "/1/deployments").
47
46
  returns([200,
48
47
  [
49
48
  {:id => 1, :deployer_name => "deployer_name", :solution_name => "FirstSolution", :deployment_stage_name => "development", :status => "RUNNING"}
50
49
  ], {}])
51
50
  @command.expects(:say).at_least_once
52
- assert_equal(@command.execute, 200)
51
+ assert_equal(@command.execute("Solution:1"), 200)
53
52
  end
54
53
 
55
54
 
56
55
  should "list available deployments for stages specified with name" do
57
- @command.options[:stage_name] = "Development"
58
- @command.expects(:get_resource_id).with(EPC::Config::DEPLOYMENT_STAGES_PATH, :name, "Development", :case_sensitivity => false).returns(1)
56
+ @command.expects(:retrieve_identifier_for).returns(1)
59
57
  @mock_client.expects(:get).with(EPC::Config::DEPLOYMENT_STAGES_PATH + "/1/deployments").
60
58
  returns([200,
61
59
  [
62
60
  {:id => 1, :deployer_name => "deployer_name", :solution_name => "FirstSolution", :deployment_stage_name => "development", :status => "RUNNING"}
63
61
  ], {}])
64
62
  @command.expects(:say).at_least_once
65
- assert_equal(@command.execute, 200)
63
+ assert_equal(@command.execute("DeploymentStage:Development"), 200)
66
64
  end
67
65
 
68
66
  should "list available deployments for stages specified with id" do
69
- @command.options[:stage_name] = 1
67
+ @command.expects(:retrieve_identifier_for).returns(1)
70
68
  @mock_client.expects(:get).with(EPC::Config::DEPLOYMENT_STAGES_PATH + "/1/deployments").
71
69
  returns([200,
72
70
  [
73
71
  {:id => 1, :deployer_name => "deployer_name", :solution_name => "FirstSolution", :deployment_stage_name => "development", :status => "RUNNING"}
74
72
  ], {}])
75
73
  @command.expects(:say).at_least_once
76
- assert_equal(@command.execute, 200)
74
+ assert_equal(@command.execute("DeploymentStage:1"), 200)
77
75
  end
78
76
 
79
77
  should "list available deployments for users specified with name" do
80
- @command.options[:user_name] = "Admin"
81
- @command.expects(:get_resource_id).with(EPC::Config::USERS_PATH, :name, "Admin").returns(1)
78
+ @command.expects(:retrieve_identifier_for).returns(1)
82
79
  @mock_client.expects(:get).with(EPC::Config::USERS_PATH + "/1/deployments").
83
80
  returns([200,
84
81
  [
85
82
  {:id => 1, :deployer_name => "deployer_name", :solution_name => "FirstSolution", :deployment_stage_name => "development", :status => "RUNNING"}
86
83
  ], {}])
87
84
  @command.expects(:say).at_least_once
88
- assert_equal(@command.execute, 200)
85
+ assert_equal(@command.execute("User:Admin"), 200)
89
86
  end
90
87
 
91
88
  should "list available deployments for users specified with id" do
92
- @command.options[:user_name] = 1
89
+ @command.expects(:retrieve_identifier_for).returns(1)
93
90
  @mock_client.expects(:get).with(EPC::Config::USERS_PATH + "/1/deployments").
94
91
  returns([200,
95
92
  [
96
93
  {:id => 1, :deployer_name => "deployer_name", :solution_name => "FirstSolution", :deployment_stage_name => "development", :status => "RUNNING"}
97
94
  ], {}])
98
95
  @command.expects(:say).at_least_once
99
- assert_equal(@command.execute, 200)
96
+ assert_equal(@command.execute("User:1"), 200)
100
97
  end
101
98
 
102
99
  should "try to determine solution context if no other option specified" do
@@ -105,7 +102,7 @@ class ListDeploymentsCommandTest < Test::Unit::TestCase
105
102
  @mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH + "/1/deployments").
106
103
  returns([200, {}, {}])
107
104
  @command.expects(:say).at_least_once
108
- assert_equal(@command.execute, 200)
105
+ assert_equal(@command.execute(""), 200)
109
106
  end
110
107
 
111
108
  end