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 rocket route tests #40

Merged
merged 5 commits into from
Nov 23, 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
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
pip install -r requirements.txt
- name: Analysing the code with pylint
run: |
pylint -d C0200,C0301,C0114,R0903,C0115,W0246,R0914,C0209,E1121,C0103,C2801,R0801,E1101,E0401,E0611,R0911,C0116,W0212,W0719,W0601,W1203,W0123,W0511,W0621 $(git ls-files '*.py')
pylint -d C0200,C0301,C0114,R0903,C0115,W0246,R0914,C0209,E1121,C0103,C2801,R0801,E1101,E0401,E0611,R0911,C0116,W0212,W0719,W0601,W1203,W0123,W0511,W0621,R0913,R0917 $(git ls-files '*.py')
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
format: black flake8 pylint ruff
format: black ruff
lint: flake8 pylint

black:
black ./lib || true
Expand All @@ -10,7 +11,7 @@ flake8:

pylint:
pylint ./lib || true
pylint --disable=E0401,W0621 ./tests || true
pylint ./tests || true

ruff:
ruff check --fix ./lib || true
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ sequenceDiagram
Rocketpy lib -->> API: Simulation Results
API -->> User: Simulation Results

User ->> API: POST /rocketpy/model/:id
User ->> API: POST /model/:id/rocketpy
API -->> MongoDB: Retrieve Rocketpy Model
MongoDB -->> API: Rocketpy Model
API ->> Rocketpy lib: Rocketpy Model
Expand Down
2 changes: 1 addition & 1 deletion lib/controllers/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ async def get_rocketpy_flight_binary(

@classmethod
async def update_flight_by_id(
cls, flight: Flight, flight_id: str
cls, flight_id: str, flight: Flight
) -> Union[FlightUpdated, HTTPException]:
"""
Update a models.Flight in the database.
Expand Down
2 changes: 1 addition & 1 deletion lib/controllers/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ async def get_rocketpy_rocket_binary(

@classmethod
async def update_rocket_by_id(
cls, rocket: Rocket, rocket_id: str
cls, rocket_id: str, rocket: Rocket
) -> Union[RocketUpdated, HTTPException]:
"""
Update a models.Rocket in the database.
Expand Down
13 changes: 11 additions & 2 deletions lib/models/aerosurfaces.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
from enum import Enum
from typing import Optional, Tuple, List
from pydantic import BaseModel
from typing import Optional, Tuple, List, Union
from pydantic import BaseModel, Field


class Parachute(BaseModel):
name: str
cd_s: float = Field(..., ge=0, description="Must be non-negative")
sampling_rate: float = Field(..., gt=0, description="Must be positive")
lag: float = Field(..., ge=0, description="Must be non-negative")
trigger: Union[str, float]
noise: Tuple[float, float, float]
GabrielBarberini marked this conversation as resolved.
Show resolved Hide resolved


class RailButtons(BaseModel):
Expand Down
10 changes: 1 addition & 9 deletions lib/models/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
NoseCone,
Tail,
RailButtons,
Parachute,
)


Expand All @@ -15,15 +16,6 @@ class CoordinateSystemOrientation(str, Enum):
NOSE_TO_TAIL: str = "NOSE_TO_TAIL"


class Parachute(BaseModel):
name: str
cd_s: float
sampling_rate: int
lag: float
trigger: Union[str, float]
noise: Tuple[float, float, float]


class Rocket(BaseModel):
# Required parameters
motor: Motor
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async def read_flight(flight_id: str) -> FlightView:


@router.get(
"/rocketpy/{flight_id}",
"/{flight_id}/rocketpy",
responses={
203: {
"description": "Binary file download",
Expand Down Expand Up @@ -146,7 +146,7 @@ async def update_flight(
"""
with tracer.start_as_current_span("update_flight"):
flight.rocket.motor.set_motor_kind(motor_kind)
return await FlightController.update_flight_by_id(flight, flight_id)
return await FlightController.update_flight_by_id(flight_id, flight)


@router.get("/{flight_id}/summary")
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ async def update_rocket(
"""
with tracer.start_as_current_span("update_rocket"):
rocket.motor.set_motor_kind(motor_kind)
return await RocketController.update_rocket_by_id(rocket, rocket_id)
return await RocketController.update_rocket_by_id(rocket_id, rocket)


@router.get(
"/rocketpy/{rocket_id}",
"/{rocket_id}/rocketpy",
GabrielBarberini marked this conversation as resolved.
Show resolved Hide resolved
responses={
203: {
"description": "Binary file download",
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ disable = """
broad-exception-caught,
raise-missing-from,
too-many-instance-attributes,
redefined-outer-name,
GabrielBarberini marked this conversation as resolved.
Show resolved Hide resolved
import-error,
too-many-arguments,
redefined-outer-name,
too-many-positional-arguments,
"""

[tool.ruff]
Expand Down
Loading
Loading