-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from NREL/feature/add-list-resources
Add List Resources feature to FASTSim-2 (SerdeAPI tweaks, list_resources)
- Loading branch information
Showing
6 changed files
with
89 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Test getting resource lists via Rust API""" | ||
import unittest | ||
|
||
import fastsim as fsim | ||
from fastsim import cycle, vehicle | ||
|
||
class TestListResources(unittest.TestCase): | ||
def test_list_resources_for_cycle(self): | ||
"check if list_resources works for RustCycle" | ||
c = cycle.Cycle.from_dict({ | ||
"cycSecs": [0.0, 1.0], | ||
"cycMps": [0.0, 0.0]}) | ||
rc = c.to_rust() | ||
resources = rc.list_resources() | ||
self.assertTrue(len(resources) > 0) | ||
|
||
def test_list_resources_for_vehicles(self): | ||
"check if list_resources works for RustVehicle" | ||
# NOTE: at the time of writing this test, | ||
# there are no vehicle assets in resources. | ||
# Therefore, we expect to get an empty vector. | ||
# If resources are committed, this test should | ||
# fail and we should use the following assert: | ||
# self.assertTrue(len(resources) > 0) | ||
rv = vehicle.Vehicle.from_vehdb(1).to_rust() | ||
resources = rv.list_resources() | ||
self.assertTrue(len(resources) == 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters