aemo 0.2.1 → 0.3.0.pre.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe AEMO::NMI::Allocation do
6
+ # ---
7
+ # CLASS METHODS
8
+ # ---
9
+ describe '.all' do
10
+ it 'should return an array of all the Allocations' do
11
+ expect(AEMO::NMI::Allocation.all).to be_a Array
12
+ expect(AEMO::NMI::Allocation.all.first).to be_a AEMO::NMI::Allocation
13
+ end
14
+ end
15
+
16
+ describe '.each' do
17
+ it 'should return an enumerable of all the Allocations' do
18
+ expect(AEMO::NMI::Allocation.each).to be_a Enumerable
19
+ end
20
+ end
21
+
22
+ describe '.first' do
23
+ it 'should return the first Allocation' do
24
+ expect(AEMO::NMI::Allocation.first).to be_a AEMO::NMI::Allocation
25
+ end
26
+ end
27
+
28
+ # ---
29
+ # INSTANCE METHODS
30
+ # ---
31
+ describe '#initialize' do
32
+ context 'valid' do
33
+ it 'should return an Allocation' do
34
+ expect(AEMO::NMI::Allocation.new('My great LNSP', :electricity)).to be_a AEMO::NMI::Allocation
35
+ expect(AEMO::NMI::Allocation.new('My great LNSP', 'electricity')).to be_a AEMO::NMI::Allocation
36
+ expect(AEMO::NMI::Allocation.new('My great gas LNSP', :gas)).to be_a AEMO::NMI::Allocation
37
+ expect(AEMO::NMI::Allocation.new('My great gas LNSP', 'gas')).to be_a AEMO::NMI::Allocation
38
+ end
39
+ end
40
+ context 'invalid' do
41
+ it 'should raise an InvalidNMIAllocationType error' do
42
+ expect { AEMO::NMI::Allocation.new('My terrible LNSP', :water) }.to raise_error AEMO::InvalidNMIAllocationType
43
+ expect { AEMO::NMI::Allocation.new('My terrible LNSP', :broccoli) }.to raise_error AEMO::InvalidNMIAllocationType
44
+ expect { AEMO::NMI::Allocation.new('My terrible LNSP', 'Ch4') }.to raise_error AEMO::InvalidNMIAllocationType
45
+ expect { AEMO::NMI::Allocation.new('My terrible LNSP', 'Natural gas') }.to raise_error AEMO::InvalidNMIAllocationType
46
+ expect { AEMO::NMI::Allocation.new('My terrible LNSP', :coal) }.to raise_error AEMO::InvalidNMIAllocationType
47
+ end
48
+ end
49
+ end
50
+ end
@@ -9,11 +9,6 @@ describe AEMO::NMI do
9
9
  # ---
10
10
  # CLASS CONSTANTS
11
11
  # ---
12
- describe '::NMI_ALLOCATIONS' do
13
- it 'should be a hash' do
14
- expect(AEMO::NMI::NMI_ALLOCATIONS.class).to eq(Hash)
15
- end
16
- end
17
12
  describe '::TNI_CODES' do
18
13
  it 'should be a hash' do
19
14
  expect(AEMO::NMI::TNI_CODES.class).to eq(Hash)
@@ -57,10 +52,10 @@ describe AEMO::NMI do
57
52
  end
58
53
  end
59
54
 
60
- describe '.network?(nmi)' do
55
+ describe '.network(nmi)' do
61
56
  it 'should return a network for an allocated NMI' do
62
57
  network = AEMO::NMI.network('NCCCC00000')
63
- expect(network.to_a[0].last[:title]).to eq('Ausgrid')
58
+ expect(network.title).to eq('Ausgrid')
64
59
  end
65
60
  it 'should return NIL for an unallocated NMI' do
66
61
  network = AEMO::NMI.network('ZZZZZZZZZZZZ')
@@ -68,6 +63,17 @@ describe AEMO::NMI do
68
63
  end
69
64
  end
70
65
 
