示例#1
0
    def test_get_headers(self):
        assert self.transport._get_headers() == {}
        assert self.transport._get_headers({"foo": "bar"}) == {"foo": "bar"}

        self.transport.config = ClientConfig(token="token", host="host")

        assert self.transport._get_headers() == {
            "Authorization": "{} {}".format(AuthenticationTypes.TOKEN, "token")
        }
        assert self.transport._get_headers({"foo": "bar"}) == {
            "foo": "bar",
            "Authorization": "{} {}".format(AuthenticationTypes.TOKEN, "token"),
        }

        self.transport.config.authentication_type = AuthenticationTypes.INTERNAL_TOKEN
        assert self.transport._get_headers() == {
            "Authorization": "{} {}".format(AuthenticationTypes.INTERNAL_TOKEN, "token")
        }
        assert self.transport._get_headers({"foo": "bar"}) == {
            "foo": "bar",
            "Authorization": "{} {}".format(
                AuthenticationTypes.INTERNAL_TOKEN, "token"
            ),
        }
 def test_from_config(self):
     settings.CLIENT_CONFIG.host = "localhost"
     client = PolyaxonClient(config=ClientConfig())
     assert client.config.is_managed is False
     assert client.config.host == "https://cloud.polyaxon.com"
     assert client.config.token is None
 def test_is_managed(self):
     config = ClientConfig(host=None, is_managed=True)
     assert config.is_managed is True
     assert config.version == "v1"
     assert config.host == "https://cloud.polyaxon.com"
 def setUp(self):
     self.host = "http://localhost:8000"
     self.config = ClientConfig(host=self.host, version="v1", token="token")