Exemplo n.º 1
0
    def test_custom_path(self):
        default_path = pathlib.Path(GravityModel.default_gravity_path())
        with tempfile.TemporaryDirectory() as dirname:
            gravity_model_path = pathlib.Path(dirname) / default_path.name
            gravity_model_path.mkdir()
            for filename in default_path.glob(f'{self.MODEL_NAME}*'):
                shutil.copy(filename, gravity_model_path)

            model = GravityModel(self.MODEL_NAME, gravity_model_path)
            self.assertEqual(model.gravity_model_name(), self.MODEL_NAME)
            self.assertEqual(model.gravity_model_directory(),
                             str(gravity_model_path))
Exemplo n.º 2
0
    def test_custom_path_from_env02(self):
        default_path = pathlib.Path(GravityModel.default_gravity_path())
        with tempfile.TemporaryDirectory() as dirname:
            gravity_model_path = pathlib.Path(dirname) / default_path.name
            gravity_model_path.mkdir()
            for filename in default_path.glob(f'{self.MODEL_NAME}*'):
                shutil.copy(filename, gravity_model_path)

            old_env = os.environ.get('GEOGRAPHICLIB_GRAVITY_PATH')
            os.environ['GEOGRAPHICLIB_GRAVITY_PATH'] = str(gravity_model_path)
            try:
                model = GravityModel(self.MODEL_NAME)
                self.assertEqual(model.gravity_model_name(), self.MODEL_NAME)
                self.assertEqual(model.gravity_model_directory(),
                                 str(gravity_model_path))
            finally:
                if old_env is None:
                    del os.environ['GEOGRAPHICLIB_GRAVITY_PATH']
                else:
                    os.environ['GEOGRAPHICLIB_GRAVITY_PATH'] = old_env
Exemplo n.º 3
0
 def setUp(self) -> None:
     self.model = GravityModel(self.MODEL_NAME)
Exemplo n.º 4
0
 def test_default_path(self):
     path = GravityModel.default_gravity_path()
     model = GravityModel(self.MODEL_NAME, path)
     self.assertEqual(model.gravity_model_name(), self.MODEL_NAME)
     self.assertEqual(model.gravity_model_directory(), path)
Exemplo n.º 5
0
 def test_name(self):
     model = GravityModel(self.MODEL_NAME)
     self.assertIsInstance(model, GravityModel)
     self.assertEqual(model.gravity_model_name(), self.MODEL_NAME)
Exemplo n.º 6
0
 def test_no_args(self):
     model = GravityModel()
     self.assertIsInstance(model, GravityModel)
     self.assertEqual(model.gravity_model_name(),
                      GravityModel.default_gravity_name())
Exemplo n.º 7
0
 def setUp(self) -> None:
     self.name = GravityModel.default_gravity_name()
     self.datapath = GravityModel.default_gravity_path()
     self.model = GravityModel(self.name, self.datapath)