Skip to content

Commit

Permalink
refactors environment_fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielBarberini committed Mar 7, 2024
1 parent 5657c90 commit 7d79b7f
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions tests/fixtures/environment/environment_fixtures.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import datetime

import pytest

import os
from datetime import datetime, timedelta
from rocketpy import Environment, EnvironmentAnalysis


@pytest.fixture
def example_env():
def example_plain_env():
"""Simple object of the Environment class to be used in the tests.
Returns
Expand All @@ -24,43 +23,35 @@ def example_date_naive():
-------
datetime.datetime
"""
return datetime.datetime.now()
return datetime.now() + timedelta(days=1)


@pytest.fixture
def example_env_robust():
"""Create an object of the Environment class to be used in the tests. This
allows to avoid repeating the same code in all tests. The environment set
here is a bit more complex than the one in the example_env fixture. This
time the latitude, longitude and elevation are set, as well as the datum and
the date. The location refers to the Spaceport America Cup launch site,
while the date is set to tomorrow at noon.
def example_spaceport_env(example_date_naive):
"""Environment class with location set to Spaceport America Cup launch site
Returns
-------
rocketpy.Environment
An object of the Environment class
"""
env = Environment(
spaceport_env = Environment(
latitude=32.990254,
longitude=-106.974998,
elevation=1400,
datum="WGS84",
)
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
env.set_date((tomorrow.year, tomorrow.month, tomorrow.day, 12))
return env
spaceport_env.set_date(example_date_naive)
yield spaceport_env
os.remove("environment.json")


@pytest.fixture
def env_analysis():
"""Create a simple object of the Environment Analysis class to be used in
the tests. This allows to avoid repeating the same code in all tests.
"""Environment Analysis class with hardcoded parameters
Returns
-------
EnvironmentAnalysis
A simple object of the Environment Analysis class
"""
env_analysis = EnvironmentAnalysis(
start_date=datetime.datetime(2019, 10, 23),
Expand Down

0 comments on commit 7d79b7f

Please sign in to comment.