66
+ describe '.allocation(nmi)' do
67
+ it 'should return an Allocation for a NMI' do
68
+ allocation = AEMO::NMI.allocation('NCCCC00000')
69
+ expect(allocation.title).to eq('Ausgrid')
70
+ end
71
+ it 'should return NIL for an unallocated NMI' do
72
+ allocation = AEMO::NMI.allocation('ZZZZZZZZZZZZ')
73
+ expect(allocation).to eq(nil)
74
+ end
75
+ end
76
+
71
77
  # ---
72
78
  # INSTANCE METHODS
73
79
  # ---
@@ -131,7 +137,9 @@ describe AEMO::NMI do
131
137
  it 'should return a network for a valid NMI' do
132
138
  json.each do |nmi|
133
139
  a_nmi = AEMO::NMI.new(nmi['nmi'])
134
- expect(a_nmi.network.class).to eq(Hash) unless a_nmi.network.nil?
140
+ next if a_nmi.network.nil?
141
+ expect(a_nmi.network).to be_a AEMO::NMI::Allocation
142
+ expect(a_nmi.allocation).to be_a AEMO::NMI::Allocation
135
143
  end
136
144
  end
137
145
  # Negative test cases
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aemo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0.pre.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Courtney
@@ -13,99 +13,99 @@ cert_chain: []
13
13
  date: 2016-11-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: json
16
+ name: activesupport
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: 1.7.5
21
+ version: 4.2.6
22
+ - - "<"
23
+ - !ruby/object:Gem::Version
24
+ version: '5.2'
22
25
  type: :runtime
23
26
  prerelease: false
24
27
  version_requirements: !ruby/object:Gem::Requirement
25
28
  requirements:
26
29
  - - ">="
27
30
  - !ruby/object:Gem::Version
28
- version: 1.7.5
31
+ version: 4.2.6
32
+ - - "<"
33
+ - !ruby/object:Gem::Version
34
+ version: '5.2'
29
35
  - !ruby/object:Gem::Dependency
30
- name: nokogiri
36
+ name: httparty
31
37
  requirement: !ruby/object:Gem::Requirement
32
38
  requirements:
33
39
  - - "~>"
34
40
  - !ruby/object:Gem::Version
35
- version: '1.8'
41
+ version: '0.15'
36
42
  - - ">="
37
43
  - !ruby/object:Gem::Version
38
- version: 1.8.2
44
+ version: 0.15.6
39
45
  type: :runtime
40
46
  prerelease: false
41
47
  version_requirements: !ruby/object:Gem::Requirement
42
48
  requirements:
43
49
  - - "~>"
44
50
  - !ruby/object:Gem::Version
45
- version: '1.8'
51
+ version: '0.15'
46
52
  - - ">="
47
53
  - !ruby/object:Gem::Version
48
- version: 1.8.2
54
+ version: 0.15.6
49
55
  - !ruby/object:Gem::Dependency
50
- name: multi_xml
56
+ name: json
51
57
  requirement: !ruby/object:Gem::Requirement
52
58
  requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '0.6'
56
59
  - - ">="
57
60
  - !ruby/object:Gem::Version
58
- version: 0.5.0
61
+ version: 1.7.5
59
62
  type: :runtime
60
63
  prerelease: false
61
64
  version_requirements: !ruby/object:Gem::Requirement
62
65
  requirements:
63
- - - "~>"
64
- - !ruby/object:Gem::Version
65
- version: '0.6'
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 0.5.0
68
+ version: 1.7.5
69
69
  - !ruby/object:Gem::Dependency
70
- name: httparty
70
+ name: multi_xml
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.15'
75
+ version: '0.6'
76
76
  - - ">="
77
77
  - !ruby/object:Gem::Version
78
- version: 0.15.6
78
+ version: 0.5.0
79
79
  type: :runtime
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - "~>"
84
84
  - !ruby/object:Gem::Version
85
- version: '0.15'
85
+ version: '0.6'
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
- version: 0.15.6
88
+ version: 0.5.0
89
89
  - !ruby/object:Gem::Dependency
