def test_client_can_override_api_root_with_a_dict(self):
     api_root = "http://localhost"
     alma_client = Client(api_key="sk_live_3geNR4OVI0gQGCAKgcYqQs2I",
                          api_root={ApiModes.LIVE: api_root})
     assert alma_client.context.options["api_root"] == {
         ApiModes.LIVE: api_root,
     }
    def test_client_inits_api_key_credentials(self):
        api_key = "sk_live_3geNR4OVI0gQGCAKgcYqQs2I"
        alma_client = Client.with_api_key(api_key)

        assert alma_client.context.credentials
        assert isinstance(alma_client.context.credentials, ApiKeyCredentials)
        assert alma_client.context.credentials.api_key == api_key
Beispiel #3
0
    def setUp(self) -> None:
        self.session_id = "1234567890"
        self.cookie_name = "alma_session"
        client = Client.with_alma_session(self.session_id, self.cookie_name)

        self.credentials = client.context.credentials
        self.request = Request(client.context, "https://url.com")
    def test_client_expose_endpoints(self):
        alma_client = Client(api_key="sk_live_3geNR4OVI0gQGCAKgcYqQs2I")
        assert alma_client.payments.fetch_all
        assert alma_client.orders.fetch_all
        assert alma_client.exports.fetch_all

        # Exposed but empty
        assert alma_client.merchants
    def test_client_inits_merchant_id_credentials(self):
        merchant_id = "merchant"
        alma_client = Client.with_merchant_id(merchant_id)

        assert alma_client.context.credentials
        assert isinstance(alma_client.context.credentials,
                          MerchantIdCredentials)
        assert alma_client.context.credentials.merchant_id == merchant_id
    def test_client_inits_with_cookies_credentials(self):
        session_id = "merchant"
        cookie_name = "session_cookie"
        alma_client = Client.with_alma_session(session_id=session_id,
                                               cookie_name=cookie_name)

        assert alma_client.context.credentials
        assert isinstance(alma_client.context.credentials,
                          AlmaSessionCredentials)
        assert alma_client.context.credentials.session_id == session_id
        assert alma_client.context.credentials.cookie_name == cookie_name
 def setUp(self):
     client = Client.with_api_key("sk_live_3geNR4OVI0gQGCAKgcYqQs2I")
     self.context = client.context
 def test_client_raises_with_no_api_key_arguments(self):
     with pytest.raises(
         TypeError, match=r"__init__\(\) missing 1 required positional argument: 'api_key'"
     ):
         Client()
 def test_client_raises_with_empty_api_key_set_to_None(self):
     with pytest.raises(ValueError, match=r"An API key is required"):
         Client(api_key=None)
 def setUp(self) -> None:
     client = Client.with_api_key("sk_test_3geNR4OVI0gQGCAKgcYqQs2I")
     self.credentials = client.context.credentials
     self.request = Request(client.context, "https://url.com")
 def test_client_raises_with_no_api_key_arguments_nor_credentials(self):
     with pytest.raises(ValueError,
                        match=r"Valid credentials are required"):
         Client()
 def test_client_cannot_override_mode_with_something_else(self):
     with pytest.raises(
             ValueError,
             match=r"`mode` option must be one of \(live, test\)"):
         Client(api_key="sk_live_3geNR4OVI0gQGCAKgcYqQs2I", mode="blah")
 def test_client_cannot_override_api_root_with_something_else(self):
     with pytest.raises(
             ValueError,
             match=r"`api_root` option must be a dict or a string"):
         Client(api_key="sk_live_3geNR4OVI0gQGCAKgcYqQs2I", api_root=12)
 def test_client_detects_mode_with_regards_to_the_suggested_key(self):
     alma_client = Client(api_key="sk_live_3geNR4OVI0gQGCAKgcYqQs2I")
     assert alma_client.context.options["mode"] == ApiModes.LIVE
     alma_client = Client(api_key="sk_test_l6C92m3mqmS0aWcscEw62Xk4")
     assert alma_client.context.options["mode"] == ApiModes.TEST
 def test_client_raises_with_empty_api_key_set_to_None(self):
     with pytest.raises(ValueError,
                        match=r"Valid credentials are required"):
         Client(api_key=None)
Beispiel #16
0
    def setUp(self) -> None:
        self.merchant_id = "merchant"
        client = Client.with_merchant_id(self.merchant_id)

        self.credentials = client.context.credentials
        self.request = Request(client.context, "https://url.com")