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]
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
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
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
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]
def test_find_RingParam(): elem_kwargs = {'Periodicity': 1, 'FamName': 'fam'} assert find_class(elem_kwargs, True) is RingParam
def test_find_Marker(elem_kwargs): assert find_class(elem_kwargs, True) is elements.Marker
def test_find_ThinMultipole(elem_kwargs): assert find_class(elem_kwargs, True) is elements.ThinMultipole
def test_find_Octupole(): elem_kwargs = {'PolynomB': [0, 0, 0, 1], 'FamName': 'fam'} assert find_class(elem_kwargs, True) is elements.Octupole
def test_find_Drift(): elem_kwargs = {'Length': 1, 'FamName': 'fam'} assert find_class(elem_kwargs, True) is elements.Drift
def test_find_Quadrupole(elem_kwargs): assert find_class(elem_kwargs, True) is elements.Quadrupole
def test_find_M66(): elem_kwargs = {'M66': numpy.eye(6), 'FamName': 'fam'} assert find_class(elem_kwargs, True) is elements.M66
def test_find_Corrector(): elem_kwargs = {'KickAngle': [0, 0], 'FamName': 'fam'} assert find_class(elem_kwargs, True) is elements.Corrector
def test_find_Dipole(elem_kwargs): assert find_class(elem_kwargs, True) is elements.Dipole
def test_find_Monitor(): elem_kwargs = {'GCR': [1, 1, 0, 0], 'FamName': 'fam'} assert find_class(elem_kwargs, True) is elements.Monitor
def test_find_RFCavity(elem_kwargs): assert find_class(elem_kwargs, True) is elements.RFCavity
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
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]