Skip to content

Commit

Permalink
feat: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwa2710 committed Jan 4, 2025
1 parent 57251f3 commit 91d8fb6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
18 changes: 12 additions & 6 deletions bindings/python/test/access/test_visibility_criterion.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,15 @@ def test_aer_interval_is_satisfied(
aer_interval = VisibilityCriterion.AERInterval(
azimuth_interval, elevation_interval, range_interval
)
aer = AER(azimuth=np.pi / 4, elevation=np.pi / 8, range=5e6)
assert aer_interval.is_satisfied(aer) is True
assert (
aer_interval.is_satisfied(azimuth=np.pi / 4, elevation=np.pi / 8, range=5e6)
is True
)

aer_invalid = AER(azimuth=np.pi, elevation=np.pi / 2, range=1e8)
assert aer_interval.is_satisfied(aer_invalid) is False
assert (
aer_interval.is_satisfied(azimuth=np.pi, elevation=np.pi / 2, range=1e8)
is False
)

def test_elevation_interval_is_satisfied(
self,
Expand All @@ -159,8 +163,10 @@ def test_line_of_sight_is_satisfied(
):
line_of_sight = VisibilityCriterion.LineOfSight(environment)
instant = Instant.now()
from_position = np.array([7000e3, 0.0, 0.0]) # 7000 km altitude
to_position = np.array([0.0, 7000e3, 0.0]) # 7000 km altitude

from_position = np.array([7000e3, 0.0, 0.0])
to_position = np.array([7005e3, 0.0, 0.0])

assert line_of_sight.is_satisfied(instant, from_position, to_position) is True

def test_visibility_criterion_type_checks(
Expand Down
10 changes: 9 additions & 1 deletion bindings/python/test/solvers/test_temporal_condition_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from ostk.astrodynamics.trajectory.orbit.model.kepler import COE
from ostk.astrodynamics.access import Generator
from ostk.astrodynamics.solver import TemporalConditionSolver
from ostk.astrodynamics.access import AccessTarget
from ostk.astrodynamics.access import VisibilityCriterion


@pytest.fixture
Expand Down Expand Up @@ -141,9 +143,15 @@ def test_solve_success_using_access_generator(
celestial_object=earth,
)

visibility_criterion: VisibilityCriterion = (
VisibilityCriterion.from_line_of_sight(environment)
)

access_target = AccessTarget.from_trajectory(visibility_criterion, trajectory)

solution: list[Interval] = temporal_condition_solver.solve(
condition=generator.get_condition_function(
from_trajectory=trajectory,
access_target=access_target,
to_trajectory=trajectory,
),
interval=interval,
Expand Down
14 changes: 10 additions & 4 deletions bindings/python/test/test_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
from ostk.physics.unit import Length
from ostk.physics.unit import Angle

from ostk.astrodynamics import Trajectory
from ostk.astrodynamics import display
from ostk.astrodynamics.access import Generator as AccessGenerator
from ostk.astrodynamics.trajectory import Orbit
from ostk.astrodynamics.trajectory.orbit.model import SGP4
from ostk.astrodynamics.trajectory.orbit.model.sgp4 import TLE
from ostk.astrodynamics.access import AccessTarget
from ostk.astrodynamics.access import VisibilityCriterion


class TestDisplay:
Expand Down Expand Up @@ -52,7 +53,12 @@ def test_accesses_plot(self):
environment: Environment = Environment.default()
earth: Celestial = environment.access_celestial_object_with_name("Earth")

ground_station_trajectory: Trajectory = Trajectory.position(
visibility_criterion: VisibilityCriterion = (
VisibilityCriterion.from_line_of_sight(environment)
)

access_target: AccessTarget = AccessTarget.from_position(
visibility_criterion,
Position.meters(
ground_station_lla.to_cartesian(
earth.get_equatorial_radius(),
Expand All @@ -76,15 +82,15 @@ def test_accesses_plot(self):

accesses_1 = generator.compute_accesses(
interval=search_interval,
from_trajectory=ground_station_trajectory,
access_target=access_target,
to_trajectory=orbit_1,
)

assert len(accesses_1) > 0

accesses_2 = generator.compute_accesses(
interval=search_interval,
from_trajectory=ground_station_trajectory,
access_target=access_target,
to_trajectory=orbit_2,
)

Expand Down

0 comments on commit 91d8fb6

Please sign in to comment.