Esempio n. 1
0
    def test_missing_parameter(self, yaml_fn):
        params = ['phi', 'sigma', 'alpha', 'Lambda_prime']

        with open(yaml_fn, 'w') as fh:
            fh.write('medium_type: eqf\n')
            for p in params:
                fh.write('{}: 42\n'.format(p))

        with pytest.raises(LookupError):
            from_yaml(yaml_fn)
Esempio n. 2
0
    def test_ok_loading_fluid(self, yaml_fn):
        params = ['rho', 'c']

        with open(yaml_fn, 'w') as fh:
            fh.write('medium_type: fluid\n')
            for ii, p in enumerate(params):
                fh.write('{}: {}\n'.format(p, ii))

        medium = from_yaml(yaml_fn)
        for ii, p in enumerate(params):
            assert getattr(medium, p) == ii
Esempio n. 3
0
    def test_ok_loading_eqf_withoutopts(self, yaml_fn):
        params = ['phi', 'sigma', 'alpha', 'Lambda_prime', 'Lambda']

        with open(yaml_fn, 'w') as fh:
            fh.write('medium_type: eqf\n')
            for ii, p in enumerate(params):
                fh.write('{}: {}\n'.format(p, ii))

        medium = from_yaml(yaml_fn)
        for ii, p in enumerate(params):
            assert getattr(medium, p) == ii
Esempio n. 4
0
    def test_ok_loading_pem(self, yaml_fn):
        params = [
            'phi', 'sigma', 'alpha', 'Lambda_prime', 'Lambda', 'rho_1', 'nu',
            'E', 'eta', 'loss_type'
        ]

        with open(yaml_fn, 'w') as fh:
            fh.write('medium_type: pem\n')
            for ii, p in enumerate(params):
                if p != 'loss_type':
                    fh.write('{}: {}\n'.format(p, ii))
                else:
                    fh.write('{}: structural\n'.format(p))

        medium = from_yaml(yaml_fn)
        for ii, p in enumerate(params):
            if p != 'loss_type':
                assert getattr(medium, p) == ii
            else:
                assert getattr(medium, p) == 'structural'
Esempio n. 5
0
    def test_bad_medium_type(self, yaml_fn):
        with open(yaml_fn, 'w') as fh:
            fh.write('medium_type: phony_medium\n')

        with pytest.raises(ValueError):
            from_yaml(yaml_fn)
Esempio n. 6
0
    def test_file_not_found(self, tmpdir):

        with pytest.raises(IOError):
            from_yaml(tmpdir.join('inexistent.yaml').strpath)