90
- name: activesupport
90
+ name: nokogiri
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - ">="
93
+ - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: 4.2.6
96
- - - "<"
95
+ version: '1.8'
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
- version: '5.2'
98
+ version: 1.8.2
99
99
  type: :runtime
100
100
  prerelease: false
101
101
  version_requirements: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - ">="
103
+ - - "~>"
104
104
  - !ruby/object:Gem::Version
105
- version: 4.2.6
106
- - - "<"
105
+ version: '1.8'
106
+ - - ">="
107
107
  - !ruby/object:Gem::Version
108
- version: '5.2'
108
+ version: 1.8.2
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: awesome_print
111
111
  requirement: !ruby/object:Gem::Requirement
@@ -252,20 +252,20 @@ dependencies:
252
252
  requirements:
253
253
  - - "~>"
254
254
  - !ruby/object:Gem::Version
255
- version: '0.50'
255
+ version: 0.52.1
256
256
  - - ">="
257
257
  - !ruby/object:Gem::Version
258
- version: 0.50.0
258
+ version: 0.52.1
259
259
  type: :development
260
260
  prerelease: false
261
261
  version_requirements: !ruby/object:Gem::Requirement
262
262
  requirements:
263
263
  - - "~>"
264
264
  - !ruby/object:Gem::Version
265
- version: '0.50'
265
+ version: 0.52.1
266
266
  - - ">="
267
267
  - !ruby/object:Gem::Version
268
- version: 0.50.0
268
+ version: 0.52.1
269
269
  - !ruby/object:Gem::Dependency
270
270
  name: simplecov
271
271
  requirement: !ruby/object:Gem::Requirement
@@ -358,6 +358,7 @@ extra_rdoc_files: []
358
358
  files:
359
359
  - lib/aemo.rb
360
360
  - lib/aemo/dispatchable.rb
361
+ - lib/aemo/exceptions/invalid_nmi_allocation_type.rb
361
362
  - lib/aemo/market.rb
362
363
  - lib/aemo/market/interval.rb
363
364
  - lib/aemo/market/node.rb
@@ -366,6 +367,7 @@ files:
366
367
  - lib/aemo/nem12.rb
367
368
  - lib/aemo/nem13.rb
368
369
  - lib/aemo/nmi.rb
370
+ - lib/aemo/nmi/allocation.rb
369
371
  - lib/aemo/region.rb
370
372
  - lib/aemo/register.rb
371
373
  - lib/aemo/version.rb
@@ -494,6 +496,7 @@ files:
494
496
  - spec/lib/aemo/meter_spec.rb
495
497
  - spec/lib/aemo/msats_spec.rb
496
498
  - spec/lib/aemo/nem12_spec.rb
499
+ - spec/lib/aemo/nmi/allocation_spec.rb
497
500
  - spec/lib/aemo/nmi_spec.rb
498
501
  - spec/lib/aemo/region_spec.rb
499
502
  - spec/spec.opts
@@ -510,12 +513,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
510
513
  requirements:
511
514
  - - ">="
512
515
  - !ruby/object:Gem::Version
513
- version: 1.9.3
516
+ version: 2.3.0
514
517
  required_rubygems_version: !ruby/object:Gem::Requirement
515
518
  requirements:
516
- - - ">="
519
+ - - ">"
517
520
  - !ruby/object:Gem::Version
518
- version: '0'
521
+ version: 1.3.1
519
522
  requirements: []
520
523
  rubyforge_project:
521
524
  rubygems_version: 2.7.6
@@ -641,6 +644,7 @@ test_files:
641
644
  - spec/lib/aemo/meter_spec.rb
642
645
  - spec/lib/aemo/msats_spec.rb
643
646
  - spec/lib/aemo/nem12_spec.rb
647
+ - spec/lib/aemo/nmi/allocation_spec.rb
644
648
  - spec/lib/aemo/nmi_spec.rb
645
649
  - spec/lib/aemo/region_spec.rb
646
650
  - spec/spec.opts