epc 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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,70 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CreateSolutionCommandTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
should_require_login
|
6
|
+
|
7
|
+
context "execute" do
|
8
|
+
setup do
|
9
|
+
@mock_client = mock("Client")
|
10
|
+
@mock_config = mock("Config")
|
11
|
+
|
12
|
+
EPC::Config.target_file = '~/.epc_test_target'
|
13
|
+
end
|
14
|
+
|
15
|
+
should "create the solution directory if the status is 201" do
|
16
|
+
command = EPC::Command::CreateSolutionCommand.new(@mock_client)
|
17
|
+
|
18
|
+
@mock_client.expects(:post).with("/api/v1/solutions", { :name => "FirstSolution" }).returns([201, { :id => 1 }, {}])
|
19
|
+
EPC::Config.expects(:add_solution).with("FirstSolution", 1)
|
20
|
+
|
21
|
+
command.expects(:mkdir).with("FirstSolution").returns(:ok)
|
22
|
+
command.expects(:say).with("Successfully created the solution with [http://localhost:3000] and created your local directory.")
|
23
|
+
|
24
|
+
assert_equal(command.execute("", "FirstSolution"), 201)
|
25
|
+
end
|
26
|
+
|
27
|
+
should "not create the solution directory if --nodir options specified" do
|
28
|
+
command = EPC::Command::CreateSolutionCommand.new(@mock_client, {:nodir => true})
|
29
|
+
|
30
|
+
@mock_client.expects(:post).with("/api/v1/solutions", { :name => "FirstSolution" }).returns([201, { :id => 1 }, {}])
|
31
|
+
|
32
|
+
command.expects(:mkdir).never
|
33
|
+
command.expects(:say).with("Successfully created the solution with [http://localhost:3000].")
|
34
|
+
|
35
|
+
assert_equal(command.execute("", "FirstSolution"), 201)
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
should "report failure if the status is 201 and the solution directory cannot be created" do
|
40
|
+
command = EPC::Command::CreateSolutionCommand.new(@mock_client)
|
41
|
+
|
42
|
+
@mock_client.expects(:post).with("/api/v1/solutions", { :name => "Test Solution" }).returns([201, { :name => "Test Solution" }, {}])
|
43
|
+
FileUtils.expects(:mkdir).with("Test Solution", {}).raises(SystemCallError.new("File exists - Test Solution"))
|
44
|
+
|
45
|
+
|
46
|
+
command.expects(:say).with("Failed to create local directory [Test Solution] - [unknown error - File exists - Test Solution]")
|
47
|
+
command.expects(:say).with("Successfully created the solution with [http://localhost:3000], but FAILED to create your local directory.")
|
48
|
+
|
49
|
+
assert_equal(command.execute("", "Test Solution"), 1)
|
50
|
+
end
|
51
|
+
|
52
|
+
should "report failure if the status is not 201" do
|
53
|
+
command = EPC::Command::CreateSolutionCommand.new(@mock_client)
|
54
|
+
|
55
|
+
@mock_client.expects(:post).with("/api/v1/solutions", { :name => "Test Solution" }).returns([400, { :message => "Bad Request" }, {}])
|
56
|
+
command.expects(:say).with("Solution creation failed [Bad Request].")
|
57
|
+
|
58
|
+
assert_equal(command.execute("", "Test Solution"), 400)
|
59
|
+
end
|
60
|
+
|
61
|
+
should "report error is the call throws an exception" do
|
62
|
+
command = EPC::Command::CreateSolutionCommand.new(@mock_client)
|
63
|
+
|
64
|
+
@mock_client.expects(:post).with("/api/v1/solutions", { :name => "Test Solution" }).raises(StandardError.new("failed"))
|
65
|
+
command.expects(:say).with("Solution creation failed [failed].")
|
66
|
+
|
67
|
+
assert_equal(command.execute("", "Test Solution"), 1)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CreateUserCommandTest < Test::Unit::TestCase
|
4
|
+
context "execute" do
|
5
|
+
setup do
|
6
|
+
@mock_client = mock("Client")
|
7
|
+
@mock_config = mock("Config")
|
8
|
+
|
9
|
+
EPC::Config.target_file = '~/.epc_test_target'
|
10
|
+
end
|
11
|
+
|
12
|
+
should "prompt for password" do
|
13
|
+
command = EPC::Command::CreateUserCommand.new(@mock_client)
|
14
|
+
command.expects(:ask).with("Password: ").returns("testpass")
|
15
|
+
|
16
|
+
@mock_client.expects(:post).with("/api/v1/users", { :email => 'me@there.com', :password => 'testpass' }).returns(201, {}, {})
|
17
|
+
|
18
|
+
assert_equal(command.execute("", "me@there.com"), 201)
|
19
|
+
end
|
20
|
+
|
21
|
+
should "report failure if email was not provided" do
|
22
|
+
command = EPC::Command::CreateUserCommand.new(@mock_client, :password => 'testpass')
|
23
|
+
command.expects(:ask).with("Password: ").never
|
24
|
+
@mock_client.expects(:post).never
|
25
|
+
assert_raise EPC::Error::FatalError do
|
26
|
+
assert_equal(command.execute(""), 1)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
should "report success if status is 201" do
|
31
|
+
command = EPC::Command::CreateUserCommand.new(@mock_client, :password => 'testpass', :name => "me")
|
32
|
+
command.expects(:ask).with("Password: ").never
|
33
|
+
|
34
|
+
@mock_client.expects(:post).with("/api/v1/users", { :email => 'me@there.com', :password => 'testpass', :name => "me" }).
|
35
|
+
returns([201, { :id => 1, :caller_id => '123' }, {}])
|
36
|
+
command.expects(:say).with("Successfully created the user with [http://localhost:3000]")
|
37
|
+
|
38
|
+
assert_equal(command.execute("", "me@there.com"), 201)
|
39
|
+
end
|
40
|
+
|
41
|
+
should "report error if status is not 201" do
|
42
|
+
command = EPC::Command::CreateUserCommand.new(@mock_client, :password => 'testpass')
|
43
|
+
command.expects(:ask).with("Password: ").never
|
44
|
+
|
45
|
+
@mock_client.expects(:post).with("/api/v1/users", { :email => 'me@there.com', :password => 'testpass' }).
|
46
|
+
returns([400, { :message => "Bad Request" }, {}])
|
47
|
+
command.expects(:say).with("User creation failed [Bad Request].")
|
48
|
+
|
49
|
+
assert_equal(command.execute("", "me@there.com"), 400)
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.expand_path "../../../lib/epc", __FILE__
|
2
|
+
require "test/unit"
|
3
|
+
require 'shoulda'
|
4
|
+
require 'mocha'
|
5
|
+
|
6
|
+
class DefineServiceCommandTest < 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 the user to specify the service_name" do
|
15
|
+
@command = EPC::Command::DefineServiceCommand.new(@mock_client)
|
16
|
+
@command.expects(:say).with("You must specify a name for the service")
|
17
|
+
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:define_service])
|
18
|
+
@command.execute
|
19
|
+
end
|
20
|
+
|
21
|
+
should "require the user to specify a service_type identifier" do
|
22
|
+
@command = EPC::Command::DefineServiceCommand.new(@mock_client, {:service_type => nil})
|
23
|
+
@command.expects(:say).with("You must specify a service type with -t option.")
|
24
|
+
@command.execute("service")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "service definition" do
|
29
|
+
setup do
|
30
|
+
@mock_client = stub('Client')
|
31
|
+
@command = EPC::Command::DefineServiceCommand.new(@mock_client, {:service_type => "MySQL"})
|
32
|
+
end
|
33
|
+
|
34
|
+
should "query core for service_type_id if service type name was specified" do
|
35
|
+
@command.expects(:get_resource_id).returns(0)
|
36
|
+
@command.expects(:say).with("MySQL service type could not be found.")
|
37
|
+
@command.execute("service")
|
38
|
+
end
|
39
|
+
|
40
|
+
should "fail if status is not 201" do
|
41
|
+
@command.expects(:get_resource_id).returns(1)
|
42
|
+
@mock_client.expects(:post).with(EPC::Config::SERVICE_DEFINITIONS_PATH, {:name => "service", :type_id => 1}).returns([400, {'message' => 'Not Found'}])
|
43
|
+
@command.expects(:say).with("Service definition failed with: [Not Found]")
|
44
|
+
@command.execute("service")
|
45
|
+
end
|
46
|
+
|
47
|
+
should "define a service" do
|
48
|
+
@command.expects(:get_resource_id).returns(1)
|
49
|
+
@mock_client.expects(:post).with(EPC::Config::SERVICE_DEFINITIONS_PATH, {:name => "service", :type_id => 1}).returns([201, {'id' => 1}])
|
50
|
+
@command.expects(:say).with("service has been defined.")
|
51
|
+
@command.execute("service")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DeleteConfigCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
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
|
+
|
18
|
+
context "valid commands" do
|
19
|
+
setup do
|
20
|
+
@mock_client = mock("Client")
|
21
|
+
@command = EPC::Command::DeleteConfigCommand.new(@mock_client)
|
22
|
+
end
|
23
|
+
|
24
|
+
should "query the server for key id" do
|
25
|
+
@command.expects(:extract_configuration_level).returns(["Project", 1])
|
26
|
+
@mock_client.expects(:get).with(EPC::Config::CONFIGURATIONS_PATH + "/Project/1").
|
27
|
+
returns([200, {:name => "key1", :id => 1}, {}])
|
28
|
+
@command.expects(:say).with("key1 is not defined.")
|
29
|
+
@command.execute("key1")
|
30
|
+
end
|
31
|
+
|
32
|
+
should "fail if querying the server fails" do
|
33
|
+
assert_raise EPC::Error::FatalError do
|
34
|
+
@command.options[:stage_name] = "Development"
|
35
|
+
@command.expects(:extract_configuration_level).returns(["Project", 1])
|
36
|
+
@mock_client.expects(:get).with(EPC::Config::CONFIGURATIONS_PATH + "/Project/1/Development").
|
37
|
+
returns([404, {:message => "Not Found"}, {}])
|
38
|
+
@command.execute("key1")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
should "notify if there are no keys defined" do
|
43
|
+
@command.expects(:extract_configuration_level).returns(["Project", 1])
|
44
|
+
@mock_client.expects(:get).with(EPC::Config::CONFIGURATIONS_PATH + "/Project/1").
|
45
|
+
returns([200, {}, {}])
|
46
|
+
@command.expects(:say).with("There are no configurations defined for this project.")
|
47
|
+
@command.execute("key1")
|
48
|
+
end
|
49
|
+
|
50
|
+
should "notify user if key does not exist" do
|
51
|
+
@command.expects(:extract_configuration_level).returns(["Project", 1])
|
52
|
+
@mock_client.expects(:get).with(EPC::Config::CONFIGURATIONS_PATH + "/Project/1").
|
53
|
+
returns([200, {:name => "key1", :id => 1}, {}])
|
54
|
+
@command.expects(:say).with("key2 is not defined.")
|
55
|
+
@command.execute("key2")
|
56
|
+
end
|
57
|
+
|
58
|
+
should "delete specified key" do
|
59
|
+
@command.expects(:extract_configuration_level).returns(["Project", 1])
|
60
|
+
@mock_client.expects(:get).with(EPC::Config::CONFIGURATIONS_PATH + "/Project/1").
|
61
|
+
returns([200, [{:name => "key1", :id => 1}], {}])
|
62
|
+
@command.expects(:ask_yn).returns("Y")
|
63
|
+
@mock_client.expects(:delete).with(EPC::Config::CONFIGURATIONS_PATH + "/1").
|
64
|
+
returns([200, {}, {}])
|
65
|
+
@command.expects(:say).with("key1 succesfully removed.")
|
66
|
+
@command.execute("key1")
|
67
|
+
end
|
68
|
+
|
69
|
+
should "notify when removal fails" do
|
70
|
+
@command.expects(:extract_configuration_level).returns(["Project", 1])
|
71
|
+
@mock_client.expects(:get).with(EPC::Config::CONFIGURATIONS_PATH + "/Project/1").
|
72
|
+
returns([200, [{:name => "key1", :id => 1}], {}])
|
73
|
+
@command.expects(:ask_yn).returns("Y")
|
74
|
+
@mock_client.expects(:delete).with(EPC::Config::CONFIGURATIONS_PATH + "/1").
|
75
|
+
returns([500, {:message => "System Exception"}, {}])
|
76
|
+
@command.expects(:say).with("Request failed: [System Exception]")
|
77
|
+
@command.execute("key1")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DeleteDependencyCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::DeleteDependencyCommand.new(@mock_client)
|
10
|
+
end
|
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
|
+
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)
|
24
|
+
end
|
25
|
+
|
26
|
+
context "deletion" do
|
27
|
+
setup do
|
28
|
+
@command.options[:project_name] = 1
|
29
|
+
@command.options[:solution_name] = 1
|
30
|
+
@command.expects(:infer_solution_context).returns([1, "FirstSolution"])
|
31
|
+
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
32
|
+
@command.expects(:ask_yn).returns("Y")
|
33
|
+
end
|
34
|
+
|
35
|
+
should "fail if status is not 200" do
|
36
|
+
@mock_client.expects(:delete).with(EPC::Config::PROJECTS_PATH + "/1/remove_dependency/1").
|
37
|
+
returns([404, {:message => "Not Found"}, {}])
|
38
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
39
|
+
assert_equal(@command.execute("1"), 404)
|
40
|
+
end
|
41
|
+
|
42
|
+
should "delete a dependency" do
|
43
|
+
@mock_client.expects(:delete).with(EPC::Config::PROJECTS_PATH + "/1/remove_dependency/1")
|
44
|
+
.returns([200, {}, {}])
|
45
|
+
@command.expects(:say).with("Dependency deleted")
|
46
|
+
assert_equal(@command.execute("1"), 200)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DeleteGroupCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::DeleteGroupCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if no names are specified" do
|
13
|
+
@command.expects(:say).with("You need to specify a group id/name")
|
14
|
+
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:delete_group])
|
15
|
+
assert_equal(@command.execute, 1)
|
16
|
+
end
|
17
|
+
|
18
|
+
should "fail if group id can't be determined" do
|
19
|
+
@command.expects(:ask_yn).returns("Y")
|
20
|
+
@command.expects(:get_resource_id).with(EPC::Config::GROUPS_PATH, :name, "admins").returns(nil)
|
21
|
+
@command.expects(:say).with("Group could not be determined")
|
22
|
+
|
23
|
+
assert_equal(@command.execute("admins"), 1)
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
should "fail if status is not 200" do
|
28
|
+
@command.expects(:ask_yn).returns("Y")
|
29
|
+
@mock_client.expects(:delete).with(EPC::Config::GROUPS_PATH + "/1").
|
30
|
+
returns([404, {:message => "Not Found"}, {}])
|
31
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
32
|
+
assert_equal(@command.execute(1), 404)
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
should "delete a group specified by id" do
|
37
|
+
@command.expects(:ask_yn).returns("Y")
|
38
|
+
@mock_client.expects(:delete).with(EPC::Config::GROUPS_PATH + "/1").
|
39
|
+
returns([200, {}, {}])
|
40
|
+
@command.expects(:say).with("Group deleted")
|
41
|
+
|
42
|
+
assert_equal(@command.execute(1), 200)
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
should "delete a group specified by name" do
|
47
|
+
@command.expects(:ask_yn).returns("Y")
|
48
|
+
@command.expects(:get_resource_id).with(EPC::Config::GROUPS_PATH, :name, "admins").returns(1)
|
49
|
+
@mock_client.expects(:delete).with(EPC::Config::GROUPS_PATH + "/1").
|
50
|
+
returns([200, {}, {}])
|
51
|
+
@command.expects(:say).with("Group deleted")
|
52
|
+
|
53
|
+
assert_equal(@command.execute("admins"), 200)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DeleteLibraryCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::DeleteLibraryCommand.new(@mock_client)
|
10
|
+
end
|
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
|
+
should "fail if status is not 200" do
|
28
|
+
@command.expects(:ask_yn).returns("Y")
|
29
|
+
@mock_client.expects(:delete).with(EPC::Config::LIBRARIES_PATH + "/1").returns([404, {:message => "Not Found"}, {}])
|
30
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
31
|
+
|
32
|
+
assert_equal(@command.execute("1"), 404)
|
33
|
+
end
|
34
|
+
|
35
|
+
should "delete a library" do
|
36
|
+
@command.expects(:ask_yn).returns("Y")
|
37
|
+
@mock_client.expects(:delete).with(EPC::Config::LIBRARIES_PATH + "/1").returns([200, {}, {}])
|
38
|
+
@command.expects(:say).with("Library deleted")
|
39
|
+
|
40
|
+
assert_equal(@command.execute("1"), 200)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DeleteLibrarylanguageCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::DeleteLibrarylanguageCommand.new(@mock_client)
|
10
|
+
end
|
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
|
+
should "fail if status is not 200" do
|
27
|
+
@command.expects(:ask_yn).returns("Y")
|
28
|
+
@mock_client.expects(:delete).with(EPC::Config::LIBRARY_LANGUAGES_PATH + "/1").
|
29
|
+
returns([404, {:message => "Not Found"}, {}])
|
30
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
31
|
+
assert_equal(@command.execute(1), 404)
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
should "delete a language specified by id" do
|
36
|
+
@command.expects(:ask_yn).returns("Y")
|
37
|
+
@mock_client.expects(:delete).with(EPC::Config::LIBRARY_LANGUAGES_PATH + "/1").
|
38
|
+
returns([200, {}, {}])
|
39
|
+
@command.expects(:say).with("Language deleted")
|
40
|
+
|
41
|
+
assert_equal(@command.execute(1), 200)
|
42
|
+
end
|
43
|
+
|
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
|
+
end
|
55
|
+
end
|