Project

General

Profile

Download (5.2 KB) Statistics
| Branch: | Tag: | Revision:

hammer-cli-csv / test / setup_test.rb @ 400832c6

1
require File.join(File.dirname(__FILE__), 'csv_test_helper')
2

    
3
describe 'setup' do
4

    
5
  extend CommandTestHelper
6

    
7
  before :each do
8
    HammerCLI::Settings.load_from_file 'test/config.yml'
9
  end
10

    
11
  context 'Setup Organizations' do
12
    it "hammer csv organizations -v --csv-file test/data/organizations.csv" do
13
      stdout,stderr = capture {
14
        hammer.run(%W{csv organizations -v --csv-file test/data/organizations.csv})
15
      }
16
      stderr.must_equal ''
17
      stdout.must_match(/.*organization 'Mega Corporation'.*/)
18
    end
19
  end
20

    
21
  context 'Setup Locations' do
22
    it "hammer csv locations -v --csv-file test/data/locations.csv" do
23
      stdout,stderr = capture {
24
        hammer.run(%W{csv locations -v --csv-file test/data/locations.csv})
25
      }
26
      stderr.must_equal ''
27
      stdout.must_match(/.*Asia Pacific.*/)
28
    end
29
  end
30

    
31
  context 'Setup' do
32
    it "hammer csv operating-systems -v --csv-file test/data/operatingsystems.csv" do
33
      stdout,stderr = capture {
34
        hammer.run(%W{csv operating-systems -v --csv-file test/data/operatingsystems.csv})
35
      }
36
      stderr.must_equal ''
37
      stdout.must_match(/.*operating system 'Fedora 18'.*/)
38
    end
39
  end
40

    
41
  context 'Setup' do
42
    it "hammer csv architectures -v --csv-file test/data/architectures.csv" do
43
      stdout,stderr = capture {
44
        hammer.run(%W{csv architectures -v --csv-file test/data/architectures.csv})
45
      }
46
      stderr.must_equal ''
47
      stdout.must_match(/.*architecture 'x86_64'.*/)
48
    end
49
  end
50

    
51
  context 'Setup' do
52
    it "hammer csv partitiontables -v --csv-file test/data/partitiontables.csv" do
53
      stdout,stderr = capture {
54
        hammer.run(%W{csv partition-tables -v --csv-file test/data/partitiontables.csv})
55
      }
56
      stderr.must_equal ''
57
      stdout.must_match(/.*ptable 'ext4 default'.*/)
58
    end
59
  end
60

    
61
  context 'Setup' do
62
    it "hammer csv domains -v --csv-file test/data/domains.csv" do
63
      stdout,stderr = capture {
64
        hammer.run(%W{csv domains -v --csv-file test/data/domains.csv})
65
      }
66
      stderr.must_equal ''
67
      stdout.must_match(/.*domain 'megacorp.com'.*/)
68
    end
69
  end
70

    
71
  context 'Setup' do
72
    it "hammer csv puppet-environments -v --csv-file test/data/puppetenvironments.csv" do
73
      stdout,stderr = capture {
74
        hammer.run(%W{csv puppet-environments -v --csv-file test/data/puppetenvironments.csv})
75
      }
76
      stderr.must_equal ''
77
      stdout.must_match(/.*environment 'Development'.*/)
78
    end
79
  end
80

    
81
  context 'Setup' do
82
    it "hammer csv hosts -v --csv-file test/data/hosts.csv" do
83
      stdout,stderr = capture {
84
        hammer.run(%W{csv hosts -v --csv-file test/data/hosts.csv})
85
      }
86
      stderr.must_equal ''
87
      stdout.split("\n").length.must_equal 255
88
      stdout.must_match(/.*host 'dhcp129-000\.megacorp\.com'.*/)
89
    end
90
  end
91

    
92
  context 'Setup' do
93
    it "hammer csv puppet-facts -v --csv-file test/data/puppetfacts.csv" do
94
      stdout,stderr = capture {
95
        hammer.run(%W{csv puppet-facts -v --csv-file test/data/puppetfacts.csv})
96
      }
97
      stderr.must_equal ''
98
      stdout.must_match(/.*puppetfacts 'dhcp129-000.megacorp.com'.*/)
99
    end
100
  end
101

    
102
  context 'subscription setup' do
103
    it "hammer subscription upload -v --organization-id megacorp --file test/data/megacorp.zip" do
104
      # TODO: http://projects.theforeman.org/issues/4748
105
      "".must_equal "TODO: Bug #4748 - errors on import manifest should complete dynflow task and display information to user"
106
      stdout,stderr = capture {
107
        hammer.run(%W{-v subscription upload --organization-id megacorp --file test/data/megacorp.zip})
108
      }
109
      stderr.must_equal ''
110
      stdout.must_match '.*Manifest is being uploaded.*'
111
    end
112
  end
113

    
114
  context 'Setup' do
115
    it "hammer csv products -v --csv-file test/data/products.csv" do
116
      stdout,stderr = capture {
117
        hammer.run(%W{csv products -v --csv-file test/data/products.csv})
118
      }
119
      stderr.must_equal ''
120
      stdout.must_match(/.*product 'Point of Sale'.*/)
121
    end
122
  end
123

    
124
  context 'Setup' do
125
    it "hammer csv lifecycle-environments -v --csv-file test/data/lifecycleenvironments.csv" do
126
      stdout,stderr = capture {
127
        hammer.run(%W{csv lifecycle-environments -v --csv-file test/data/lifecycleenvironments.csv})
128
      }
129
      stderr.must_equal ''
130
      stdout.must_match(/.*environment 'Development'.*/)
131
    end
132
  end
133

    
134
  context 'Setup' do
135
    it "hammer csv system-groups -v --csv-file test/data/systemgroups.csv" do
136
      stdout,stderr = capture {
137
        hammer.run(%W{csv system-groups -v --csv-file test/data/systemgroups.csv})
138
      }
139
      stderr.must_equal ''
140
      stdout.must_match(/.*system group 'Mega Corp HQ'.*/)
141
    end
142
  end
143

    
144
  context 'Setup' do
145
    it "hammer csv systems -v --csv-file test/data/systems.csv" do
146
      stdout,stderr = capture {
147
        hammer.run(%W{csv systems -v --csv-file test/data/systems.csv})
148
      }
149
      stderr.must_equal ''
150
      stdout.must_match(/.*system 'host0'.*/)
151
    end
152
  end
153

    
154
  context 'Setup' do
155
    it "hammer csv activation-keys -v --csv-file test/data/activationkeys.csv" do
156
      stdout,stderr = capture {
157
        hammer.run(%W{csv activation-keys -v --csv-file test/data/activationkeys.csv})
158
      }
159
      stderr.must_equal ''
160
      stdout.must_match(/.*activation key 'damon\.dials@megacorp\.com'.*/)
161
    end
162
  end
163

    
164
end