def test_set_keys_using_env_var(self, post):
        # reset Client settings
        keen._client = None
        keen.project_id = None
        keen.write_key = None
        keen.read_key = None
        keen.master_key = None

        # set env vars
        exp_project_id = os.environ["KEEN_PROJECT_ID"] = "xxxx5678"
        exp_write_key = os.environ["KEEN_WRITE_KEY"] = "yyyy8901"
        exp_read_key = os.environ["KEEN_READ_KEY"] = "zzzz2345"
        exp_master_key = os.environ["KEEN_MASTER_KEY"] = "abcd1234"

        keen._initialize_client_from_environment()

        # test values
        self.assertEquals(exp_project_id, keen.project_id)
        self.assertEquals(exp_write_key, keen.write_key)
        self.assertEquals(exp_read_key, keen.read_key)
        self.assertEquals(exp_master_key, keen.master_key)
        self.assertEquals(exp_project_id, keen._client.api.project_id)
        self.assertEquals(exp_write_key, keen._client.api.write_key)
        self.assertEquals(exp_read_key, keen._client.api.read_key)
        self.assertEquals(exp_master_key, keen._client.api.master_key)

        # remove env vars
        del os.environ["KEEN_PROJECT_ID"]
        del os.environ["KEEN_WRITE_KEY"]
        del os.environ["KEEN_READ_KEY"]
        del os.environ["KEEN_MASTER_KEY"]
    def test_set_keys_using_env_var(self, post):
        # reset Client settings
        keen._client = None
        keen.project_id = None
        keen.write_key = None
        keen.read_key = None
        keen.master_key = None

        # set env vars
        exp_project_id = os.environ["KEEN_PROJECT_ID"] = "xxxx5678"
        exp_write_key = os.environ["KEEN_WRITE_KEY"] = "yyyy8901"
        exp_read_key = os.environ["KEEN_READ_KEY"] = "zzzz2345"
        exp_master_key = os.environ["KEEN_MASTER_KEY"] = "abcd1234"

        keen._initialize_client_from_environment()

        # test values
        self.assertEquals(exp_project_id, keen.project_id)
        self.assertEquals(exp_write_key, keen.write_key)
        self.assertEquals(exp_read_key, keen.read_key)
        self.assertEquals(exp_master_key, keen.master_key)
        self.assertEquals(exp_project_id, keen._client.api.project_id)
        self.assertEquals(exp_write_key, keen._client.api.write_key)
        self.assertEquals(exp_read_key, keen._client.api.read_key)
        self.assertEquals(exp_master_key, keen._client.api.master_key)

        # remove env vars
        del os.environ["KEEN_PROJECT_ID"]
        del os.environ["KEEN_WRITE_KEY"]
        del os.environ["KEEN_READ_KEY"]
        del os.environ["KEEN_MASTER_KEY"]
    def test_keen_is_readable_keen_var(self):
        # only set project id, check should fail
        keen.project_id = "1234abcd"
        keen._initialize_client_from_environment()
        self.assertFalse(keen_is_readable())

        # set read_key
        keen.read_key = "4567abcd5678efgh"
        keen._initialize_client_from_environment()
        self.assertTrue(keen_is_readable())
    def test_set_keys_using_package_var(self, post):
        exp_project_id = keen.project_id = "uuuu5678"
        exp_write_key = keen.write_key = "vvvv8901"
        exp_read_key = keen.read_key = "wwwww2345"
        exp_master_key = keen.master_key = "abcd4567"

        keen._initialize_client_from_environment()

        # test values
        self.assertEquals(exp_project_id, keen.project_id)
        self.assertEquals(exp_write_key, keen.write_key)
        self.assertEquals(exp_read_key, keen.read_key)
        self.assertEquals(exp_master_key, keen.master_key)
        self.assertEquals(exp_project_id, keen._client.api.project_id)
        self.assertEquals(exp_write_key, keen._client.api.write_key)
        self.assertEquals(exp_read_key, keen._client.api.read_key)
        self.assertEquals(exp_master_key, keen._client.api.master_key)
    def test_set_keys_using_package_var(self, post):
        exp_project_id = keen.project_id = "uuuu5678"
        exp_write_key = keen.write_key = "vvvv8901"
        exp_read_key = keen.read_key = "wwwww2345"
        exp_master_key = keen.master_key = "abcd4567"

        keen._initialize_client_from_environment()

        # test values
        self.assertEquals(exp_project_id, keen.project_id)
        self.assertEquals(exp_write_key, keen.write_key)
        self.assertEquals(exp_read_key, keen.read_key)
        self.assertEquals(exp_master_key, keen.master_key)
        self.assertEquals(exp_project_id, keen._client.api.project_id)
        self.assertEquals(exp_write_key, keen._client.api.write_key)
        self.assertEquals(exp_read_key, keen._client.api.read_key)
        self.assertEquals(exp_master_key, keen._client.api.master_key)
    def test_keen_has_project_id_keen_var(self):
        keen.project_id = "1234abcd"

        keen._initialize_client_from_environment()

        self.assertTrue(keen_has_project_id())