def test_family_mapping(): elem_kwargs = {} for family_name in CLASS_MAPPING: elem_kwargs['FamName'] = family_name assert find_class_name(elem_kwargs) == CLASS_MAPPING[family_name] elem_kwargs['FamName'] = family_name.upper() assert find_class_name(elem_kwargs) == CLASS_MAPPING[family_name]
def test_class_mapping(): elem_kwargs = {'FamName': 'fam'} for class_name in CLASS_MAPPING: elem_kwargs['Class'] = class_name assert find_class_name(elem_kwargs) == CLASS_MAPPING[class_name] elem_kwargs['Class'] = class_name.upper() assert find_class_name(elem_kwargs) == CLASS_MAPPING[class_name]
def test_find_Monitor(): elem_kwargs = {'GCR': [1, 1, 0, 0], 'FamName': 'fam'} assert find_class_name(elem_kwargs) == 'Monitor'
def test_invalid_class_warns_when_quiet_is_False(): elem_kwargs = {'Class': 'Invalid'} with pytest.warns(at.AtWarning): find_class_name(elem_kwargs, quiet=False)
def test_find_RFCavity(elem_kwargs): assert find_class_name(elem_kwargs) == 'RFCavity'
def test_find_Aperture(): elem_kwargs = {'Limits': [-0.5, 0.5, -0.5, 0.5], 'FamName': 'fam'} assert find_class_name(elem_kwargs) == 'Aperture'
def test_PassMethod_mapping(): elem_kwargs = {'FamName': 'fam'} for pass_method in PASS_MAPPING.keys(): elem_kwargs['PassMethod'] = pass_method assert find_class_name(elem_kwargs) == PASS_MAPPING[pass_method]
def test_find_M66(): elem_kwargs = {'M66': numpy.eye(6), 'FamName': 'fam'} assert find_class_name(elem_kwargs) == 'M66'
def test_find_Marker(elem_kwargs): assert find_class_name(elem_kwargs) == 'Marker'
def test_find_ThinMultipole(elem_kwargs): assert find_class_name(elem_kwargs) == 'ThinMultipole'
def test_find_Octupole(): elem_kwargs = {'PolynomB': [0, 0, 0, 1], 'FamName': 'fam'} assert find_class_name(elem_kwargs) == 'Octupole'
def test_find_Drift(): elem_kwargs = {'Length': 1, 'FamName': 'fam'} assert find_class_name(elem_kwargs) == 'Drift'
def test_invalid_class_does_not_warn_when_quiet_is_True(): elem_kwargs = {'Class': 'Invalid'} with pytest.warns(None) as record: find_class_name(elem_kwargs, quiet=True) assert len(record) is 0
def test_find_Quadrupole(elem_kwargs): assert find_class_name(elem_kwargs) == 'Quadrupole'
def test_find_Dipole(elem_kwargs): assert find_class_name(elem_kwargs) == 'Dipole'
def test_find_Corrector(): elem_kwargs = {'KickAngle': [0, 0], 'FamName': 'fam'} assert find_class_name(elem_kwargs) == 'Corrector'
def test_find_RingParam(): elem_kwargs = {'Periodicity': 1, 'FamName': 'fam'} assert find_class_name(elem_kwargs) == 'RingParam'