• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

top-sim / topsim / 19009196833

02 Nov 2025 07:37AM UTC coverage: 83.425% (-0.6%) from 84.047%
19009196833

Pull #58

github

myxie
REF #41: Add unittest for no HDF5 path.

Signed-off-by: myxie <contact@ryanbunney.com>
Pull Request #58: REF #41: Add commandline support for topsim experiment.

66 of 149 new or added lines in 8 files covered. (44.3%)

1 existing line in 1 file now uncovered.

2733 of 3276 relevant lines covered (83.42%)

2.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.92
/test/test_simulation.py
1
import unittest
3✔
2
import simpy
3✔
3
import logging
3✔
4
import os
3✔
5
import datetime
3✔
6
import pandas as pd
3✔
7
from pathlib import Path
3✔
8

9
from topsim.core.simulation import Simulation
3✔
10
from topsim.user.schedule.dynamic_plan import DynamicSchedulingFromPlan
3✔
11
from topsim.user.schedule.batch_allocation import BatchProcessing
3✔
12
from topsim.user.plan.static_planning import SHADOWPlanning
3✔
13
from topsim.user.plan.batch_planning import BatchPlanning
3✔
14
from topsim.user.telescope import Telescope
3✔
15

16
logging.basicConfig(level='WARNING')
3✔
17
logger = logging.getLogger(__name__)
3✔
18

19
cwd = os.getcwd()
3✔
20
CONFIG = Path(f'{cwd}/test/data/config/standard_simulation.json')
3✔
21

22

23
class TestSimulationConfig(unittest.TestCase):
3✔
24
    """
25
    docstring for TestSimulation"unittest.TestCase
26
    """
27

28
    def setUp(self):
3✔
29
        # tel = Telescope(env, buffer_obj, config, planner)
30
        self.env = simpy.Environment()
3✔
31
        self.instrument = Telescope
3✔
32
        self.timestamp = 0
3✔
33

34
    def testBasicConfig(self):
3✔
35
        simulation = Simulation(
3✔
36
            self.env,
37
            CONFIG,
38
            self.instrument,
39
            planning_model=SHADOWPlanning('heft'),
40
            scheduling=DynamicSchedulingFromPlan(),
41
            timestamp=self.timestamp
42
        )
43
        self.assertTrue(36, simulation.instrument.total_arrays)
3✔
44

45

46
# @unittest.skip
47
class TestSimulationFileOptions(unittest.TestCase):
3✔
48

49
    def setUp(self) -> None:
3✔
50
        self.env = simpy.Environment()
3✔
51
        self.output = f'test/data/output/hdf5.h5'
3✔
52

53
    def tearDown(self):
3✔
54
        if os.path.exists(self.output):
3✔
NEW
55
            os.remove(self.output)
×
56

57
    def test_simulation_produces_file(self):
3✔
58
        simulation = Simulation(
3✔
59
            self.env,
60
            CONFIG,
61
            Telescope,
62
            planning_model=SHADOWPlanning('heft'),
63
            scheduling=DynamicSchedulingFromPlan(),
64
            delay=None,
65
            timestamp=0,
66
            to_file=True,
67
            hdf5_path=self.output
68
        )
69

70
        simulation.start(runtime=60)
3✔
71
        self.assertTrue(os.path.exists(self.output))
3✔
72

73
        store = pd.HDFStore(self.output)
3✔
74
        store.close()
3✔
75
        os.remove(self.output)
3✔
76

77

78
    def test_simulation_nofile_exception(self):
3✔
79
        self.assertRaises(ValueError, Simulation,
3✔
80
            self.env,
81
            CONFIG,
82
            Telescope,
83
            planning_model=SHADOWPlanning('heft'),
84
            scheduling=DynamicSchedulingFromPlan(),
85
            delay=None,
86
            timestamp=0,
87
            to_file=True,
88
        )
89

90

91
class TestSimulationBatchProcessing(unittest.TestCase):
3✔
92
    def setUp(self) -> None:
3✔
93
        self.env = simpy.Environment()
3✔
94

95
    def test_run_batchmodel(self):
3✔
96
        simulation = Simulation(
3✔
97
            self.env,
98
            CONFIG,
99
            Telescope,
100
            planning_model=BatchPlanning('batch'),
101
            scheduling=BatchProcessing(),
102
            delay=None,
103
            timestamp=0
104
        )
105
        sim, task = simulation.start()
3✔
106
        self.assertGreater(len(sim), 0)
3✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc