Project

General

Profile

Revision d76bdbc0

Added by Andrew Kofink over 6 years ago

Fixes #17051 - PUT quantity to attach for AK subs (#134)

PUT the quantity to attach to the activation key rather than the
total quantity attached

`activation-keys --itemized-subscriptions --file ak_subs.csv`

View differences:

test/resources/activation_keys_test.rb
66 66

  
67 67
      stop_vcr
68 68
    end
69

  
70
    def test_itemized_create_and_update
71
      stdout,stderr = capture {
72
        hammer.run(%W{--reload-cache csv activation-keys --verbose --file test/data/setup/activation-keys.csv})
73
      }
74

  
75
      start_vcr
76
      set_user 'admin'
77

  
78
      name = "ak1"
79
      sub_name = "Red Hat Enterprise Linux Server, Premium (8 sockets) (Unlimited guests)"
80
      quantity = 1
81

  
82
      file = Tempfile.new('activation_keys_test')
83
      file.write("Name,Organization,Description,Limit,Environment,Content View,Host\
84
                  Collections,Auto-Attach,Service Level,Release Version,Subscription\
85
                  Name,Subscription Type,Subscription Quantity,Subscription SKU,Subscription\
86
                  Contract,Subscription Account,Subscription Start,Subscription End\n")
87
      file.write("#{name},Default Organization,,,,Default Organization View,\"\",Yes,,,\"#{sub_name}\",Red\
88
                  Hat,#{quantity},RH0105260,10855292,5535485,2016-01-05T05:00:00+00:00,2017-01-05T04:59:59+00:00")
89

  
90
      file.rewind
91

  
92
      # Attaching an integer quantity of a subscription
93
      stdout,stderr = capture {
94
        hammer.run(%W{--reload-cache csv activation-keys --verbose --itemized-subscriptions --file #{file.path}})
95
      }
96
      assert_equal '', stderr
97
      assert_equal stdout[0..-2], "Updating subscriptions for activation key '#{name}'... attaching #{quantity} of '#{sub_name}'...done"
98

  
99
      file.rewind
100

  
101
      # Attaching already-attached subscription
102
      stdout,stderr = capture {
103
        hammer.run(%W{--reload-cache csv activation-keys --verbose --itemized-subscriptions --file #{file.path}})
104
      }
105
      assert_equal '', stderr
106
      assert_equal stdout[0..-2], "Updating subscriptions for activation key '#{name}'... '#{sub_name}' already attached...done"
107

  
108
      # Attaching automatic quantity with Automatic in quantity field
109
      stdout,stderr = capture {
110
        hammer.run(%W{--reload-cache csv activation-keys --verbose --file test/data/setup/activation-keys.csv})
111
      }
112

  
113
      file.rewind
114

  
115
      file.write("Name,Organization,Description,Limit,Environment,Content View,Host\
116
                  Collections,Auto-Attach,Service Level,Release Version,Subscription\
117
                  Name,Subscription Type,Subscription Quantity,Subscription SKU,Subscription\
118
                  Contract,Subscription Account,Subscription Start,Subscription End\n")
119
      file.write("#{name},Default Organization,,,,Default Organization View,\"\",Yes,,,\"#{sub_name}\",Red\
120
                  Hat,Automatic,RH0105260,10855292,5535485,2016-01-05T05:00:00+00:00,2017-01-05T04:59:59+00:00")
121

  
122
      file.rewind
123

  
124
      stdout,stderr = capture {
125
        hammer.run(%W{--reload-cache csv activation-keys --verbose --itemized-subscriptions --file #{file.path}})
126
      }
127
      assert_equal '', stderr
128
      assert_equal stdout[0..-2], "Updating subscriptions for activation key '#{name}'... attaching -1 of '#{sub_name}'...done"
129

  
130
      # Attaching automatic quantity with nothing in quantity field
131
      stdout,stderr = capture {
132
        hammer.run(%W{--reload-cache csv activation-keys --verbose --file test/data/setup/activation-keys.csv})
133
      }
134

  
135
      file.rewind
136

  
137
      file.write("Name,Organization,Description,Limit,Environment,Content View,Host\
138
                  Collections,Auto-Attach,Service Level,Release Version,Subscription\
139
                  Name,Subscription Type,Subscription Quantity,Subscription SKU,Subscription\
140
                  Contract,Subscription Account,Subscription Start,Subscription End\n")
141
      file.write("#{name},Default Organization,,,,Default Organization View,\"\",Yes,,,\"#{sub_name}\",Red\
142
                  Hat,,RH0105260,10855292,5535485,2016-01-05T05:00:00+00:00,2017-01-05T04:59:59+00:00")
143

  
144
      file.rewind
145

  
146
      stdout,stderr = capture {
147
        hammer.run(%W{--reload-cache csv activation-keys --verbose --itemized-subscriptions --file #{file.path}})
148
      }
149
      assert_equal '', stderr
150
      assert_equal stdout[0..-2], "Updating subscriptions for activation key '#{name}'... attaching -1 of '#{sub_name}'...done"
151

  
152
      # Attaching automatic quantity with "" in quantity field
153
      stdout,stderr = capture {
154
        hammer.run(%W{--reload-cache csv activation-keys --verbose --file test/data/setup/activation-keys.csv})
155
      }
156

  
157
      file.rewind
158

  
159
      file.write("Name,Organization,Description,Limit,Environment,Content View,Host\
160
                  Collections,Auto-Attach,Service Level,Release Version,Subscription\
161
                  Name,Subscription Type,Subscription Quantity,Subscription SKU,Subscription\
162
                  Contract,Subscription Account,Subscription Start,Subscription End\n")
163
      file.write("#{name},Default Organization,,,,Default Organization View,\"\",Yes,,,\"#{sub_name}\",Red\
164
                  Hat,\"\",RH0105260,10855292,5535485,2016-01-05T05:00:00+00:00,2017-01-05T04:59:59+00:00")
165

  
166
      file.rewind
167

  
168
      stdout,stderr = capture {
169
        hammer.run(%W{--reload-cache csv activation-keys --verbose --itemized-subscriptions --file #{file.path}})
170
      }
171
      assert_equal '', stderr
172
      assert_equal stdout[0..-2], "Updating subscriptions for activation key '#{name}'... attaching -1 of '#{sub_name}'...done"
173

  
174
      file.unlink
175

  
176
      stop_vcr
177
    end
69 178
  end
70 179
end

Also available in: Unified diff