hammer_cli_foreman 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of hammer_cli_foreman might be problematic. Click here for more details.

@@ -1,5 +1,5 @@
1
1
  module HammerCLIForeman
2
2
  def self.version
3
- @version ||= Gem::Version.new '0.0.11'
3
+ @version ||= Gem::Version.new '0.0.12'
4
4
  end
5
5
  end
@@ -0,0 +1,79 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+ require 'hammer_cli'
3
+
4
+
5
+ describe HammerCLIForeman do
6
+
7
+ context "collection_to_common_format" do
8
+
9
+ let(:kind) { { "name" => "PXELinux", "id" => 1 } }
10
+
11
+ it "should convert old API format" do
12
+ old_format = [
13
+ {
14
+ "template_kind" => kind
15
+ }
16
+ ]
17
+
18
+ set = HammerCLIForeman.collection_to_common_format(old_format)
19
+ set.must_be_kind_of HammerCLI::Output::RecordCollection
20
+ set.first.must_equal(kind)
21
+ end
22
+
23
+ it "should convert common API format" do
24
+ common_format = [ kind ]
25
+
26
+ set = HammerCLIForeman.collection_to_common_format(common_format)
27
+ set.must_be_kind_of HammerCLI::Output::RecordCollection
28
+ set.first.must_equal(kind)
29
+ end
30
+
31
+ it "should convert new API format" do
32
+ new_format = {
33
+ "total" => 1,
34
+ "subtotal" => 1,
35
+ "page" => 1,
36
+ "per_page" => 20,
37
+ "search" => nil,
38
+ "sort" => {
39
+ "by" => nil,
40
+ "order" => nil
41
+ },
42
+ "results" => [ kind ]
43
+ }
44
+
45
+ set = HammerCLIForeman.collection_to_common_format(new_format)
46
+ set.must_be_kind_of HammerCLI::Output::RecordCollection
47
+ set.first.must_equal(kind)
48
+ end
49
+
50
+ it "should rise error on unexpected format" do
51
+ proc { HammerCLIForeman.collection_to_common_format('unexpected') }.must_raise RuntimeError
52
+ end
53
+
54
+ end
55
+
56
+
57
+ context "record_to_common_format" do
58
+
59
+ let(:arch) { { "name" => "x86_64", "id" => 1 } }
60
+
61
+ it "should convert old API format" do
62
+ old_format = {
63
+ "architecture" => arch
64
+ }
65
+
66
+ rec = HammerCLIForeman.record_to_common_format(old_format)
67
+ rec.must_equal(arch)
68
+ end
69
+
70
+ it "should convert common API format" do
71
+ common_format = arch
72
+
73
+ rec = HammerCLIForeman.record_to_common_format(common_format)
74
+ rec.must_equal(arch)
75
+
76
+ end
77
+
78
+ end
79
+ end
@@ -9,6 +9,11 @@ describe HammerCLIForeman::Output::Formatters::OSNameFormatter do
9
9
  formatter = HammerCLIForeman::Output::Formatters::OSNameFormatter.new
10
10
  formatter.format({ :name => 'Fedora', :major => '19'}).must_equal 'Fedora 19'
11
11
  end
12
+
13
+ it "recovers when os is nil" do
14
+ formatter = HammerCLIForeman::Output::Formatters::OSNameFormatter.new
15
+ formatter.format(nil).must_equal nil
16
+ end
12
17
  end
13
18
 
14
19
  describe HammerCLIForeman::Output::Formatters::ServerFormatter do
@@ -16,4 +21,9 @@ describe HammerCLIForeman::Output::Formatters::ServerFormatter do
16
21
  formatter = HammerCLIForeman::Output::Formatters::ServerFormatter.new
17
22
  formatter.format({ :name => 'Server', :url => "URL"}).must_equal 'Server (URL)'
18
23
  end
24
+
25
+ it "recovers when server is nil" do
26
+ formatter = HammerCLIForeman::Output::Formatters::ServerFormatter.new
27
+ formatter.format(nil).must_equal nil
28
+ end
19
29
  end
@@ -3,7 +3,12 @@ require 'hammer_cli/output/adapter/abstract'
3
3
 
4
4
  class TestAdapter < HammerCLI::Output::Adapter::Abstract
5
5
 
6
- def print_records(fields, data)
6
+ def print_record(fields, record)
7
+ print_collection(fields, [record].flatten(1))
8
+ end
9
+
10
+
11
+ def print_collection(fields, data)
7
12
  @separator = '#'
8
13
  puts @separator+fields.collect{|f| f.label.to_s}.join(@separator)+@separator
9
14
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_foreman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomáš Strachota
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-26 00:00:00.000000000 Z
12
+ date: 2013-12-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hammer_cli
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '>='
19
19
  - !ruby/object:Gem::Version
20
- version: 0.0.10
20
+ version: 0.0.12
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '>='
26
26
  - !ruby/object:Gem::Version
27
- version: 0.0.10
27
+ version: 0.0.12
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: foreman_api
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -99,6 +99,7 @@ files:
99
99
  - lib/hammer_cli_foreman/version.rb
100
100
  - test/unit/apipie_resource_mock.rb
101
101
  - test/unit/architecture_test.rb
102
+ - test/unit/commands_test.rb
102
103
  - test/unit/common_parameter_test.rb
103
104
  - test/unit/compute_resource_test.rb
104
105
  - test/unit/domain_test.rb
@@ -145,13 +146,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
146
  version: '0'
146
147
  requirements: []
147
148
  rubyforge_project:
148
- rubygems_version: 2.0.8
149
+ rubygems_version: 2.0.13
149
150
  signing_key:
150
151
  specification_version: 4
151
152
  summary: Foreman commands for Hammer
152
153
  test_files:
153
154
  - test/unit/apipie_resource_mock.rb
154
155
  - test/unit/architecture_test.rb
156
+ - test/unit/commands_test.rb
155
157
  - test/unit/common_parameter_test.rb
156
158
  - test/unit/compute_resource_test.rb
157
159
  - test/unit/domain_test.rb