rsmp-validator 0.3.2 → 0.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf28fcdaff9ccf8df4f107cbe2f045e55316f81285c21520da2ef63a19f9f94f
4
- data.tar.gz: 5c7614286acbcb9dce4abb36b66fb48a94493b072a7f88432b598e3249d0b6df
3
+ metadata.gz: ec84b58102563bba94566d083e07f4180e2522a977b5d8c94fe10bd397518c06
4
+ data.tar.gz: 511f803b289f6bdb2a8483174b50bccb2b7bc56e60f32c6209d48becc82c584f
5
5
  SHA512:
6
- metadata.gz: 3e31a7dd63d4143b7804f04026d090a1936e3918a6bd2f060c6e6dd8ae81ad74600ac76cac553a17a89daad2bf769efeaf293f0c6f73d5ca049dbcc756f99e06
7
- data.tar.gz: 4abbb6813ee551793997e18e680f131f15680f2a2a16361d524607baf9068807e4f7a663e5d136e2941b9dad8c9601a3ba995dcf80dcc778fef365702e34aa01
6
+ metadata.gz: ada00db87ffe79709e3fa3003037da04894a5aa39f3699e608aa1c33dea845726a37cc7c13923a9b7af8870af25c160a0ac2a946d6c89f0b3efed8360af28e87
7
+ data.tar.gz: 0f90a7420de0f29caefb21f83dba9657684536d597b58a4399e74d40f3e34e295b2ae65114a6f3a6e60aaf4b2e6607add3a7c133f97a2eef1f0c3401f9f488f4
@@ -1,5 +1,5 @@
1
1
  module RSMP
2
2
  module Validator
3
- VERSION = '0.3.2'.freeze
3
+ VERSION = '0.3.3'.freeze
4
4
  end
5
5
  end
@@ -5,9 +5,10 @@ describe 'Site::Tlc::Subscribe' do
5
5
  # is arbitrary as we simply want to check that
6
6
  # the subscription mechanism works.
7
7
  #
8
- # 1. subscribe
9
- # 1. check that we receive a status update with a predefined time
10
- # 1. unsubscribe
8
+ # 1. Given the site_proxy is connected
9
+ # 2. When we subscribe to S0001
10
+ # 3. Then we should receive a status update
11
+ # 4. Finally we unsubscribe from S0001
11
12
 
12
13
  it 'can be turned on and off for S0001' do
13
14
  with_site(:connected) do |site_proxy|
@@ -30,39 +31,41 @@ describe 'Site::Tlc::Subscribe' do
30
31
  # The test subscribes to S0001 'cyclecounter' attribute with an initial update rate of 60s,
31
32
  # then changes the update rate to 1s and verifies the new rate is in effect.
32
33
  #
33
- # 1. Subscribe to S0001 'cyclecounter' with update rate 60s
34
- # 2. Verify that subscription succeeds
35
- # 3. Send the same subscription again with update rate 1s
36
- # 4. Verify that the new update rate is in effect by checking next update is received within 2s
34
+ # 1. Given the site_proxy is connected
35
+ # 2. When we subscribe to S0001 'cyclecounter' with update rate 60s
36
+ # 3. And we change the update rate to 1s
37
+ # 4. Then we should receive two immediate updates and one periodic update within 2s
38
+ # 5. Finally we unsubscribe from S0001
37
39
 
38
40
  it 'can change interval during active subscription' do
39
41
  with_site(:connected) do |site_proxy|
40
42
  component = RSMP::Validator.get_config('main_component')
43
+ matcher = RSMP::StatusMatcher.new('sCI' => 'S0001', 'n' => 'cyclecounter')
41
44
 
42
- # Step 1: Subscribe with 60s update rate (no need to wait for updates with long interval)
43
- log 'Subscribe to S0001 cyclecounter with 60s update rate'
44
- initial_status_list = [{ 'sCI' => 'S0001', 'n' => 'cyclecounter', 'uRt' => '60' }]
45
- initial_status_list.map! { |item| item.merge!('sOc' => true) } if site_proxy.tlc.use_soc?
46
-
47
- # Subscribe but don't wait for updates (since 60s is too long)
48
- site_proxy.subscribe_to_status! initial_status_list, component: component
49
- log 'Initial subscription with 60s update rate successful'
45
+ # start collecting matching status updates
46
+ collector = RSMP::Collector.new(
47
+ site_proxy,
48
+ filter: RSMP::Filter.new(type: 'StatusUpdate', component: component, ingoing: true, outgoing: false),
49
+ num: 3,
50
+ timeout: 2
51
+ )
52
+ collector.start do |message|
53
+ :keep if message.attributes.fetch('sS', []).any? { |item| matcher.match(item) }
54
+ end
50
55
 
51
- # Step 3: Change update rate to 1s by re-subscribing and verify we get update within 2s
52
- log 'Change update rate to 1s by re-subscribing and verify update within 2s'
53
- updated_status_list = [{ 'sCI' => 'S0001', 'n' => 'cyclecounter', 'uRt' => '1' }]
54
- updated_status_list.map! { |item| item.merge!('sOc' => true) } if site_proxy.tlc.use_soc?
56
+ log 'Subscribe to S0001 cyclecounter with 60s update rate'
57
+ status_list = [{ 'sCI' => 'S0001', 'n' => 'cyclecounter', 'uRt' => '60' }]
58
+ status_list.each { |item| item['sOc'] = false } if site_proxy.tlc.use_soc?
59
+ site_proxy.subscribe_to_status! status_list, component: component
55
60
 
56
- # This should collect at least one status update within 2s if the 1s rate is working
57
- exchange = site_proxy.subscribe_to_status_and_collect(updated_status_list,
58
- component: component,
59
- within: 2).value!
61
+ log 'Change update rate to 1s and wait for three updates within 2s'
62
+ status_list.first['uRt'] = '1'
63
+ site_proxy.subscribe_to_status! status_list, component: component
60
64
 
61
- assert(!exchange.nil?, 'Expected subscribe_to_status_and_collect to return an exchange')
62
- assert(!exchange.messages.empty?,
63
- 'Expected to receive status update within 2s with new 1s update rate')
64
- log 'Successfully received status update within 2s, confirming 1s update rate is active'
65
+ expect(collector.wait.success?).to be == true
66
+ log 'Received three updates within 2s, confirming periodic updates at the new rate'
65
67
  ensure
68
+ collector&.stop
66
69
  # Clean up subscription
67
70
  unsubscribe_list = [{ 'sCI' => 'S0001', 'n' => 'cyclecounter' }]
68
71
  site_proxy.unsubscribe_to_status! unsubscribe_list, component: component
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsmp-validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - RSMP Nordic