aemo 0.1.19 → 0.1.20
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.
- checksums.yaml +4 -4
- data/lib/aemo.rb +0 -1
- data/lib/aemo/market.rb +2 -7
- data/lib/aemo/msats.rb +19 -12
- data/lib/aemo/nem12.rb +4 -25
- data/lib/aemo/nmi.rb +66 -70
- data/lib/aemo/region.rb +16 -17
- data/lib/aemo/version.rb +1 -1
- data/spec/fixtures/MSATS/c4.xml +275 -0
- data/spec/fixtures/MSATS/msats_limits.xml +67 -0
- data/spec/fixtures/MSATS/nmi_details.xml +144 -0
- data/spec/fixtures/MSATS/nmi_details.xml.zip +0 -0
- data/spec/fixtures/MSATS/nmi_discovery_by_address.xml +141 -0
- data/spec/fixtures/MSATS/participant_system_status.xml +30 -0
- data/spec/lib/aemo/market/interval_spec.rb +49 -0
- data/spec/lib/aemo/market_spec.rb +14 -8
- data/spec/lib/aemo/msats_spec.rb +84 -0
- data/spec/lib/aemo/nem12_spec.rb +21 -23
- data/spec/lib/aemo/nmi_spec.rb +78 -0
- data/spec/lib/aemo/region_spec.rb +49 -1
- data/spec/spec_helper.rb +41 -2
- metadata +63 -21
Binary file
|
@@ -0,0 +1,141 @@
|
|
1
|
+
<?xml version="1.0" ?>
|
2
|
+
<ase:aseXML xmlns:ase="urn:aseXML:r31" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:aseXML:r31 http://www.nemmco.com.au/aseXML/schemas/r31/aseXML_r31.xsd">
|
3
|
+
<Header>
|
4
|
+
<From description="Australian Energy Market Operator Limited">NEMMCO</From>
|
5
|
+
<To description="COzero Energy Retail Pty Ltd">COZEROER</To>
|
6
|
+
<MessageID>NEMMCO-MSG-600298046</MessageID>
|
7
|
+
<MessageDate>2016-03-23T16:12:34+10:00</MessageDate>
|
8
|
+
<TransactionGroup>NMID</TransactionGroup>
|
9
|
+
<Priority>High</Priority>
|
10
|
+
<SecurityContext>NEMMCOBATCH</SecurityContext>
|
11
|
+
<Market>NEM</Market>
|
12
|
+
</Header>
|
13
|
+
<Transactions>
|
14
|
+
<Transaction transactionID="NMID-600298046" transactionDate="2016-03-23T16:12:34+10:00" initiatingTransactionID="1234567890">
|
15
|
+
<NMIDiscoveryResponse version="r17">
|
16
|
+
<NMIStandingData xsi:type="ase:ElectricityStandingData" version="r31">
|
17
|
+
<NMI checksum="7">4000000000</NMI>
|
18
|
+
<MasterData>
|
19
|
+
<Address>
|
20
|
+
<StructuredAddress>
|
21
|
+
<FlatOrUnit>
|
22
|
+
<FlatOrUnitType>SITE</FlatOrUnitType>
|
23
|
+
<FlatOrUnitNumber>0</FlatOrUnitNumber>
|
24
|
+
</FlatOrUnit>
|
25
|
+
<BuildingOrPropertyName>PARLIAMENT HOUSE</BuildingOrPropertyName>
|
26
|
+
<LocationDescriptor>HUT PARLIAMENT HOUSE TELSTRA</LocationDescriptor>
|
27
|
+
<House>
|
28
|
+
<HouseNumber>6</HouseNumber>
|
29
|
+
</House>
|
30
|
+
<Street>
|
31
|
+
<StreetName>MACQUARIE</StreetName>
|
32
|
+
<StreetType>ST</StreetType>
|
33
|
+
</Street>
|
34
|
+
</StructuredAddress>
|
35
|
+
<SuburbOrPlaceOrLocality>SYDNEY</SuburbOrPlaceOrLocality>
|
36
|
+
<StateOrTerritory>NSW</StateOrTerritory>
|
37
|
+
<PostCode>2000</PostCode>
|
38
|
+
</Address>
|
39
|
+
<CustomerClassificationCode>BUSINESS</CustomerClassificationCode>
|
40
|
+
<CustomerThresholdCode>LOW</CustomerThresholdCode>
|
41
|
+
</MasterData>
|
42
|
+
<RoleAssignments>
|
43
|
+
<RoleAssignment>
|
44
|
+
<Party>ENERGYAP</Party>
|
45
|
+
<Role>LNSP</Role>
|
46
|
+
</RoleAssignment>
|
47
|
+
</RoleAssignments>
|
48
|
+
</NMIStandingData>
|
49
|
+
<NMIStandingData xsi:type="ase:ElectricityStandingData" version="r31">
|
50
|
+
<NMI checksum="4">4000000001</NMI>
|
51
|
+
<MasterData>
|
52
|
+
<Address>
|
53
|
+
<StructuredAddress>
|
54
|
+
<BuildingOrPropertyName>PARLIAMENT HOUSE</BuildingOrPropertyName>
|
55
|
+
<LocationDescriptor>SUPPLY 3</LocationDescriptor>
|
56
|
+
<House>
|
57
|
+
<HouseNumber>6</HouseNumber>
|
58
|
+
</House>
|
59
|
+
<Street>
|
60
|
+
<StreetName>MACQUARIE</StreetName>
|
61
|
+
<StreetType>ST</StreetType>
|
62
|
+
</Street>
|
63
|
+
</StructuredAddress>
|
64
|
+
<SuburbOrPlaceOrLocality>SYDNEY</SuburbOrPlaceOrLocality>
|
65
|
+
<StateOrTerritory>NSW</StateOrTerritory>
|
66
|
+
<PostCode>2000</PostCode>
|
67
|
+
</Address>
|
68
|
+
<CustomerClassificationCode>BUSINESS</CustomerClassificationCode>
|
69
|
+
<CustomerThresholdCode>HIGH</CustomerThresholdCode>
|
70
|
+
</MasterData>
|
71
|
+
<RoleAssignments>
|
72
|
+
<RoleAssignment>
|
73
|
+
<Party>ENERGYAP</Party>
|
74
|
+
<Role>LNSP</Role>
|
75
|
+
</RoleAssignment>
|
76
|
+
</RoleAssignments>
|
77
|
+
</NMIStandingData>
|
78
|
+
<NMIStandingData xsi:type="ase:ElectricityStandingData" version="r31">
|
79
|
+
<NMI checksum="8">4000000002</NMI>
|
80
|
+
<MasterData>
|
81
|
+
<Address>
|
82
|
+
<StructuredAddress>
|
83
|
+
<BuildingOrPropertyName>PARLIAMENT HOUSE</BuildingOrPropertyName>
|
84
|
+
<House>
|
85
|
+
<HouseNumber>6</HouseNumber>
|
86
|
+
</House>
|
87
|
+
<Street>
|
88
|
+
<StreetName>MACQUARIE</StreetName>
|
89
|
+
<StreetType>ST</StreetType>
|
90
|
+
</Street>
|
91
|
+
</StructuredAddress>
|
92
|
+
<SuburbOrPlaceOrLocality>SYDNEY</SuburbOrPlaceOrLocality>
|
93
|
+
<StateOrTerritory>NSW</StateOrTerritory>
|
94
|
+
<PostCode>2000</PostCode>
|
95
|
+
</Address>
|
96
|
+
<CustomerClassificationCode>BUSINESS</CustomerClassificationCode>
|
97
|
+
<CustomerThresholdCode>LOW</CustomerThresholdCode>
|
98
|
+
</MasterData>
|
99
|
+
<RoleAssignments>
|
100
|
+
<RoleAssignment>
|
101
|
+
<Party>ENERGYAP</Party>
|
102
|
+
<Role>LNSP</Role>
|
103
|
+
</RoleAssignment>
|
104
|
+
</RoleAssignments>
|
105
|
+
</NMIStandingData>
|
106
|
+
<NMIStandingData xsi:type="ase:ElectricityStandingData" version="r31">
|
107
|
+
<NMI checksum="6">4000000003</NMI>
|
108
|
+
<MasterData>
|
109
|
+
<Address>
|
110
|
+
<StructuredAddress>
|
111
|
+
<BuildingOrPropertyName>PARLIAMENT HOUSE</BuildingOrPropertyName>
|
112
|
+
<LocationDescriptor>SUPPLIES 1 AND 2</LocationDescriptor>
|
113
|
+
<House>
|
114
|
+
<HouseNumber>6</HouseNumber>
|
115
|
+
</House>
|
116
|
+
<Street>
|
117
|
+
<StreetName>MACQUARIE</StreetName>
|
118
|
+
<StreetType>ST</StreetType>
|
119
|
+
</Street>
|
120
|
+
</StructuredAddress>
|
121
|
+
<SuburbOrPlaceOrLocality>SYDNEY</SuburbOrPlaceOrLocality>
|
122
|
+
<StateOrTerritory>NSW</StateOrTerritory>
|
123
|
+
<PostCode>2000</PostCode>
|
124
|
+
</Address>
|
125
|
+
<CustomerClassificationCode>BUSINESS</CustomerClassificationCode>
|
126
|
+
<CustomerThresholdCode>HIGH</CustomerThresholdCode>
|
127
|
+
</MasterData>
|
128
|
+
<RoleAssignments>
|
129
|
+
<RoleAssignment>
|
130
|
+
<Party>ENERGYAP</Party>
|
131
|
+
<Role>LNSP</Role>
|
132
|
+
</RoleAssignment>
|
133
|
+
</RoleAssignments>
|
134
|
+
</NMIStandingData>
|
135
|
+
<Event severity="Information">
|
136
|
+
<Code>0</Code>
|
137
|
+
</Event>
|
138
|
+
</NMIDiscoveryResponse>
|
139
|
+
</Transaction>
|
140
|
+
</Transactions>
|
141
|
+
</ase:aseXML>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<?xml version="1.0" ?>
|
2
|
+
<ase:aseXML xmlns:ase="urn:aseXML:r32" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:aseXML:r32 http://www.nemmco.com.au/aseXML/schemas/r32/aseXML_r32.xsd">
|
3
|
+
<Header>
|
4
|
+
<From description="Australian Energy Market Operator Limited">NEMMCO</From>
|
5
|
+
<To description="Energy Retail">ER</To>
|
6
|
+
<MessageID>NEMMCO-MSG-666</MessageID>
|
7
|
+
<MessageDate>2016-01-01T00:00:00+10:00</MessageDate>
|
8
|
+
<TransactionGroup>CATS</TransactionGroup>
|
9
|
+
<Priority>Medium</Priority>
|
10
|
+
<SecurityContext>NEMMCOBATCH</SecurityContext>
|
11
|
+
<Market>NEM</Market>
|
12
|
+
</Header>
|
13
|
+
<Transactions>
|
14
|
+
<Transaction transactionID="CATS-666" transactionDate="2016-01-01T00:00:00+10:00" initiatingTransactionID="1234567890">
|
15
|
+
<ReportResponse version="r10">
|
16
|
+
<ReportParameters xsi:type="ase:GenericReportParameters">
|
17
|
+
<ReportName>ParticipantSystemStatus</ReportName>
|
18
|
+
</ReportParameters>
|
19
|
+
<ReportResults xsi:type="ase:CATSParticipantSystemStatusReportFormat">
|
20
|
+
<ParticipantSystemsStatus>
|
21
|
+
</ParticipantSystemsStatus>
|
22
|
+
</ReportResults>
|
23
|
+
<Event severity="Information">
|
24
|
+
<Code>0</Code>
|
25
|
+
<Explanation>Success</Explanation>
|
26
|
+
</Event>
|
27
|
+
</ReportResponse>
|
28
|
+
</Transaction>
|
29
|
+
</Transactions>
|
30
|
+
</ase:aseXML>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AEMO::Market::Interval do
|
4
|
+
describe 'AEMO::Market::Interval contstants' do
|
5
|
+
it 'has INTERVALS' do
|
6
|
+
expect(AEMO::Market::Interval::INTERVALS).to eq({trading: 'Trading',dispatch: 'Dispatch'})
|
7
|
+
end
|
8
|
+
end
|
9
|
+
describe 'AEMO::Market::Interval instance methods' do
|
10
|
+
before(:each) do
|
11
|
+
@interval = AEMO::Market::Interval.new("2016-03-01T00:30:00", {'REGION' => 'NSW', 'TOTALDEMAND' => 1000.23, 'RRP' => 76.54, 'PERIODTYPE' => 'TRADING'})
|
12
|
+
end
|
13
|
+
it 'creates a valid interval' do
|
14
|
+
expect {AEMO::Market::Interval.new("2016-03-01T00:30:00", {'REGION' => 'NSW', 'TOTALDEMAND' => 1000.23, 'RRP' => 76.54, 'PERIODTYPE' => 'TRADING'})}.not_to raise_error
|
15
|
+
end
|
16
|
+
it 'has a trailing datetime' do
|
17
|
+
expect(@interval.datetime).to eq(DateTime.parse("2016-03-01T00:30:00+1000"))
|
18
|
+
end
|
19
|
+
it 'has a leading datetime' do
|
20
|
+
expect(@interval.datetime(false)).to eq(DateTime.parse("2016-03-01T00:00:00+1000"))
|
21
|
+
end
|
22
|
+
it 'has a leading datetime for dispatch' do
|
23
|
+
@interval = AEMO::Market::Interval.new("2016-03-01T00:30:00", {'REGION' => 'NSW', 'TOTALDEMAND' => 1000.23, 'RRP' => 76.54, 'PERIODTYPE' => ''})
|
24
|
+
expect(@interval.datetime(false)).to eq(DateTime.parse("2016-03-01T00:25:00+1000"))
|
25
|
+
end
|
26
|
+
it 'has an interval length' do
|
27
|
+
expect(@interval.interval_length).to eq(Time.at(300))
|
28
|
+
end
|
29
|
+
it 'is a trading interval' do
|
30
|
+
expect(@interval.interval_type).to eq(:trading)
|
31
|
+
end
|
32
|
+
it 'is a trading interval' do
|
33
|
+
expect(@interval.is_trading?).to eq(true)
|
34
|
+
expect(@interval.is_dispatch?).to eq(false)
|
35
|
+
end
|
36
|
+
it 'is a dispatch interval' do
|
37
|
+
@interval = AEMO::Market::Interval.new("2016-03-01T00:30:00", {'REGION' => 'NSW', 'TOTALDEMAND' => 1000.23, 'RRP' => 76.54, 'PERIODTYPE' => ''})
|
38
|
+
expect(@interval.interval_type).to eq(:dispatch)
|
39
|
+
end
|
40
|
+
it 'is a dispatch interval' do
|
41
|
+
@interval = AEMO::Market::Interval.new("2016-03-01T00:30:00", {'REGION' => 'NSW', 'TOTALDEMAND' => 1000.23, 'RRP' => 76.54, 'PERIODTYPE' => ''})
|
42
|
+
expect(@interval.is_trading?).to eq(false)
|
43
|
+
expect(@interval.is_dispatch?).to eq(true)
|
44
|
+
end
|
45
|
+
it 'has a valid value' do
|
46
|
+
expect(@interval.value).to eq((@interval.total_demand * @interval.rrp).round(2))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,16 +1,22 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe AEMO::Market do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
it "returns the SupportedFormats constant for subclasses" do
|
5
|
+
class MyParser < HTTParty::Parser
|
6
|
+
SupportedFormats = {"application/atom+xml" => :atom}
|
7
7
|
end
|
8
|
+
expect(MyParser.formats).to eq({"application/atom+xml" => :atom})
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'Dispatch data' do
|
12
|
+
it 'has an array of data' do
|
13
|
+
expect(AEMO::Market.current_dispatch('NSW').class).to eq(Array)
|
14
|
+
end
|
15
|
+
end
|
8
16
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
expect(MyParser.formats).to eq({"application/atom+xml" => :atom})
|
17
|
+
describe 'Trading data' do
|
18
|
+
it 'has an array of data' do
|
19
|
+
expect(AEMO::Market.current_trading('NSW').class).to eq(Array)
|
14
20
|
end
|
15
21
|
end
|
16
22
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AEMO::MSATS do
|
4
|
+
describe 'instance methods' do
|
5
|
+
it 'creates a new instance' do
|
6
|
+
expect(AEMO::MSATS.new.class).to eq(AEMO::MSATS)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'class methods' do
|
11
|
+
describe 'nmi details' do
|
12
|
+
before(:each) do
|
13
|
+
AEMO::MSATS.authorize("ER","ER","ER")
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should get data for a valid nmi' do
|
17
|
+
nmi_detail_query = AEMO::MSATS.nmi_detail('4001234567')
|
18
|
+
expect(nmi_detail_query.class).to eq(Hash)
|
19
|
+
end
|
20
|
+
it 'should get a 404 for a nonexistent nmi' do
|
21
|
+
nmi_detail_query = AEMO::MSATS.nmi_detail('4001234566')
|
22
|
+
# TODO workout what the different errors are here...
|
23
|
+
end
|
24
|
+
it 'should raise an error for a bad nmi' do
|
25
|
+
expect {AEMO::MSATS.nmi_detail('BOBISAFISH')}.to raise_error(ArgumentError)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#c4' do
|
30
|
+
before(:each) do
|
31
|
+
AEMO::MSATS.authorize("ER","ER","ER")
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should return a hash of information' do
|
35
|
+
AEMO::MSATS.c4("4001234567",DateTime.now,DateTime.now,DateTime.now)
|
36
|
+
end
|
37
|
+
it 'should raise an error for a bad nmi' do
|
38
|
+
expect {AEMO::MSATS.c4('BOBISAFISH')}.to raise_error(ArgumentError)
|
39
|
+
end
|
40
|
+
it 'should return a hash of information' do
|
41
|
+
AEMO::MSATS.c4("4001234566",DateTime.now,DateTime.now,DateTime.now)
|
42
|
+
# TODO workout what the different errors are here...
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#msats_limits' do
|
47
|
+
before(:each) do
|
48
|
+
AEMO::MSATS.authorize("ER","ER","ER")
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should give details of msats_limits' do
|
52
|
+
expect(AEMO::MSATS.msats_limits.class).to eq(Hash)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#nmi_discovery_by_*' do
|
57
|
+
before(:each) do
|
58
|
+
AEMO::MSATS.authorize("ER","ER","ER")
|
59
|
+
end
|
60
|
+
it 'should find by address' do
|
61
|
+
expect(AEMO::MSATS.nmi_discovery_by_address('NSW',{ house_number: 6, street_name: 'Macquarie', suburb_or_place_or_locality: 'Sydney', postcode: 2000}).class).to eq(Array)
|
62
|
+
end
|
63
|
+
it 'should find by meter_serial_number' do
|
64
|
+
expect(AEMO::MSATS.nmi_discovery_by_meter_serial_number('NSW',666).class).to eq(Array)
|
65
|
+
end
|
66
|
+
it 'should find by meter_serial_number' do
|
67
|
+
expect {AEMO::MSATS.nmi_discovery_by_delivery_point_identifier('NSW',666)}.to raise_error(ArgumentError)
|
68
|
+
end
|
69
|
+
it 'should find by meter_serial_number' do
|
70
|
+
expect(AEMO::MSATS.nmi_discovery_by_delivery_point_identifier('NSW',10000001).class).to eq(Array)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#system_status' do
|
75
|
+
before(:each) do
|
76
|
+
AEMO::MSATS.authorize("ER","ER","ER")
|
77
|
+
end
|
78
|
+
it 'should provide a status' do
|
79
|
+
AEMO::MSATS.system_status
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
data/spec/lib/aemo/nem12_spec.rb
CHANGED
@@ -11,23 +11,6 @@ describe AEMO::NEM12 do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
describe '.valid_nmi?' do
|
15
|
-
it 'should validate nmi' do
|
16
|
-
json.each do |nmi|
|
17
|
-
expect(AEMO::NEM12.valid_nmi?(nmi['nmi'])).to eq(true)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#nmi_checksum' do
|
23
|
-
it 'should return nmi checksum' do
|
24
|
-
json.each do |nmi|
|
25
|
-
nem12 = AEMO::NEM12.new(nmi['nmi'])
|
26
|
-
expect(nem12.nmi_checksum).to eq(nmi['checksum'])
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
14
|
describe '#parse_nem12' do
|
32
15
|
end
|
33
16
|
|
@@ -39,22 +22,37 @@ describe AEMO::NEM12 do
|
|
39
22
|
end
|
40
23
|
end
|
41
24
|
|
42
|
-
describe 'parse_nem12_100' do
|
25
|
+
describe '#parse_nem12_100' do
|
26
|
+
it 'should raise datetime error' do
|
27
|
+
expect {AEMO::NEM12.parse_nem12_100('100,NEM12,666,CNRGYMDP,NEMMCO')}.to raise_error(ArgumentError)
|
28
|
+
end
|
29
|
+
it 'should raise datetime error' do
|
30
|
+
expect {AEMO::NEM12.parse_nem12_100('100,NEM12,666,CNRGYMDP,NEMMCO', {strict: true})}.to raise_error(ArgumentError)
|
31
|
+
end
|
32
|
+
it 'should not raise an error' do
|
33
|
+
expect {AEMO::NEM12.parse_nem12_100('100,NEM12,201603010000,CNRGYMDP,NEMMCO', {strict: true})}.not_to raise_error
|
34
|
+
end
|
43
35
|
end
|
44
36
|
|
45
|
-
describe 'parse_nem12_200' do
|
37
|
+
describe '#parse_nem12_200' do
|
38
|
+
before(:each) do
|
39
|
+
@nem12 = AEMO::NEM12.parse_nem12_100('100,NEM12,201603010000,CNRGYMDP,NEMMCO', {strict: true})
|
40
|
+
end
|
46
41
|
end
|
47
42
|
|
48
|
-
describe 'parse_nem12_300' do
|
43
|
+
describe '#parse_nem12_300' do
|
49
44
|
end
|
50
45
|
|
51
|
-
describe 'parse_nem12_400' do
|
46
|
+
describe '#parse_nem12_400' do
|
52
47
|
end
|
53
48
|
|
54
|
-
describe 'parse_nem12_500' do
|
49
|
+
describe '#parse_nem12_500' do
|
55
50
|
end
|
56
51
|
|
57
|
-
describe 'parse_nem12_900' do
|
52
|
+
describe '#parse_nem12_900' do
|
58
53
|
end
|
59
54
|
|
55
|
+
describe '#flag_to_s' do
|
56
|
+
|
57
|
+
end
|
60
58
|
end
|
data/spec/lib/aemo/nmi_spec.rb
CHANGED
@@ -131,4 +131,82 @@ describe AEMO::NMI do
|
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
+
describe "#friendly_address" do
|
135
|
+
it 'should return the empty string if the address is not a hash' do
|
136
|
+
nmi = AEMO::NMI.new("4001234567")
|
137
|
+
nmi.address = "An address"
|
138
|
+
expect(nmi.friendly_address).to eq('')
|
139
|
+
end
|
140
|
+
it 'should return a friendly address if the address is a hash' do
|
141
|
+
nmi = AEMO::NMI.new("4001234567")
|
142
|
+
nmi.address = { number: '1', street: 'Bob', street_type: 'Street'}
|
143
|
+
expect(nmi.friendly_address).to eq('1, Bob, Street')
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe "#current_daily_load" do
|
148
|
+
it "should return zero for no data" do
|
149
|
+
@nmi = AEMO::NMI.new("4001234567")
|
150
|
+
expect(@nmi.current_daily_load).to eq(0)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe "#meters_by_status" do
|
155
|
+
before(:each) do
|
156
|
+
@nmi = AEMO::NMI.new("4001234567")
|
157
|
+
@nmi.meters = [OpenStruct.new(status: 'C'),OpenStruct.new(status: 'R')]
|
158
|
+
end
|
159
|
+
it 'should return current meters' do
|
160
|
+
expect(@nmi.meters_by_status.count).to eq(1)
|
161
|
+
end
|
162
|
+
it 'should return retired meters' do
|
163
|
+
expect(@nmi.meters_by_status('R').count).to eq(1)
|
164
|
+
end
|
165
|
+
it 'should return zero meters for weird status' do
|
166
|
+
expect(@nmi.meters_by_status('TMP').count).to eq(0)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "distribution loss factors" do
|
171
|
+
before(:each) do
|
172
|
+
@nmi = AEMO::NMI.new("4001234567")
|
173
|
+
@nmi.dlf = "BL0A"
|
174
|
+
@nmi.tni = "NGN2"
|
175
|
+
end
|
176
|
+
it "has a valid DLF Code" do
|
177
|
+
expect(@nmi.dlf).to eq("BL0A")
|
178
|
+
end
|
179
|
+
it "has a DLF value" do
|
180
|
+
expect(@nmi.dlfc_value.class).to eq(Float)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
describe "transmission node identifiers and loss factors" do
|
185
|
+
before(:each) do
|
186
|
+
@nmi = AEMO::NMI.new("4001234567")
|
187
|
+
@nmi.dlf = "BL0A"
|
188
|
+
@nmi.tni = "NGN2"
|
189
|
+
end
|
190
|
+
it "has a valid TNI Code" do
|
191
|
+
expect(@nmi.tni).to eq("NGN2")
|
192
|
+
end
|
193
|
+
it "has a TNI value" do
|
194
|
+
expect(@nmi.tni_value.class).to eq(Float)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
describe "MSATS functions" do
|
199
|
+
it 'should get data' do
|
200
|
+
AEMO::MSATS.authorize("ER","ER","ER")
|
201
|
+
nmi = AEMO::NMI.new('4001234567')
|
202
|
+
nmi.update_from_msats!
|
203
|
+
expect(nmi.msats_detail).to_not eq(nil)
|
204
|
+
end
|
205
|
+
it 'should return the hash of raw data' do
|
206
|
+
AEMO::MSATS.authorize("ER","ER","ER")
|
207
|
+
nmi = AEMO::NMI.new('4001234567')
|
208
|
+
expect(nmi.raw_msats_nmi_detail.class).to eq(Hash)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
134
212
|
end
|