Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmthomas committed Jan 28, 2025
1 parent 0225326 commit 8fa82fb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion openc3/lib/openc3/api/tlm_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def inject_tlm(target_name, packet_name, item_hash = nil, type: :CONVERTED, manu
if type == :CONVERTED
# If the type is converted, check that the item states are valid
item_hash.each do |item_name, item_value|
item = items.find { |i| i['name'] == item_name }
item = items.find { |i| i['name'] == item_name.to_s.upcase }
if item['states'] && !item['states'][item_value]
raise "Unknown state '#{item_value}' for #{item['name']}, must be one of #{item['states'].keys.join(', ')}"
end
Expand Down
4 changes: 2 additions & 2 deletions openc3/python/openc3/api/tlm_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ def inject_tlm(target_name, packet_name, item_hash=None, type="CONVERTED", scope
if type == 'CONVERTED':
# If the type is converted, check that the item states are valid
for item_name, item_value in item_hash.items():
item = items.find(lambda i: i['name'] == item_name)
if item['states'] and item_value not in item['states']:
item = next((i for i in items if i['name'] == item_name.upper()), None)
if item and item.get('states') and item_value not in item['states']:
raise RuntimeError(
f"Unknown state '{item_value}' for {item['name']}, must be one of {', '.join(item['states'].keys())}"
)
Expand Down
4 changes: 2 additions & 2 deletions openc3/python/test/api/test_limits_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ def test_get_overall_limits_state_returns_the_overall_system_limits_state(self):
"TEMP2": 0,
"TEMP3": 0,
"TEMP4": 0,
"GROUND1STATUS": 1,
"GROUND2STATUS": 1,
"GROUND1STATUS": 'CONNECTED',
"GROUND2STATUS": 'CONNECTED',
},
)
time.sleep(0.1)
Expand Down
2 changes: 1 addition & 1 deletion openc3/spec/api/limits_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class ApiTest
describe "get_overall_limits_state" do
it "returns the overall system limits state" do
@api.inject_tlm("INST", "HEALTH_STATUS",
{ 'TEMP1' => 0, 'TEMP2' => 0, 'TEMP3' => 0, 'TEMP4' => 0, 'GROUND1STATUS' => 1, 'GROUND2STATUS' => 1 })
{ 'TEMP1' => 0, 'TEMP2' => 0, 'TEMP3' => 0, 'TEMP4' => 0, 'GROUND1STATUS' => 'CONNECTED', 'GROUND2STATUS' => 'CONNECTED' })
sleep 0.1
expect(@api.get_overall_limits_state).to eql "GREEN"
# TEMP1 limits: -80.0 -70.0 60.0 80.0 -20.0 20.0
Expand Down
2 changes: 2 additions & 0 deletions openc3/spec/api/tlm_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class ApiTest
before(:each) do
mock_redis()
setup_system()
local_s3()

%w(INST SYSTEM).each do |target|
model = TargetModel.new(folder_name: target, name: target, scope: "DEFAULT")
Expand All @@ -57,6 +58,7 @@ class ApiTest
end

after(:each) do
local_s3_unset()
Thread.list.each do |t|
t.join if t != Thread.current
end
Expand Down

0 comments on commit 8fa82fb

Please sign in to comment.