コード例 #1
0
    def test_complex_lookup_config_is_supplied___correct_instance_is_created_with_correct_config_path(self, supplier,
                                                                                                      model, version,
                                                                                                      complex_lookup_data):
        with TemporaryDirectory() as d:
            keys_path = os.path.join(d, 'keys')
            os.mkdir(keys_path)

            version_path = os.path.join(d, 'version.csv')
            self.write_version_file(supplier, model, version, version_path)

            module_path = os.path.join(d, '{}_lookup.py'.format(model))
            self.write_py_module(model, module_path)

            complex_lookup_config_path = os.path.join(d, 'lookup_config.json'.format(model))
            self.write_complex_config_file(complex_lookup_data, complex_lookup_config_path)

            output_directory = os.path.join(d, 'output')
            os.mkdir(output_directory)

            _, instance = olf.create(
                model_keys_data_path=keys_path,
                model_version_file_path=version_path,
                lookup_module_path=module_path,
                complex_lookup_config_fp=complex_lookup_config_path,
                output_directory=output_directory
            )

            self.assertEqual(type(instance).__name__, '{}KeysLookup'.format(model))
            self.assertEqual(instance.supplier, supplier)
            self.assertEqual(instance.model_name, model)
            self.assertEqual(instance.model_version, version)
            self.assertEqual(instance.keys_data_directory, keys_path)
            self.assertEqual(instance.complex_lookup_config_fp, complex_lookup_config_path)
            self.assertEqual(instance.output_directory, output_directory)
コード例 #2
0
    def test_model_version_file_path_not_supplied___correct_exception_raised(
            self, model):
        with TemporaryDirectory() as d:
            module_path = os.path.join(d, '{}_lookup.py'.format(model))
            self.write_py_module(model, module_path)

            with self.assertRaisesRegexp(
                    OasisException,
                    r"Unable to get model version data without model_version_file_path"
            ):
                _, instance = olf.create(lookup_package_path=module_path)
コード例 #3
0
    def test_lookup_package_path_not_supplied___correct_exception_raised(
            self, supplier, model, version):
        with TemporaryDirectory() as d:
            version_path = os.path.join(d, 'version.csv')
            self.write_version_file(supplier, model, version, version_path)

            with self.assertRaisesRegexp(
                    OasisException,
                    r"Unable to import lookup package without lookup_package_path"
            ):
                _, instance = olf.create(model_version_file_path=version_path)
コード例 #4
0
    def test_version_file_missing___correct_exception_raised(self, model):
        with TemporaryDirectory() as d:
            version_path = os.path.join(d, 'version.csv')

            module_path = os.path.join(d, '{}_lookup.py'.format(model))
            self.write_py_module(model, module_path)

            with self.assertRaisesRegexp(
                    OasisException,
                    r"model_version_file_path does not exist.*"):
                _, instance = olf.create(model_version_file_path=version_path)
コード例 #5
0
ファイル: test_lookup.py プロジェクト: zejiang-unsw/OasisLMF
    def test_lookup_package_path_missing___correct_exception_raised(
            self, supplier, model, version):
        with TemporaryDirectory() as d:
            version_path = os.path.join(d, 'version.csv')
            self.write_version_file(supplier, model, version, version_path)

            module_path = os.path.join(d, '{}_lookup.py'.format(model))

            with self.assertRaisesRegex(
                    OasisException, r"lookup_package_path does not exist.*"):
                _, instance = olf.create(model_version_file_path=version_path,
                                         lookup_package_path=module_path)
コード例 #6
0
    def test_model_version_file_path_not_supplied___correct_exception_raised(self, model):
        with TemporaryDirectory() as d:
            keys_path = os.path.join(d, 'keys')
            os.mkdir(keys_path)

            module_path = os.path.join(d, '{}_lookup.py'.format(model))
            self.write_py_module(model, module_path)

            with self.assertRaisesRegex(OasisException,
                                        r"The path None \(model_version_file_path\) is indicated as preexisting"
                                        r" but is not a valid path"):
                _, instance = olf.create(
                    model_keys_data_path=keys_path,
                    lookup_module_path=module_path
                )
コード例 #7
0
    def test_model_keys_data_path_missing___correct_exception_raised(self, supplier, model, version):
        with TemporaryDirectory() as d:
            keys_path = os.path.join(d, 'keys')

            version_path = os.path.join(d, 'version.csv')
            self.write_version_file(supplier, model, version, version_path)

            module_path = os.path.join(d, '{}_lookup.py'.format(model))
            self.write_py_module(model, module_path)

            with self.assertRaisesRegex(OasisException,
                                        r"The path .*/keys \(model_keys_data_path\) is indicated as preexisting"
                                        r" but does not exist"):
                _, instance = olf.create(
                    model_version_file_path=version_path,
                    lookup_module_path=module_path,
                    model_keys_data_path=keys_path
                )
コード例 #8
0
    def test_keys_path_not_supplied___correct_instance_is_created_with_correct_model_info_and_keys_path(self, supplier,
                                                                                                        model, version):
        with TemporaryDirectory() as d:
            version_path = os.path.join(d, 'version.csv')
            self.write_version_file(supplier, model, version, version_path)

            module_path = os.path.join(d, '{}_lookup.py'.format(model))
            self.write_py_module(model, module_path)

            _, instance = olf.create(
                model_version_file_path=version_path,
                lookup_module_path=module_path
            )

            self.assertEqual(type(instance).__name__, '{}KeysLookup'.format(model))
            self.assertEqual(instance.supplier, supplier)
            self.assertEqual(instance.model_name, model)
            self.assertEqual(instance.model_version, version)
            self.assertEqual(instance.keys_data_directory, os.path.join(os.sep, 'var', 'oasis', 'keys_data'))
            self.assertEqual(instance.complex_lookup_config_fp, None)
コード例 #9
0
ファイル: test_lookup.py プロジェクト: bbetov/OasisLMF
    def test_keys_path_is_supplied___correct_instance_is_created_with_correct_model_info_and_keys_path(self, supplier, model, version):
        with TemporaryDirectory() as d:
            keys_path = os.path.join(d, 'keys')
            os.mkdir(keys_path)

            version_path = os.path.join(d, 'version.csv')
            self.write_version_file(supplier, model, version, version_path)

            module_path = os.path.join(d, '{}_lookup.py'.format(model))
            self.write_py_module(model, module_path)

            _, instance = olf.create(
                model_keys_data_path=keys_path,
                model_version_file_path=version_path,
                lookup_package_path=module_path,
            )

            self.assertEqual(type(instance).__name__, '{}KeysLookup'.format(model))
            self.assertEqual(instance.supplier, supplier)
            self.assertEqual(instance.model_name, model)
            self.assertEqual(instance.model_version, version)
            self.assertEqual(instance.keys_data_directory, keys_path)