Exemplo n.º 1
0
    def setup(self):
        self.arguments = Argument(name="TestSimulation",description="An argument used in the TestSimulation class",data={"test":"TestSimulation"})
        
        self.simulation = Simulation(self.arguments)

        self.session.add(self.arguments)
        self.session.add(self.simulation)
        self.session.commit()
Exemplo n.º 2
0
class TestSimulation(DatabaseTest):
    def setup(self):
        self.arguments = Argument(name="TestSimulation",description="An argument used in the TestSimulation class",data={"test":"TestSimulation"})
        
        self.simulation = Simulation(self.arguments)

        self.session.add(self.arguments)
        self.session.add(self.simulation)
        self.session.commit()

    def test_range_kernel_presim(self):
        presim = PreSimRangeTest()
        self.simulation.kernels.append(presim)

        presim.execute(self.simulation.arguments,self.simulation.diagnostics)

        assert self.simulation.diagnostics["counter"].data == 0

        assert self.simulation.arguments["range"].validate(5)

    def test_range_simulation(self):
        presim = PreSimRangeTest()
        presim.description = "PreSimulateKernel used in TestSimulation"
        sim = SimRangeTest()
        sim.description = "SimulateKernel used in TestSimulation"
        postsim = PostSimRangeTest()
        postsim.description = "PostSimulateKernel used in TestSimulation"

        self.simulation.kernels.append(presim)
        self.simulation.kernels.append(sim)
        self.simulation.kernels.append(postsim)

        self.simulation.steps = 20

        self.session.add(presim)
        self.session.add(sim)
        self.session.add(postsim)
        self.session.commit()

        print("-----RUNNING TEST SIMULATION-----")
        self.simulation.run()
        print("-----END TEST SIMULATION-----")

        self.session.commit()

        assert self.simulation.diagnostics["counter"].data == 14