Skip to content

Commit 6e96495

Browse files
duposylpyansys-ci-botjwinkle8
authored
test: update tests to use local data (#882)
Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Justin Winkler <[email protected]>
1 parent fc5b7a9 commit 6e96495

File tree

201 files changed

+97
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+97
-23
lines changed

doc/source/changelog/882.test.md

Lines changed: 1 addition & 0 deletions

doc/source/conf.py

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,13 +485,15 @@ def copy_examples_to_output_dir(app: sphinx.application.Sphinx, exception: Excep
485485
# TODO: investigate issues when using OUTPUT_EXAMPLES instead of SOURCE_EXAMPLES
486486
# https://github.com/ansys/pystk/issues/415
487487
OUTPUT_EXAMPLES = pathlib.Path(app.outdir) / "examples"
488+
OUTPUT_DATA = OUTPUT_EXAMPLES / "data"
488489
OUTPUT_IMAGES = OUTPUT_EXAMPLES / "img"
489-
for directory in [OUTPUT_EXAMPLES, OUTPUT_IMAGES]:
490+
for directory in [OUTPUT_EXAMPLES, OUTPUT_DATA, OUTPUT_IMAGES]:
490491
if not directory.exists():
491492
directory.mkdir(parents=True, exist_ok=True)
492493

493494
SOURCE_EXAMPLES = pathlib.Path(app.srcdir) / "examples"
494495
EXAMPLES_DIRECTORY = SOURCE_EXAMPLES.parent.parent.parent / "examples"
496+
EXAMPLES_DATA_DIRECTORY = EXAMPLES_DIRECTORY / "data"
495497
IMAGES_DIRECTORY = EXAMPLES_DIRECTORY / "img"
496498

497499
# Copy the examples
@@ -508,6 +510,20 @@ def copy_examples_to_output_dir(app: sphinx.application.Sphinx, exception: Excep
508510
destination_file = OUTPUT_EXAMPLES / file.name
509511
destination_file.write_text(file.read_text(encoding="utf-8"), encoding="utf-8")
510512

513+
# Copy the data files
514+
all_data_files = list(EXAMPLES_DATA_DIRECTORY.glob("*.tle"))
515+
data_files = [file for file in all_data_files]
516+
for file in status_iterator(
517+
data_files,
518+
f"Copying example data to doc/_build/examples/data",
519+
"green",
520+
len(data_files),
521+
verbosity=1,
522+
stringify_func=(lambda x: x.name),
523+
):
524+
destination_file = OUTPUT_DATA / file.name
525+
destination_file.write_text(file.read_text(encoding="utf-8"), encoding="utf-8")
526+
511527
# Copy the static images
512528
images = list(IMAGES_DIRECTORY.glob("*.png"))
513529
for file in status_iterator(
@@ -533,15 +549,17 @@ def copy_examples_files_to_source_dir(app: sphinx.application.Sphinx):
533549
534550
"""
535551
SOURCE_EXAMPLES = pathlib.Path(app.srcdir) / "examples"
552+
SOURCE_DATA = SOURCE_EXAMPLES / "data"
536553
SOURCE_IMAGES = SOURCE_EXAMPLES / "img"
537-
for directory in [SOURCE_EXAMPLES, SOURCE_IMAGES]:
554+
for directory in [SOURCE_EXAMPLES, SOURCE_DATA, SOURCE_IMAGES]:
538555
if not directory.exists():
539556
directory.mkdir(parents=True, exist_ok=True)
540557

541558
EXAMPLES_DIRECTORY = SOURCE_EXAMPLES.parent.parent.parent / "examples"
559+
EXAMPLES_DATA_DIRECTORY = EXAMPLES_DIRECTORY / "data"
542560
IMAGES_DIRECTORY = EXAMPLES_DIRECTORY / "img"
543561

544-
# Copy the the examples
562+
# Copy the examples
545563
all_examples = list(EXAMPLES_DIRECTORY.glob("*.py"))
546564
examples = [file for file in all_examples if f"{file.name}" not in exclude_examples]
547565
for file in status_iterator(
@@ -555,6 +573,20 @@ def copy_examples_files_to_source_dir(app: sphinx.application.Sphinx):
555573
destination_file = SOURCE_EXAMPLES / file.name
556574
destination_file.write_text(file.read_text(encoding="utf-8"), encoding="utf-8")
557575

576+
# Copy the data files
577+
example_data_files = list(EXAMPLES_DATA_DIRECTORY.glob("*.tle"))
578+
data_files = [file for file in example_data_files]
579+
for file in status_iterator(
580+
data_files,
581+
f"Copying example data to doc/source/examples/data/",
582+
"green",
583+
len(data_files),
584+
verbosity=1,
585+
stringify_func=(lambda file: file.name),
586+
):
587+
destination_file = SOURCE_DATA / file.name
588+
destination_file.write_text(file.read_text(encoding="utf-8"), encoding="utf-8")
589+
558590
# Copy the static images
559591
images = list(IMAGES_DIRECTORY.glob("*.png"))
560592
for file in status_iterator(

examples/communication-link-calculator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@
100100
satellite.set_propagator_type(PropagatorType.SGP4)
101101
propagator = satellite.propagator
102102

103-
# Finally, use the propagator's `common_tasks` property to add the satellite's orbit from an online source, and propagate the satellite:
103+
# Finally, use the propagator's `common_tasks` property to add the satellite's orbit from a local file, and propagate the satellite:
104104

105-
propagator.common_tasks.add_segments_from_online_source("31698")
105+
tle_file = pathlib.Path("data") / "TerraSarX_31698.tle"
106+
propagator.common_tasks.add_segments_from_file("31698", str(tle_file.resolve()))
106107
propagator.propagate()
107108

108109
# ## Add the camp site

examples/data/TerraSarX_31698.tle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1 31698U 07026A 24075.25000000 .00008923 00000-0 42574-3 0 00007
2+
2 31698 097.4466 083.7351 0001914 083.7701 301.0238 15.19143971928808
3+

examples/data/iss_5Jun2022.tle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1 25544U 98067A 22156.00000000 .00001944 00000-0 34115-4 0 00005
2+
2 25544 051.6451 036.9525 0004589 195.9534 179.2523 15.49879136343299

examples/facility-to-satellite-access.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,19 @@
136136

137137
# ### Add a satellite using the SPG4 propagator
138138

139-
# **Note:** this portion requires internet access.
140-
141-
# First, create the satellite using online data for the International Space Station (SSN number $25544$):
139+
# First, create the satellite using local data for the International Space Station (SSN number $25544$):
142140

143141
# +
142+
import pathlib
143+
144144
from ansys.stk.core.stkobjects import PropagatorType
145145

146146

147147
satellite = root.current_scenario.children.new(STKObjectType.SATELLITE, "MySatellite")
148148
satellite.set_propagator_type(PropagatorType.SGP4)
149149
propagator = satellite.propagator
150-
propagator.common_tasks.add_segments_from_online_source("25544")
150+
tle_file = pathlib.Path("data") / "iss_5Jun2022.tle"
151+
propagator.common_tasks.add_segments_from_file("25544", str(tle_file.resolve()))
151152
propagator.propagate()
152153
# -
153154

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1 47954U 21022Y 20153.75000000 .00000000 00000-0 00000-0 0 00002
2+
2 47954 097.5686 057.1838 0018941 165.4562 124.5594 15.05622178000003

tests/doc_snippets_tests/data_analysis/data_analysis_snippets.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import os
2424
import sys
2525

26+
from pathlib import Path
27+
2628

2729
# Add path to the parent directory to use some common utilities
2830
sys.path.insert(1, os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
@@ -189,7 +191,8 @@ def _create_access_scenario(self):
189191
ksu_cubesat_propagator.ephemeris_interval.set_implicit_interval(
190192
root.current_scenario.analysis_workbench_components.time_intervals.item("AnalysisInterval")
191193
)
192-
ksu_cubesat_propagator.common_tasks.add_segments_from_online_source("47954")
194+
tle_file = Path(__file__).parent.parent / "data" / "KSU-CUBESAT_47954_1Jun2020.tle"
195+
ksu_cubesat_propagator.common_tasks.add_segments_from_file("47954", str(tle_file.resolve()))
193196
ksu_cubesat_propagator.automatic_update_enabled = True
194197
ksu_cubesat_propagator.propagate()
195198

tests/doc_snippets_tests/stk_objects/satellite/satellite_snippets.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# SOFTWARE.
2222

2323
import os
24+
import pytest
2425
import sys
2526

2627
from ansys.stk.core.stkobjects import (
@@ -244,6 +245,7 @@ def SPICESatelliteSnippet(self, root, satellite):
244245
propagator.step = 60.0
245246
propagator.propagate()
246247

248+
@pytest.mark.skip(reason="Temporarily disabled due to connectivity.")
247249
def test_SGP4SatelliteSnippet(self):
248250
try:
249251
satellite = self.get_scenario().children.new(STKObjectType.SATELLITE, "satellite")
-547 Bytes

0 commit comments

Comments
 (0)