-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OS X crash on import paseos when pip installed #51
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ca1e90f
Updates to not control the event loop
johanos1 0d237a1
PASEOS adds tasks to event loop instead of starting it during activit…
johanos1 11b9088
removed commented line
johanos1 d8400dc
MANIFEST file created to include resources on pip install
johanos1 b6546ce
Removed images from module.
johanos1 5684c82
Include resources in commit
johanos1 7e91bcc
Remove .DS_Store
johanos1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,2 @@ | ||
include paseos/resources/default_cfg.toml | ||
include README.md |
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ dependencies: | |
- myst-parser | ||
- pykep | ||
- pytest | ||
- pytest-asyncio | ||
- python | ||
- scikit-spatial | ||
- sphinx | ||
|
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
File renamed without changes.
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 |
---|---|---|
|
@@ -2,11 +2,18 @@ | |
from test_utils import get_default_instance | ||
|
||
from paseos import SpacecraftActor | ||
|
||
import asyncio | ||
import pytest | ||
|
||
|
||
async def wait_for_activity(sim): | ||
while sim._is_running_activity is True: | ||
await asyncio.sleep(0.1) | ||
|
||
|
||
def test_activity(): | ||
# tell pytest to create an event loop and execute the tests using the event loop | ||
@pytest.mark.asyncio | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a comment somewhere what this actually does, so we remember? :) |
||
async def test_activity(): | ||
"""Test if performing activity consumes power as expected""" | ||
sim, sat1, earth = get_default_instance() | ||
|
||
|
@@ -15,7 +22,7 @@ def test_activity(): | |
|
||
# Out test case is a function that increments a value, genius. | ||
# (needs a list to increase the actual value by reference and not create a copy) | ||
test_value = [0] | ||
test_val = [0] | ||
|
||
async def func(args): | ||
for _ in range(10): | ||
|
@@ -28,10 +35,11 @@ async def func(args): | |
) | ||
|
||
# Run the activity | ||
sim.perform_activity("Testing", activity_func_args=[test_value]) | ||
sim.perform_activity("Testing", activity_func_args=[test_val]) | ||
await wait_for_activity(sim) | ||
|
||
# Check activity result | ||
assert test_value[0] == 10 | ||
assert test_val[0] == 10 | ||
|
||
# Check power was depleted as expected | ||
# Activity should run roughly 2s | ||
|
@@ -41,7 +49,8 @@ async def func(args): | |
assert sat1.battery_level_in_Ws > 480 and sat1.battery_level_in_Ws < 490 | ||
|
||
|
||
def test_running_two_activities(): | ||
@pytest.mark.asyncio | ||
async def test_running_two_activities(): | ||
"""This test ensures that you cannot run two activities at the same time.""" | ||
sim, sat1, earth = get_default_instance() | ||
|
||
|
@@ -63,12 +72,14 @@ async def act2(args): | |
|
||
# try running it | ||
sim.perform_activity("act1", activity_func_args=[test_value]) | ||
await wait_for_activity(sim) | ||
|
||
# Value should be 42 as first activity is started but then an error occurs trying the second | ||
assert test_value[0] == 42 | ||
|
||
|
||
def test_activity_constraints(): | ||
@pytest.mark.asyncio | ||
async def test_activity_constraints(): | ||
"""Tests if creating a constraint function to be satisfied during an activity works. | ||
Here we start a function that counts up until we stop charging our solar panels and then prints the value. | ||
""" | ||
|
@@ -112,12 +123,7 @@ async def on_termination(args): | |
constraint_func_args=[sat1], | ||
termination_func_args=[test_value, test_value2], | ||
) | ||
await wait_for_activity(sim) | ||
|
||
assert test_value == test_value2 | ||
assert sat1.battery_level_in_Ws >= 505 | ||
|
||
|
||
if __name__ == "__main__": | ||
test_running_two_activities() | ||
test_activity() | ||
test_activity_constraints() |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls remove the file paseos/resources/.DS_Store