Ejemplo n.º 1
0
 def setUp(self):
     os.environ[CONFIGMAP_FILE_ENVIRONMENT] = os.path.join(
         os.path.dirname(os.path.abspath(__file__)), self.file1)
     ms = MyMicroservice(path=__file__)
     self.app = ms.create_app()
     self.client = self.app.test_client()
     self.assertEqual("reload1", self.app.config["APP_NAME"])
Ejemplo n.º 2
0
 def setUp(self):
     os.environ[CONFIGMAP_FILE_ENVIRONMENT] = os.path.join(
         self.BASE_DIR, "config-tests-metrics.yml")
     ms = MyMicroservice(path=__file__)
     ms.reload_conf()
     self.app = ms.create_app()
     self.client = self.app.test_client()
Ejemplo n.º 3
0
 def setUp(self):
     os.environ[CONFIGMAP_FILE_ENVIRONMENT] = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                                           "config-tests-flask-swagger.yml")
     ms = MyMicroservice(path=__file__)
     self.app = ms.create_app()
     self.client = self.app.test_client()
     self.assertEqual("Python Microservice With Flask", self.app.config["APP_NAME"])
Ejemplo n.º 4
0
def test_configfiles(payload, configfile, status_code):
    os.environ[CONFIGMAP_FILE_ENVIRONMENT] = os.path.join(
        os.path.dirname(os.path.abspath(__file__)), configfile)
    ms = MyMicroservice(path=__file__)
    ms.reload_conf()
    app = ms.create_app()
    client = app.test_client()
    response = client.get("/")
    assert payload == app.config["APP_NAME"]
    assert status_code == response.status_code
Ejemplo n.º 5
0
 def test_import_config_without_create_app(self):
     ms1 = MyMicroservice(path=__file__)
     self.assertEqual(ms1.config.subservice1, config().subservice1)
Ejemplo n.º 6
0
 def test_singleton_inherit_conf(self):
     ms1 = Microservice(path=__file__)
     ms2 = MyMicroservice()
     self.assertEqual(ms1.config.subservice1, ms2.config.subservice1)
Ejemplo n.º 7
0
 def test_singleton_child_class(self):
     ms1 = Microservice(path=__file__)
     ms2 = MyMicroservice()
     self.assertNotEqual(ms1, ms2)