Skip to content
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

Implements flight route tests #41

Merged
merged 3 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ $ touch .env && echo MONGODB_CONNECTION_STRING="$ConnectionString" > .env
│   ├── test_motor_service.py
│   └── test_rocket_serice.py
├── test_routes
│   ├── test_environment_route.py
│   ├── test_flight_route.py
│   ├── test_motor_route.py
│   └── test_rocket_route.py
├── test_repositories
│   ├── test_environment_repo.py
│   ├── test_flight_repo.py
Expand Down Expand Up @@ -167,14 +161,14 @@ sequenceDiagram
participant MongoDB
participant Rocketpy lib

User ->> API: POST /summary/model/:id
User ->> API: GET /summary/model/:id
API -->> MongoDB: Retrieve Rocketpy native class
MongoDB -->> API: Rocketpy native class
API ->> Rocketpy lib: Simulate Rocketpy native class
Rocketpy lib -->> API: Simulation Results
API -->> User: Simulation Results

User ->> API: POST /model/:id/rocketpy
User ->> API: GET /model/:id/rocketpy
API -->> MongoDB: Retrieve Rocketpy Model
MongoDB -->> API: Rocketpy Model
API ->> Rocketpy lib: Rocketpy Model
Expand Down
1 change: 1 addition & 0 deletions lib/models/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class CoordinateSystemOrientation(str, Enum):


class Rocket(BaseModel):

# Required parameters
motor: Motor
radius: float
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ disable = """
broad-exception-caught,
raise-missing-from,
too-many-instance-attributes,
redefined-outer-name,
import-error,
too-many-arguments,
redefined-outer-name,
Expand Down
95 changes: 95 additions & 0 deletions tests/test_routes/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import json
import pytest

from lib.models.rocket import Rocket
from lib.models.motor import Motor, MotorTank, TankFluids, TankKinds
from lib.models.environment import Env


@pytest.fixture
def stub_env():
env = Env(latitude=0, longitude=0)
env_json = env.model_dump_json()
return json.loads(env_json)
phmbressan marked this conversation as resolved.
Show resolved Hide resolved


@pytest.fixture
def stub_motor():
motor = Motor(
thrust_source=[[0, 0]],
burn_time=0,
nozzle_radius=0,
dry_mass=0,
dry_inertia=[0, 0, 0],
center_of_dry_mass_position=0,
)
motor_json = motor.model_dump_json()
return json.loads(motor_json)


@pytest.fixture
def stub_tank():
tank = MotorTank(
geometry=[[(0, 0), 0]],
gas=TankFluids(name='gas', density=0),
liquid=TankFluids(name='liquid', density=0),
flux_time=(0, 0),
position=0,
discretize=0,
name='tank',
)
tank_json = tank.model_dump_json()
return json.loads(tank_json)


@pytest.fixture
def stub_level_tank(stub_tank):
stub_tank.update({'tank_kind': TankKinds.LEVEL, 'liquid_height': 0})
return stub_tank
GabrielBarberini marked this conversation as resolved.
Show resolved Hide resolved


@pytest.fixture
def stub_mass_flow_tank(stub_tank):
stub_tank.update(
{
'tank_kind': TankKinds.MASS_FLOW,
'gas_mass_flow_rate_in': 0,
'gas_mass_flow_rate_out': 0,
'liquid_mass_flow_rate_in': 0,
'liquid_mass_flow_rate_out': 0,
'initial_liquid_mass': 0,
'initial_gas_mass': 0,
}
)
return stub_tank


@pytest.fixture
def stub_ullage_tank(stub_tank):
stub_tank.update({'tank_kind': TankKinds.ULLAGE, 'ullage': 0})
return stub_tank


@pytest.fixture
def stub_mass_tank(stub_tank):
stub_tank.update(
{'tank_kind': TankKinds.MASS, 'liquid_mass': 0, 'gas_mass': 0}
)
return stub_tank


@pytest.fixture
def stub_rocket(stub_motor):
rocket = Rocket(
motor=stub_motor,
radius=0,
mass=0,
motor_position=0,
center_of_mass_without_motor=0,
inertia=[0, 0, 0],
power_off_drag=[(0, 0)],
power_on_drag=[(0, 0)],
coordinate_system_orientation='TAIL_TO_NOSE',
)
rocket_json = rocket.model_dump_json()
return json.loads(rocket_json)
7 changes: 0 additions & 7 deletions tests/test_routes/test_environments_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
client = TestClient(app)


@pytest.fixture
def stub_env():
env = Env(latitude=0, longitude=0)
env_json = env.model_dump_json()
return json.loads(env_json)


@pytest.fixture
def stub_env_summary():
env_summary = EnvSummary()
Expand Down
Loading
Loading