Project

General

Profile

Revision 8e5eda06

Added by Thomas McKay almost 9 years ago

clean-test - updates

View differences:

lib/hammer_cli_csv/puppet_environments.rb
74 74
                                           'environment' => {
75 75
                                             'name' => name
76 76
                                           }
77
                                         })[0]['environment']['id']
77
                                         })[0]['id']
78 78
        else
79 79
          print "Updating environment '#{name}'..." if option_verbose?
80 80
          id = @f_environment_api.update({
lib/hammer_cli_csv/systems.rb
70 70
        @k_organization_api.index({:per_page => 999999})[0]['results'].each do |organization|
71 71
          @k_system_api.index({
72 72
                                'per_page' => 999999,
73
                                'organization_id' => organization['label']
73
                                'organization_id' => katello_organization(:name => organization['name'])
74 74
                               })[0]['results'].each do |system|
75 75
            system = @k_system_api.show({
76 76
                                          'id' => system['uuid'],
......
79 79

  
80 80
            name = system['name']
81 81
            count = 1
82
            organization_label = organization['label']
82
            organization_name = organization['name']
83 83
            environment = system['environment']['label']
84 84
            contentview = system['content_view']['name']
85 85
            systemgroups = CSV.generate do |column|
......
108 108
                "#{subscription['product_id']}|#{subscription['product_name']}"
109 109
              end
110 110
            end.delete!("\n")
111
            csv << [name, count, organization_label, environment, contentview, systemgroups, virtual, host,
111
            csv << [name, count, organization_name, environment, contentview, systemgroups, virtual, host,
112 112
                    operatingsystem, architecture, sockets, ram, cores, sla, products, subscriptions]
113 113
          end
114 114
        end
......
136 136
    def create_systems_from_csv(line)
137 137
      if !@existing[line[ORGANIZATION]]
138 138
        @existing[line[ORGANIZATION]] = {}
139
        @k_system_api.index({'organization_id' => line[ORGANIZATION], 'page_size' => 999999})[0]['results'].each do |system|
139
        @k_system_api.index({
140
                              'organization_id' => katello_organization(:name => line[ORGANIZATION]),
141
                              'page_size' => 999999})[0]['results'].each do |system|
140 142
          @existing[line[ORGANIZATION]][system['name']] = system['uuid'] if system
141 143
        end
142 144
      end
......
153 155
          print "Creating system '#{name}'..." if option_verbose?
154 156
          system_id = @k_system_api.create({
155 157
                                 'name' => name,
156
                                 'organization_id' => line[ORGANIZATION],
158
                                 'organization_id' => katello_organization(:name => line[ORGANIZATION]),
157 159
                                 'environment_id' => katello_environment(line[ORGANIZATION], :name => line[ENVIRONMENT]),
158 160
                                 'content_view_id' => katello_contentview(line[ORGANIZATION], :name => line[CONTENTVIEW]),
159 161
                                 'facts' => facts(line),
test/data/systems.csv
1 1
Name,Count,Organization,Environment,Content View,System Groups,Virtual,Host,OS,Arch,Sockets,RAM,Cores,SLA,Products,Subscriptions
2
host%d,1,megacorp,Library,Default Organization View,"Mega Corp HQ",No,,RHEL 6.4,x86_64,1,4,1,Standard,"69|Red Hat Enterprise Linux Server,79|Red Hat Enterprise Linux Server",RH0103708|Red Hat Enterprise Linux Server Premium (8 sockets) (Up to 4 guests)
3
guest%d,1,megacorp,Library,Default Organization View,"Mega Corp HQ,Accounting",Yes,host0,RHEL 6.4,x86_64,1,4,1,Standard,"69|Red Hat Enterprise Linux Server,79|Red Hat Enterprise Linux Server",RH0103708|Red Hat Enterprise Linux Server Premium (8 sockets) (Up to 4 guests)
2
host%d,1,Mega Corporation,Library,Default Organization View,"Mega Corp HQ",No,,RHEL 6.4,x86_64,1,4,1,Standard,"69|Red Hat Enterprise Linux Server,79|Red Hat Enterprise Linux Server",RH0103708|Red Hat Enterprise Linux Server Premium (8 sockets) (Up to 4 guests)
3
guest%d,1,Mega Corporation,Library,Default Organization View,"Mega Corp HQ,Accounting",Yes,host0,RHEL 6.4,x86_64,1,4,1,Standard,"69|Red Hat Enterprise Linux Server,79|Red Hat Enterprise Linux Server",RH0103708|Red Hat Enterprise Linux Server Premium (8 sockets) (Up to 4 guests)
4 4

  
test/setup_test.rb
105 105
        hammer.run(%W{-v subscription upload --organization-id megacorp --file test/data/megacorp.zip})
106 106
      }
107 107
      stderr.must_equal ''
108
      stdout.must_equal '.*Manifest is being uploaded.*'
108
      stdout.must_match '.*Manifest is being uploaded.*'
109 109
    end
110 110
  end
111 111

  
......
115 115
        hammer.run(%W{-v csv:products --csv-file test/data/products.csv})
116 116
      }
117 117
      stderr.must_equal ''
118
      stdout.must_match /.*xxx.*/
118
      stdout.must_match /.*product 'Point of Sale'.*/
119 119
    end
120 120
  end
121 121

  
......
145 145
        hammer.run(%W{-v csv:systems --csv-file test/data/systems.csv})
146 146
      }
147 147
      stderr.must_equal ''
148
      stdout.must_match /.*xxx.*/
148
      stdout.must_match /.*system 'host0'.*/
149 149
    end
150 150
  end
151 151

  
......
155 155
        hammer.run(%W{-v csv:activationkeys --csv-file test/data/activationkeys.csv})
156 156
      }
157 157
      stderr.must_equal ''
158
      stdout.must_match /.*xxx.*/
158
      stdout.must_match /.*activation key 'damon\.dials@megacorp\.com'.*/
159 159
    end
160 160
  end
161 161

  

Also available in: Unified diff