epc 1.0.2
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.
- data/CHANGELOG +1 -0
- data/Gemfile +22 -0
- data/Rakefile +67 -0
- data/Rakefile.gem +1 -0
- data/bin/epc +10 -0
- data/lib/epc.rb +126 -0
- data/lib/epc/client/base_client.rb +80 -0
- data/lib/epc/client/http_client.rb +19 -0
- data/lib/epc/client/json_client.rb +48 -0
- data/lib/epc/command/archive_project_command.rb +24 -0
- data/lib/epc/command/archive_solution_command.rb +21 -0
- data/lib/epc/command/attach_library_command.rb +82 -0
- data/lib/epc/command/attach_libraryset_command.rb +32 -0
- data/lib/epc/command/attach_runtime_command.rb +27 -0
- data/lib/epc/command/base_command.rb +451 -0
- data/lib/epc/command/bind_service_command.rb +35 -0
- data/lib/epc/command/build_command.rb +83 -0
- data/lib/epc/command/config/create_config_command.rb +55 -0
- data/lib/epc/command/copy_deployment_command.rb +21 -0
- data/lib/epc/command/create_command.rb +13 -0
- data/lib/epc/command/create_dependency_command.rb +43 -0
- data/lib/epc/command/define_service_command.rb +37 -0
- data/lib/epc/command/delete_config_command.rb +63 -0
- data/lib/epc/command/delete_dependency_command.rb +40 -0
- data/lib/epc/command/delete_group_command.rb +40 -0
- data/lib/epc/command/delete_library_command.rb +30 -0
- data/lib/epc/command/delete_librarylanguage_command.rb +40 -0
- data/lib/epc/command/delete_libraryset_command.rb +40 -0
- data/lib/epc/command/delete_project_command.rb +54 -0
- data/lib/epc/command/delete_role_command.rb +25 -0
- data/lib/epc/command/delete_serviceversion_command.rb +52 -0
- data/lib/epc/command/delete_solution_command.rb +39 -0
- data/lib/epc/command/delete_user_command.rb +31 -0
- data/lib/epc/command/deploy_command.rb +142 -0
- data/lib/epc/command/deployment/create_deployment_command.rb +82 -0
- data/lib/epc/command/detach_library_command.rb +35 -0
- data/lib/epc/command/detach_libraryset_command.rb +8 -0
- data/lib/epc/command/group/create_group_command.rb +21 -0
- data/lib/epc/command/info_command.rb +11 -0
- data/lib/epc/command/library/create_library_command.rb +45 -0
- data/lib/epc/command/librarylanguage/create_librarylanguage_command.rb +24 -0
- data/lib/epc/command/libraryset/create_libraryset_command.rb +54 -0
- data/lib/epc/command/list_approvals_command.rb +27 -0
- data/lib/epc/command/list_attachedlibraries_command.rb +42 -0
- data/lib/epc/command/list_boundservices_command.rb +40 -0
- data/lib/epc/command/list_config_command.rb +60 -0
- data/lib/epc/command/list_dependencies_command.rb +43 -0
- data/lib/epc/command/list_deployments_command.rb +68 -0
- data/lib/epc/command/list_groups_command.rb +19 -0
- data/lib/epc/command/list_libraries_command.rb +19 -0
- data/lib/epc/command/list_librarylanguages_command.rb +19 -0
- data/lib/epc/command/list_librarysets_command.rb +26 -0
- data/lib/epc/command/list_objectroles_command.rb +25 -0
- data/lib/epc/command/list_objecttypes_command.rb +20 -0
- data/lib/epc/command/list_permissiongroups_command.rb +20 -0
- data/lib/epc/command/list_projects_command.rb +36 -0
- data/lib/epc/command/list_projecttypes_command.rb +20 -0
- data/lib/epc/command/list_rolepermissions_command.rb +21 -0
- data/lib/epc/command/list_roles_command.rb +26 -0
- data/lib/epc/command/list_runtimes_command.rb +16 -0
- data/lib/epc/command/list_service_types_command.rb +19 -0
- data/lib/epc/command/list_servicedefinitions_command.rb +19 -0
- data/lib/epc/command/list_serviceversions_command.rb +21 -0
- data/lib/epc/command/list_solutions_command.rb +25 -0
- data/lib/epc/command/list_stages_command.rb +21 -0
- data/lib/epc/command/list_users_command.rb +26 -0
- data/lib/epc/command/list_versions_command.rb +39 -0
- data/lib/epc/command/login_command.rb +32 -0
- data/lib/epc/command/logout_command.rb +20 -0
- data/lib/epc/command/objectrole/create_objectrole_command.rb +19 -0
- data/lib/epc/command/project/create_project_command.rb +78 -0
- data/lib/epc/command/pull_command.rb +209 -0
- data/lib/epc/command/push_command.rb +194 -0
- data/lib/epc/command/refresh_solution_command.rb +71 -0
- data/lib/epc/command/renew_command.rb +19 -0
- data/lib/epc/command/request_passwordchange_command.rb +23 -0
- data/lib/epc/command/role/create_role_command.rb +17 -0
- data/lib/epc/command/serviceversion/create_serviceversion_command.rb +33 -0
- data/lib/epc/command/show_deployment_command.rb +57 -0
- data/lib/epc/command/show_group_command.rb +35 -0
- data/lib/epc/command/show_libraryset_command.rb +54 -0
- data/lib/epc/command/show_project_command.rb +74 -0
- data/lib/epc/command/show_projecttype_command.rb +18 -0
- data/lib/epc/command/show_role_command.rb +46 -0
- data/lib/epc/command/show_solution_command.rb +54 -0
- data/lib/epc/command/show_user_command.rb +42 -0
- data/lib/epc/command/solution/create_solution_command.rb +34 -0
- data/lib/epc/command/solution/list_solutions_command.rb +25 -0
- data/lib/epc/command/solution/update_solution_command.rb +43 -0
- data/lib/epc/command/submit_deployment_command.rb +19 -0
- data/lib/epc/command/target_command.rb +26 -0
- data/lib/epc/command/unarchive_project_command.rb +23 -0
- data/lib/epc/command/unarchive_solution_command.rb +21 -0
- data/lib/epc/command/unbind_service_command.rb +42 -0
- data/lib/epc/command/undefine_service_command.rb +33 -0
- data/lib/epc/command/undeploy_command.rb +106 -0
- data/lib/epc/command/update_config_command.rb +62 -0
- data/lib/epc/command/update_deploymentproject_command.rb +54 -0
- data/lib/epc/command/update_group_command.rb +43 -0
- data/lib/epc/command/update_librarylanguage_command.rb +28 -0
- data/lib/epc/command/update_libraryset_command.rb +80 -0
- data/lib/epc/command/update_project_command.rb +49 -0
- data/lib/epc/command/update_role_command.rb +47 -0
- data/lib/epc/command/update_rolepermissions_command.rb +83 -0
- data/lib/epc/command/update_solution_command.rb +45 -0
- data/lib/epc/command/update_user_command.rb +57 -0
- data/lib/epc/command/user/create_user_command.rb +27 -0
- data/lib/epc/command/vote_deployment_command.rb +29 -0
- data/lib/epc/config.rb +245 -0
- data/lib/epc/error/basic_error.rb +6 -0
- data/lib/epc/error/fatal_error.rb +6 -0
- data/lib/epc/error/input_error.rb +6 -0
- data/lib/epc/error/internal_error.rb +6 -0
- data/lib/epc/help.rb +292 -0
- data/lib/epc/persistent_attributes.rb +18 -0
- data/lib/epc/runner.rb +177 -0
- data/lib/epc/tabular_outputter.rb +161 -0
- data/lib/epc/version.rb +3 -0
- data/lib/fixnum.rb +9 -0
- data/lib/object.rb +13 -0
- data/test/command/archive_project_command_test.rb +41 -0
- data/test/command/archive_solution_command_test.rb +40 -0
- data/test/command/attach_library_command_test.rb +124 -0
- data/test/command/attach_libraryset_command_test.rb +49 -0
- data/test/command/attach_runtime_command_test.rb +44 -0
- data/test/command/base_command_test.rb +276 -0
- data/test/command/bind_service_command_test.rb +46 -0
- data/test/command/build_command_test.rb +103 -0
- data/test/command/copy_deployment_command_test.rb +38 -0
- data/test/command/create_config_command_test.rb +124 -0
- data/test/command/create_dependency_command_test.rb +55 -0
- data/test/command/create_deployment_command_test.rb +136 -0
- data/test/command/create_group_command_test.rb +34 -0
- data/test/command/create_library_command_test.rb +61 -0
- data/test/command/create_librarylanguage_command_test.rb +51 -0
- data/test/command/create_libraryset_command_test.rb +81 -0
- data/test/command/create_objectrole_command_test.rb +37 -0
- data/test/command/create_project_command_test.rb +102 -0
- data/test/command/create_role_command_test.rb +31 -0
- data/test/command/create_serviceversion_command_test.rb +60 -0
- data/test/command/create_solution_command_test.rb +70 -0
- data/test/command/create_user_command_test.rb +54 -0
- data/test/command/define_service_command_test.rb +55 -0
- data/test/command/delete_config_command_test.rb +82 -0
- data/test/command/delete_dependency_command_test.rb +50 -0
- data/test/command/delete_group_command_test.rb +56 -0
- data/test/command/delete_library_command_test.rb +43 -0
- data/test/command/delete_librarylanguage_command_test.rb +55 -0
- data/test/command/delete_libraryset_command_test.rb +55 -0
- data/test/command/delete_project_command_test.rb +76 -0
- data/test/command/delete_role_command_test.rb +41 -0
- data/test/command/delete_serviceversion_command_test.rb +53 -0
- data/test/command/delete_solution_command_test.rb +79 -0
- data/test/command/delete_user_command_test.rb +56 -0
- data/test/command/deploy_command_test.rb +185 -0
- data/test/command/detach_library_command_test.rb +53 -0
- data/test/command/info_command_test.rb +17 -0
- data/test/command/list_approvals_command_test.rb +41 -0
- data/test/command/list_boundservices_command_test.rb +46 -0
- data/test/command/list_config_command_test.rb +72 -0
- data/test/command/list_dependencies_command_test.rb +46 -0
- data/test/command/list_deployments_command_test.rb +112 -0
- data/test/command/list_deploymentstages_command_test.rb +44 -0
- data/test/command/list_libraries_command_test.rb +42 -0
- data/test/command/list_librarylanguages_command_test.rb +34 -0
- data/test/command/list_librarysets_command_test.rb +33 -0
- data/test/command/list_objectroles_command_test.rb +41 -0
- data/test/command/list_objecttypes_command_test.rb +25 -0
- data/test/command/list_permissiongroups_command_test.rb +25 -0
- data/test/command/list_projects_command_test.rb +63 -0
- data/test/command/list_projecttypes_command_test.rb +39 -0
- data/test/command/list_rolepermissions_command_test.rb +39 -0
- data/test/command/list_roles_command_test.rb +46 -0
- data/test/command/list_runtimes_command_test.rb +30 -0
- data/test/command/list_service_types_command_test.rb +44 -0
- data/test/command/list_servicedefinitions_command_test.rb +44 -0
- data/test/command/list_serviceversions_command_test.rb +47 -0
- data/test/command/list_solutions_command_test.rb +48 -0
- data/test/command/list_users_command_test.rb +33 -0
- data/test/command/login_command_test.rb +83 -0
- data/test/command/logout_command_test.rb +30 -0
- data/test/command/pull_command_test.rb +229 -0
- data/test/command/push_command_test.rb +246 -0
- data/test/command/refresh_solution_command_test.rb +35 -0
- data/test/command/renew_command_test.rb +43 -0
- data/test/command/request_passwordchange_command_test.rb +31 -0
- data/test/command/show_group_command_test.rb +50 -0
- data/test/command/show_libraryset_command_test.rb +51 -0
- data/test/command/show_project_command_test.rb +57 -0
- data/test/command/show_projecttype_command_test.rb +46 -0
- data/test/command/show_role_command_test.rb +37 -0
- data/test/command/show_solution_command_test.rb +59 -0
- data/test/command/show_user_command_test.rb +50 -0
- data/test/command/submit_deployment_command_test.rb +37 -0
- data/test/command/target_command_test.rb +58 -0
- data/test/command/unarchive_project_command_test.rb +45 -0
- data/test/command/unarchive_solution_command_test.rb +43 -0
- data/test/command/unbind_service_command_test.rb +48 -0
- data/test/command/undefine_service_command_test.rb +49 -0
- data/test/command/update_config_command_test.rb +74 -0
- data/test/command/update_deploymentproject_command_test.rb +77 -0
- data/test/command/update_group_command_test.rb +69 -0
- data/test/command/update_librarylanguage_command_test.rb +43 -0
- data/test/command/update_libraryset_command_test.rb +113 -0
- data/test/command/update_project_command_test.rb +56 -0
- data/test/command/update_role_command_test.rb +42 -0
- data/test/command/update_rolepermissions_command_test.rb +54 -0
- data/test/command/update_solution_command_test.rb +58 -0
- data/test/command/update_user_command_test.rb +76 -0
- data/test/command/vote_deployment_command_test.rb +33 -0
- data/test/config_test.rb +70 -0
- data/test/successful_test.rb +21 -0
- data/test/test_files/pom.xml +273 -0
- data/test/test_helper.rb +25 -0
- metadata +470 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DetachLibraryCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::DetachLibraryCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if library not specified" do
|
13
|
+
assert_raise EPC::Error::FatalError do
|
14
|
+
assert_equal(@command.execute, 1)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
should "fail if project can't be inferred" do
|
19
|
+
assert_raise EPC::Error::FatalError do
|
20
|
+
@command.expects(:infer_project_context).returns([nil, nil])
|
21
|
+
assert_equal(@command.execute("math_lib"), 1)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
should "fail if library id cannot be determined" do
|
26
|
+
assert_raise EPC::Error::FatalError do
|
27
|
+
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
28
|
+
@command.expects(:retrieve_libraries).with([{:name => "math_lib", :library_version => "1.2", :group => "grp"}]).returns(nil)
|
29
|
+
|
30
|
+
assert_equal(@command.execute("math_lib", "1.2", "grp"), 1)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
should "fail if status is not 200" do
|
36
|
+
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
37
|
+
@mock_client.expects(:delete).with(EPC::Config::PROJECTS_PATH + "/1/detach_library/1").
|
38
|
+
returns([404, {:message => "Not Found"}, {}])
|
39
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
40
|
+
|
41
|
+
assert_equal(@command.execute(1), 404)
|
42
|
+
end
|
43
|
+
|
44
|
+
should "detach the library from the project" do
|
45
|
+
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
46
|
+
@mock_client.expects(:delete).with(EPC::Config::PROJECTS_PATH + "/1/detach_library/1").
|
47
|
+
returns([200, {}, {}])
|
48
|
+
@command.expects(:say).with("Library detached from project.")
|
49
|
+
|
50
|
+
assert_equal(@command.execute(1), 200)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class InfoCommandTest < Test::Unit::TestCase
|
4
|
+
context "info" do
|
5
|
+
|
6
|
+
setup do
|
7
|
+
EPC::Command::InfoCommand.new(mock("Client"))
|
8
|
+
end
|
9
|
+
|
10
|
+
should "display target and current user" do
|
11
|
+
command = EPC::Command::InfoCommand.new(mock("Client"))
|
12
|
+
command.expects(:say).with("TARGET: #{EPC::Config.target_url} CURRENT_USER: #{EPC::Config.username ? EPC::Config.username : 'N/A'}" )
|
13
|
+
assert_equal(command.execute, 0)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListApprovalsCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ListApprovalsCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if deployment_id can't be determined" do
|
13
|
+
|
14
|
+
@command.expects(:say).with("You must specify a deployment id")
|
15
|
+
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:list_approvals])
|
16
|
+
assert_equal(@command.execute, 1)
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
should "show a message if status is not 200" do
|
21
|
+
@mock_client.expects(:get).with(EPC::Config::DEPLOYMENTS_PATH + "/1/approvals").returns([400, {:message => "Not Found"}, {}])
|
22
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
23
|
+
assert_equal(@command.execute(1), 400)
|
24
|
+
end
|
25
|
+
|
26
|
+
should "show a message if no approvals are found" do
|
27
|
+
@mock_client.expects(:get).with(EPC::Config::DEPLOYMENTS_PATH + "/1/approvals").returns([200, {}, {}])
|
28
|
+
@command.expects(:say).with("No approvals have been defined")
|
29
|
+
assert_equal(@command.execute(1), 200)
|
30
|
+
end
|
31
|
+
|
32
|
+
should "request and show approvals" do
|
33
|
+
@mock_client.expects(:get).with(EPC::Config::DEPLOYMENTS_PATH + "/1/approvals").
|
34
|
+
returns([200, [{:id => 1, :name => "admin approval", :approved => true, :user_id => 1}], {}])
|
35
|
+
|
36
|
+
@command.expects(:say)
|
37
|
+
assert_equal(@command.execute(1), 200)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListBoundservicesCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ListBoundservicesCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if library not specified" do
|
13
|
+
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:list_boundservices])
|
14
|
+
|
15
|
+
assert_equal(@command.execute, 1)
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
should "fail if status is not 200" do
|
20
|
+
@mock_client.expects(:get).with(EPC::Config::PROJECTS_PATH + "/1/service_versions").
|
21
|
+
returns([404, {:message => "Not Found"}, {}])
|
22
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
23
|
+
|
24
|
+
assert_equal(@command.execute(1), 404)
|
25
|
+
end
|
26
|
+
|
27
|
+
should "list bound-services" do
|
28
|
+
@mock_client.expects(:get).with(EPC::Config::PROJECTS_PATH + "/1/service_versions").
|
29
|
+
returns([200, [{
|
30
|
+
:id => 100,
|
31
|
+
:current => false,
|
32
|
+
:service_version => {
|
33
|
+
:label => "Label",
|
34
|
+
:id => 133,
|
35
|
+
:label => "Version 20",
|
36
|
+
:service_definition => {
|
37
|
+
:id => 133,
|
38
|
+
:name => "Service Definition 20"
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}], {}])
|
42
|
+
@command.expects(:say).twice
|
43
|
+
assert_equal(@command.execute(1), 200)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListConfigCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execution" do
|
7
|
+
should "fail if configuration context can't be determined" do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ListConfigCommand.new(@mock_client)
|
10
|
+
@command.expects(:extract_configuration_level).returns(nil)
|
11
|
+
|
12
|
+
assert_raise EPC::Error::FatalError do
|
13
|
+
@command.execute
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "list configurations" do
|
19
|
+
setup do
|
20
|
+
@mock_client = mock("Client")
|
21
|
+
@names_hash = {:solution => "S1", :project => "P1"}
|
22
|
+
@command = EPC::Command::ListConfigCommand.new(@mock_client)
|
23
|
+
@command.expects(:extract_configuration_level).returns(["User", 1])
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
should "show exception message status is not 201" do
|
28
|
+
@mock_client.expects(:get).with(EPC::Config::CONFIGURATIONS_PATH + "/User/1").
|
29
|
+
returns([400, {:message => "Not Found"}, {}])
|
30
|
+
@command.expects(:say).with("Configuration retrieval failed with [Not Found]")
|
31
|
+
|
32
|
+
assert_equal(@command.execute, 400)
|
33
|
+
end
|
34
|
+
|
35
|
+
should "show a message if there are no configurations keys" do
|
36
|
+
|
37
|
+
@mock_client.expects(:get).with(EPC::Config::CONFIGURATIONS_PATH + "/User/1").
|
38
|
+
returns([200, {}, {}])
|
39
|
+
|
40
|
+
@command.expects(:say).returns("No configurations keys have been defined for this project.")
|
41
|
+
|
42
|
+
assert_equal(@command.execute, 200)
|
43
|
+
end
|
44
|
+
|
45
|
+
should "list available configuration keys" do
|
46
|
+
@mock_client.expects(:get).with(EPC::Config::CONFIGURATIONS_PATH + "/User/1").
|
47
|
+
returns([200,
|
48
|
+
[
|
49
|
+
{:name => "key1", :value => "value1", :value_type => "text", :required => false},
|
50
|
+
{:name => "key2", :value => "value2", :value_type => "data", :required => true}],
|
51
|
+
{}])
|
52
|
+
|
53
|
+
@command.expects(:say).at_least_once
|
54
|
+
|
55
|
+
assert_equal(@command.execute, 200)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
should "return only the specified key" do
|
60
|
+
@mock_client.expects(:get).with(EPC::Config::CONFIGURATIONS_PATH + "/User/1").
|
61
|
+
returns([200,
|
62
|
+
[
|
63
|
+
{:name => "key1", :value => "value1", :value_type => "text", :required => false},
|
64
|
+
{:name => "key2", :value => "value2", :value_type => "data", :required => true}],
|
65
|
+
{}])
|
66
|
+
|
67
|
+
@command.expects(:say).at_least_once
|
68
|
+
assert_equal(@command.execute("key1"), 200)
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListDependenciesCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ListDependenciesCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if project_id can't be determined" do
|
13
|
+
@command.expects(:infer_project_context).returns([nil, nil])
|
14
|
+
@command.expects(:say).with("Project could not be inferred")
|
15
|
+
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:list_dependencies])
|
16
|
+
|
17
|
+
assert_equal(@command.execute, 1)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "show a message if status is not 200" do
|
21
|
+
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
22
|
+
@mock_client.expects(:get).with(EPC::Config::PROJECTS_PATH + "/1/list_dependencies").returns([400, {:message => "Not Found"}, {}])
|
23
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
24
|
+
|
25
|
+
assert_equal(@command.execute, 400)
|
26
|
+
end
|
27
|
+
|
28
|
+
should "show a message if no dependencies are found" do
|
29
|
+
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
30
|
+
@mock_client.expects(:get).with(EPC::Config::PROJECTS_PATH + "/1/list_dependencies").returns([200, [], {}])
|
31
|
+
|
32
|
+
@command.expects(:say).with("Project [FirstProject] has no dependencies")
|
33
|
+
|
34
|
+
assert_equal(@command.execute, 200)
|
35
|
+
end
|
36
|
+
|
37
|
+
should "request and show dependencies" do
|
38
|
+
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
39
|
+
@mock_client.expects(:get).with(EPC::Config::PROJECTS_PATH + "/1/list_dependencies").
|
40
|
+
returns([200, [{:id => 1, :parent_id => 1, :dependency_id => 2, :dependency_kind => 1}]])
|
41
|
+
@command.expects(:say)
|
42
|
+
assert_equal(@command.execute, 200)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListDeploymentsCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "list deployments" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ListDeploymentsCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
should "show exception message status is not 201" do
|
14
|
+
@command.options[:solution_name] = 1
|
15
|
+
@mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH + "/1/deployments").
|
16
|
+
returns([400, {:message => "Not Found"}, {}])
|
17
|
+
@command.expects(:say).with("Deployments retrieval failed with [Not Found]")
|
18
|
+
|
19
|
+
assert_equal(@command.execute, 400)
|
20
|
+
end
|
21
|
+
|
22
|
+
should "show a message if there are no deployments" do
|
23
|
+
@command.options[:solution_name] = 1
|
24
|
+
@mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH + "/1/deployments").
|
25
|
+
returns([200, {}, {}])
|
26
|
+
|
27
|
+
@command.expects(:say).returns("You have no deployments created.You can create them with epc create deployment.")
|
28
|
+
|
29
|
+
assert_equal(@command.execute, 200)
|
30
|
+
end
|
31
|
+
|
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)
|
35
|
+
@mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH + "/1/deployments").
|
36
|
+
returns([200,
|
37
|
+
[
|
38
|
+
{:id => 1, :deployer_name => "deployer_name", :solution_name => "FirstSolution", :deployment_stage_name => "development", :status => "RUNNING"}
|
39
|
+
], {}])
|
40
|
+
@command.expects(:say).at_least_once
|
41
|
+
assert_equal(@command.execute, 200)
|
42
|
+
end
|
43
|
+
|
44
|
+
should "list available deployments for solutions specified with id" do
|
45
|
+
@command.options[:solution_name] = 1
|
46
|
+
@mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH + "/1/deployments").
|
47
|
+
returns([200,
|
48
|
+
[
|
49
|
+
{:id => 1, :deployer_name => "deployer_name", :solution_name => "FirstSolution", :deployment_stage_name => "development", :status => "RUNNING"}
|
50
|
+
], {}])
|
51
|
+
@command.expects(:say).at_least_once
|
52
|
+
assert_equal(@command.execute, 200)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
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)
|
59
|
+
@mock_client.expects(:get).with(EPC::Config::DEPLOYMENT_STAGES_PATH + "/1/deployments").
|
60
|
+
returns([200,
|
61
|
+
[
|
62
|
+
{:id => 1, :deployer_name => "deployer_name", :solution_name => "FirstSolution", :deployment_stage_name => "development", :status => "RUNNING"}
|
63
|
+
], {}])
|
64
|
+
@command.expects(:say).at_least_once
|
65
|
+
assert_equal(@command.execute, 200)
|
66
|
+
end
|
67
|
+
|
68
|
+
should "list available deployments for stages specified with id" do
|
69
|
+
@command.options[:stage_name] = 1
|
70
|
+
@mock_client.expects(:get).with(EPC::Config::DEPLOYMENT_STAGES_PATH + "/1/deployments").
|
71
|
+
returns([200,
|
72
|
+
[
|
73
|
+
{:id => 1, :deployer_name => "deployer_name", :solution_name => "FirstSolution", :deployment_stage_name => "development", :status => "RUNNING"}
|
74
|
+
], {}])
|
75
|
+
@command.expects(:say).at_least_once
|
76
|
+
assert_equal(@command.execute, 200)
|
77
|
+
end
|
78
|
+
|
79
|
+
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)
|
82
|
+
@mock_client.expects(:get).with(EPC::Config::USERS_PATH + "/1/deployments").
|
83
|
+
returns([200,
|
84
|
+
[
|
85
|
+
{:id => 1, :deployer_name => "deployer_name", :solution_name => "FirstSolution", :deployment_stage_name => "development", :status => "RUNNING"}
|
86
|
+
], {}])
|
87
|
+
@command.expects(:say).at_least_once
|
88
|
+
assert_equal(@command.execute, 200)
|
89
|
+
end
|
90
|
+
|
91
|
+
should "list available deployments for users specified with id" do
|
92
|
+
@command.options[:user_name] = 1
|
93
|
+
@mock_client.expects(:get).with(EPC::Config::USERS_PATH + "/1/deployments").
|
94
|
+
returns([200,
|
95
|
+
[
|
96
|
+
{:id => 1, :deployer_name => "deployer_name", :solution_name => "FirstSolution", :deployment_stage_name => "development", :status => "RUNNING"}
|
97
|
+
], {}])
|
98
|
+
@command.expects(:say).at_least_once
|
99
|
+
assert_equal(@command.execute, 200)
|
100
|
+
end
|
101
|
+
|
102
|
+
should "try to determine solution context if no other option specified" do
|
103
|
+
EPC::Config.expects(:is_solution_dir?).returns(true)
|
104
|
+
@command.expects(:infer_solution_context).returns([1, "FirstSolution"])
|
105
|
+
@mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH + "/1/deployments").
|
106
|
+
returns([200, {}, {}])
|
107
|
+
@command.expects(:say).at_least_once
|
108
|
+
assert_equal(@command.execute, 200)
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListStagesCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "list solutions" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
|
10
|
+
@command = EPC::Command::ListStagesCommand.new(@mock_client)
|
11
|
+
end
|
12
|
+
|
13
|
+
should "show exception message status is not 201" do
|
14
|
+
@mock_client.expects(:get).with(EPC::Config::DEPLOYMENT_STAGES_PATH).
|
15
|
+
returns([400, {:message => "Not Found"}, {}])
|
16
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
17
|
+
|
18
|
+
assert_equal(@command.execute, 400)
|
19
|
+
end
|
20
|
+
|
21
|
+
should "show a message if there are no deployment stages" do
|
22
|
+
|
23
|
+
@mock_client.expects(:get).with(EPC::Config::DEPLOYMENT_STAGES_PATH).
|
24
|
+
returns([200, {}, {}])
|
25
|
+
|
26
|
+
@command.expects(:say).returns("No deployment stages available yet.")
|
27
|
+
|
28
|
+
assert_equal(@command.execute, 200)
|
29
|
+
end
|
30
|
+
|
31
|
+
should "list available deployment stages" do
|
32
|
+
@mock_client.expects(:get).with(EPC::Config::DEPLOYMENT_STAGES_PATH).
|
33
|
+
returns([200,
|
34
|
+
[
|
35
|
+
{:id => 1, :name => "dev", :runtime_envs => [{:id => 1, :name => "dev", :default_uri_base => "epaas.com"}]},
|
36
|
+
{:id => 2, :name => "prod", :runtime_envs => [{:id => 1, :name => "dev", :default_uri_base => "epaas.com"}]}],
|
37
|
+
{}])
|
38
|
+
|
39
|
+
@command.expects(:say).at_least_once
|
40
|
+
assert_equal(@command.execute, 200)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListLibrariesCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "list libraries" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ListLibrariesCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "show exception message status is not 201" do
|
13
|
+
@mock_client.expects(:get).with(EPC::Config::LIBRARIES_PATH).
|
14
|
+
returns([404, {:message => "Not Found"}, {}])
|
15
|
+
@command.expects(:say).with("Libraries retrieval failed with [Not Found]")
|
16
|
+
|
17
|
+
assert_equal(@command.execute, 404)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "show a message if there are no libraries" do
|
21
|
+
@mock_client.expects(:get).with(EPC::Config::LIBRARIES_PATH).
|
22
|
+
returns([200, {}, {}])
|
23
|
+
|
24
|
+
@command.expects(:say).returns("You have no libraries created.You can create them with epc create library.")
|
25
|
+
|
26
|
+
assert_equal(@command.execute, 200)
|
27
|
+
end
|
28
|
+
|
29
|
+
should "list available libraries" do
|
30
|
+
@mock_client.expects(:get).with(EPC::Config::LIBRARIES_PATH).
|
31
|
+
returns([200,
|
32
|
+
[
|
33
|
+
{:id => 1, :name => "math", :language => "c", :library_version => "0.2"},
|
34
|
+
{:id => 2, :name => "trig", :language => "c", :library_version => "2"}
|
35
|
+
], {}])
|
36
|
+
|
37
|
+
@command.expects(:say).at_least_once
|
38
|
+
assert_equal(@command.execute, 200)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|