예제 #1
0
def test_family_mapping():
    elem_kwargs = {}
    for family_name in _CLASS_MAP:
        elem_kwargs['FamName'] = family_name
        assert find_class(elem_kwargs) is _CLASS_MAP[family_name]
        elem_kwargs['FamName'] = family_name.upper()
        assert find_class(elem_kwargs) is _CLASS_MAP[family_name]
예제 #2
0
def test_no_pass_method_warns_correctly():
    elem_kwargs = {}
    with pytest.warns(at.AtWarning):
        find_class(elem_kwargs, quiet=False)
    with pytest.warns(None) as record:
        find_class(elem_kwargs, quiet=True)
    assert len(record) is 0
예제 #3
0
def test_invalid_pass_method_warns_correctly():
    elem_kwargs = {'PassMethod': 'invalid'}
    with pytest.warns(at.AtWarning):
        find_class(elem_kwargs, quiet=False)
    with pytest.warns(None) as record:
        find_class(elem_kwargs, quiet=True)
    assert len(record) == 0
예제 #4
0
def test_invalid_class_warns_correctly():
    elem_kwargs = {'Class': 'Invalid'}
    with pytest.warns(at.AtWarning):
        find_class(elem_kwargs, quiet=False)
    with pytest.warns(None) as record:
        find_class(elem_kwargs, quiet=True)
    assert len(record) is 0
예제 #5
0
def test_class_mapping():
    elem_kwargs = {'FamName': 'fam'}
    for class_name in _CLASS_MAP:
        elem_kwargs['Class'] = class_name
        assert find_class(elem_kwargs) is _CLASS_MAP[class_name]
        elem_kwargs['Class'] = class_name.upper()
        assert find_class(elem_kwargs) is _CLASS_MAP[class_name]
예제 #6
0
def test_find_RingParam():
    elem_kwargs = {'Periodicity': 1, 'FamName': 'fam'}
    assert find_class(elem_kwargs, True) is RingParam
예제 #7
0
def test_find_Marker(elem_kwargs):
    assert find_class(elem_kwargs, True) is elements.Marker
예제 #8
0
def test_find_ThinMultipole(elem_kwargs):
    assert find_class(elem_kwargs, True) is elements.ThinMultipole
예제 #9
0
def test_find_Octupole():
    elem_kwargs = {'PolynomB': [0, 0, 0, 1], 'FamName': 'fam'}
    assert find_class(elem_kwargs, True) is elements.Octupole
예제 #10
0
def test_find_Drift():
    elem_kwargs = {'Length': 1, 'FamName': 'fam'}
    assert find_class(elem_kwargs, True) is elements.Drift
예제 #11
0
def test_find_Quadrupole(elem_kwargs):
    assert find_class(elem_kwargs, True) is elements.Quadrupole
예제 #12
0
def test_find_M66():
    elem_kwargs = {'M66': numpy.eye(6), 'FamName': 'fam'}
    assert find_class(elem_kwargs, True) is elements.M66
예제 #13
0
def test_find_Corrector():
    elem_kwargs = {'KickAngle': [0, 0], 'FamName': 'fam'}
    assert find_class(elem_kwargs, True) is elements.Corrector
예제 #14
0
def test_find_Dipole(elem_kwargs):
    assert find_class(elem_kwargs, True) is elements.Dipole
예제 #15
0
def test_find_Monitor():
    elem_kwargs = {'GCR': [1, 1, 0, 0], 'FamName': 'fam'}
    assert find_class(elem_kwargs, True) is elements.Monitor
예제 #16
0
def test_find_RFCavity(elem_kwargs):
    assert find_class(elem_kwargs, True) is elements.RFCavity
예제 #17
0
def test_find_Aperture():
    elem_kwargs = {'Limits': [-0.5, 0.5, -0.5, 0.5], 'FamName': 'fam'}
    assert find_class(elem_kwargs, True) is elements.Aperture
예제 #18
0
def test_PassMethod_mapping():
    elem_kwargs = {'FamName': 'fam'}
    for pass_method in _PASS_MAP.keys():
        elem_kwargs['PassMethod'] = pass_method
        assert find_class(elem_kwargs) == _PASS_MAP[pass_method]