Project

General

Profile

Revision a872bfc1

Added by Thomas McKay over 5 years ago

fixes #16661 - i18n and --help test

View differences:

lib/hammer_cli_csv/compute_resources.rb
51 51
            }
52 52
          }
53 53
          if !@existing.include? name
54
            print "Creating compute resource '#{name}'..." if option_verbose?
54
            print _("Creating compute resource '%{name}'...") % {:name => name} if option_verbose?
55 55
            id = @api.resource(:compute_resources).call(:create, params)['id']
56 56
          else
57
            print "Updating compute resource '#{name}'..." if option_verbose?
57
            print _("Updating compute resource '%{name}'...") % {:name => name} if option_verbose?
58 58
            id = @existing[name]
59 59
            params['id'] = id
60 60
            @api.resource(:compute_resources).call(:update, params)
61 61
          end
62 62

  
63
          # Update associated resources
64
          # TODO: this doesn't work "Environments you cannot remove environments that are used by hosts or inherited."
65
          #associate_organizations(id, line[ORGANIZATIONS], 'compute_resource')
66
          #associate_locations(id, line[LOCATIONS], 'compute_resource')
63
          associate_organizations(id, line[ORGANIZATIONS], 'compute_resource')
64
          associate_locations(id, line[LOCATIONS], 'compute_resource')
67 65

  
68
          print "done\n" if option_verbose?
66
          puts _("done") if option_verbose?
69 67
        end
70 68
      end
71 69
    end
test/resources/compute_resources_test.rb
1
require './test/csv_test_helper'
2
require './lib/hammer_cli_csv'
3

  
4
module Resources
5
  class TestComputeResources < MiniTest::Unit::TestCase
6
    def test_usage
7
      start_vcr
8
      set_user 'admin'
9

  
10
      stdout,stderr = capture {
11
        hammer.run(%W{--reload-cache csv compute-resources --help})
12
      }
13
      assert_equal '', stderr
14
      assert_equal stdout, <<-HELP
15
**** This command is unsupported and is provided as tech preview. ****
16
Usage:
17
     csv compute-resources [OPTIONS]
18

  
19
Options:
20
 --continue-on-error           Continue processing even if individual resource error
21
 --export                      Export current data instead of importing
22
 --file FILE_NAME              CSV file (default to /dev/stdout with --export, otherwise required)
23
 --organization ORGANIZATION   Only process organization matching this name
24
 -h, --help                    print help
25
 -v, --verbose                 be verbose
26
HELP
27
      stop_vcr
28
    end
29
  end
30
end

Also available in: Unified diff