Example #1
0
    def test_should_create_env(self):
        app = Application(name="lms").save()

        app.create_env("usc-mat-sb01")

        env_from_db = AppEnvironment.objects(app=app)[0]

        self.assertIsNotNone(env_from_db)
Example #2
0
    def test_should_get_env(self):
        app = Application(name="lms").save()
        env = AppEnvironment(name="usc-mat-sb01", app=app).save()

        env_from_db = app.get_env("usc-mat-sb01")
        self.assertIsNotNone(env_from_db)

        env_from_db = app.get_env("non-existent-env")
        self.assertIsNone(env_from_db)
Example #3
0
    def test_should_return_true_if_key_exists(self):
        app = Application(name="lms").save()
        env = AppEnvironment(name="usc-mat-sb01", app=app).save()
        env.put_value("adobe_host", "foobar.com")

        env_from_db = AppEnvironment.objects(app=app)[0]
        self.assertTrue(env_from_db.has_key("adobe_host"))
Example #4
0
    def test_should_get_value(self):
        app = Application(name="lms").save()
        env = AppEnvironment(name="usc-mat-sb01", app=app).save()
        env.put_value("adobe_host", "foobar.com")

        env_from_db = AppEnvironment.objects(app=app)[0]
        self.assertEquals("foobar.com", env_from_db.get_value("adobe_host"))
Example #5
0
 def get_env(self, app_name, env_name):
     app = Application.find(app_name)
     if app is None:
         raise HTTPError(400, log_message="app not found %s" % app_name)
     env = app.get_env(env_name)
     if env is None:
         raise HTTPError(400, log_message="env  %s not found" % env_name)
     return env
Example #6
0
 def get_env(self, app_name, env_name):
     app = Application.find(app_name)
     if app is None:
         raise HTTPError(400, log_message="app not found %s" % app_name)
     env = app.get_env(env_name)
     if env is None:
         raise HTTPError(400, log_message="env  %s not found" % env_name)
     return env
Example #7
0
 def put(self, app_name):
     env_name = json.loads(self.request.body)["name"]
     app = Application.find(app_name)
     if app is None:
         raise HTTPError(400, log_message="app not found %s" % app_name)
     if app.get_env(env_name) is not None:
         raise HTTPError(400, log_message="app name %s exists" % env_name)
     app.create_env(env_name)
     self.set_status(201)
Example #8
0
    def test_should_put_new_key_value(self):
        app = Application(name="lms").save()
        env = AppEnvironment(name="usc-mat-sb01", app=app).save()
        env.put_value("adobe_host", "foobar.com")

        env_from_db = AppEnvironment.objects(app=app)[0]
        self.assertIsNotNone(env_from_db)
        entry = env_from_db.entries.get("adobe_host")
        self.assertIsNotNone(entry)
        self.assertEquals("foobar.com", entry.value)
Example #9
0
 def put(self):
     name = json.loads(self.request.body)["name"]
     if Application.name_exists(name):
         raise HTTPError(400, log_message="app name %s exists" % name)
     Application.create(name)
     self.set_status(201)
Example #10
0
    def test_should_save_env(self):
        app = Application(name="lms").save()
        AppEnvironment(name="usc-mat-sb01", app=app).save()

        self.assertEquals("usc-mat-sb01",
                          AppEnvironment.objects(app=app)[0].name)
Example #11
0
 def test_should_create_app(self):
     app = Application.create("lms")
     self.assertEquals("lms", Application.objects()[0].name)
Example #12
0
 def test_should_find_app_by_name(self):
     app = Application(name="lms").save()
     self.assertEquals("lms", Application.find("lms").name)
Example #13
0
 def test_should_return_true_if_app_name_exists(self):
     app = Application(name="lms").save()
     self.assertTrue(Application.name_exists("lms"))
     self.assertFalse(Application.name_exists("foobar"))