def test_constructor():
    body = Body(399)
    assert body.id == 399
    assert body.name == 'EARTH'
    pytest.raises(ValueError, Body, 398)
    pytest.raises(TypeError, Body, 399.5)
    with pytest.raises(AttributeError):
        body.id = 10
    with pytest.raises(AttributeError):
        body.name = 'MARS'
Exemple #2
0
 def test_rotation(self, idcode, times):
     cols = self._cols(times)
     body = Body(idcode)
     data = body.rotation(times)
     assert len(data) == 2
     assert len(data[0]) == cols
     assert data[0].dtype == float
     for matrix in data[1]:
         assert matrix.shape == (3, 3)
         assert matrix.dtype == float
Exemple #3
0
def test_constructor(idcode, name, children, parent, class_):
    # constructor and cache
    assert idcode not in Body._CACHE
    body = Body(idcode)
    assert idcode in Body._CACHE
    assert body is Body._CACHE[idcode]
    assert Body(idcode) is body
    assert type(body) is class_
    # properties
    assert body.id == idcode
    assert body.name == name
    with pytest.raises(AttributeError):
        body.id = idcode
    with pytest.raises(AttributeError):
        body.name = name
    # parent/children
    try:
        assert body.parent().id == parent
    except AttributeError:
        assert type(body) is bodies.Barycenter
        assert body.parent() is None
    assert [child.id for child in body.children()] == children
Exemple #4
0
 def test_position(self, idcode, times):
     cols = self._cols(times)
     body = Body(idcode)
     data = body.position(times)
     assert data.shape == (4, cols)
     assert data.dtype == float
Exemple #5
0
 def test_state(self, idcode, times):
     cols = self._cols(times)
     body = Body(idcode)
     data = body.state(times)
     assert data.shape == (8, cols)
     assert data.dtype == float