Skip to content

Commit 8d5b0bd

Browse files
committed
Add tests for new endpoints
1 parent 27cc781 commit 8d5b0bd

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import unittest
2+
import mock
3+
from ...management.branding import Branding
4+
5+
6+
class TestBranding(unittest.TestCase):
7+
def test_init_with_optionals(self):
8+
branding = Branding(
9+
domain="domain", token="jwttoken", telemetry=False, timeout=(10, 2)
10+
)
11+
self.assertEqual(branding.client.options.timeout, (10, 2))
12+
13+
telemetry = branding.client.base_headers.get("Auth0-Client", None)
14+
self.assertEqual(telemetry, None)
15+
16+
@mock.patch("auth0.v3.management.branding.RestClient")
17+
def test_get(self, mock_rc):
18+
api = mock_rc.return_value
19+
20+
branding = Branding(domain="domain", token="jwttoken")
21+
branding.get()
22+
23+
api.get.assert_called_with(
24+
"https://domain/api/v2/branding",
25+
)
26+
27+
@mock.patch("auth0.v3.management.branding.RestClient")
28+
def test_update(self, mock_rc):
29+
api = mock_rc.return_value
30+
api.patch.return_value = {}
31+
32+
branding = Branding(domain="domain", token="jwttoken")
33+
branding.update({"a": "b", "c": "d"})
34+
35+
api.patch.assert_called_with(
36+
"https://domain/api/v2/branding", data={"a": "b", "c": "d"}
37+
)
38+
39+
@mock.patch("auth0.v3.management.branding.RestClient")
40+
def test_get_template_universal_login(self, mock_rc):
41+
api = mock_rc.return_value
42+
43+
branding = Branding(domain="domain", token="jwttoken")
44+
branding.get_template_universal_login()
45+
46+
api.get.assert_called_with(
47+
"https://domain/api/v2/branding/templates/universal-login",
48+
)
49+
50+
@mock.patch("auth0.v3.management.branding.RestClient")
51+
def test_delete_template_universal_login(self, mock_rc):
52+
api = mock_rc.return_value
53+
54+
branding = Branding(domain="domain", token="jwttoken")
55+
branding.delete_template_universal_login()
56+
57+
api.delete.assert_called_with(
58+
"https://domain/api/v2/branding/templates/universal-login",
59+
)
60+
61+
@mock.patch("auth0.v3.management.branding.RestClient")
62+
def test_update_template_universal_login(self, mock_rc):
63+
api = mock_rc.return_value
64+
api.put.return_value = {}
65+
66+
branding = Branding(domain="domain", token="jwttoken")
67+
branding.update_template_universal_login({"a": "b", "c": "d"})
68+
69+
api.put.assert_called_with(
70+
"https://domain/api/v2/branding/templates/universal-login",
71+
type="put_universal-login_body",
72+
body={"template": {"a": "b", "c": "d"}},
73+
)

0 commit comments

Comments
 (0)