Coverage for tests/core.py: 100%
26 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 10:31 +0900
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 10:31 +0900
1import pytest
2import rebound
3import airball
4import airball.units as u
5import numpy as np
7################################################
8################################################
9########## INITIALIZATION TESTS ##############
10################################################
11################################################
13def test_add_star():
14 star = airball.Star(m=0, b=1, v=1, inc=0, omega=0, Omega=0)
15 sim = rebound.Simulation()
16 sim.add(m=1)
17 airball.add_star_to_sim(sim, star, rmax=1e5, hash='star')
18 assert sim.N == 2
20def test_add_star_to_empty_sim():
21 star = airball.Star(m=0, b=1, v=1, inc=0, omega=0, Omega=0)
22 sim = rebound.Simulation()
23 with pytest.raises(AttributeError):
24 airball.add_star_to_sim(sim, star, rmax=1e5, hash='star')
26def test_remove_star():
27 sim = rebound.Simulation()
28 with pytest.raises(RuntimeError):
29 airball.core.remove_star_from_sim(sim, 'star')
32################################################
33################################################
34############# FLYBY TESTS ####################
35################################################
36################################################
38def test_basic_flyby():
39 star = airball.Star(m=0, b=1, v=1, inc=0, omega=0, Omega=0)
40 sim = rebound.Simulation()
41 sim.add(m=1)
42 simout = airball.flyby(sim, star)
43 assert sim.N == simout.N