Debian Codegraph @

tests/test_person.py

raw symbols SCIP
1 """Person object test module"""
2
3 import unittest
4 from unittest.mock import patch
5 import uuid
6
7 from rachiopy import Person
8 from tests.constants import BASE_API_URL, AUTHTOKEN, RESPONSE200
9
10
11 class TestPersonMethods(unittest.TestCase):
12 """Class containing the Rachio object test cases."""
13
14 def setUp(self):
15 self.person = Person(AUTHTOKEN)
16
17 def test_init(self):
18 """Test if the constructor works as expected."""
19 self.assertEqual(self.person.authtoken, AUTHTOKEN)
20
21 @patch("requests.Session.request")
22 def test_info(self, mock):
23 """Test if the info method works as expected."""
24
25 mock.return_value = RESPONSE200
26
27 self.person.info()
28
29 args, kwargs = mock.call_args
30
31 # Check that the mock function is called with the rights args.
32 self.assertEqual(args[1], f"{BASE_API_URL}/person/info")
33 self.assertEqual(args[0], "GET")
34 self.assertEqual(kwargs["data"], None)
35
36 @patch("requests.Session.request")
37 def test_get(self, mock):
38 """Test if the get method works as expected."""
39 mock.return_value = RESPONSE200
40
41 personid = uuid.uuid4()
42
43 self.person.get(personid)
44
45 args, kwargs = mock.call_args
46
47 # Check that the mock function is called with the rights args.
48 self.assertEqual(args[1], f"{BASE_API_URL}/person/{personid}")
49 self.assertEqual(args[0], "GET")
50 self.assertEqual(kwargs["data"], None)