Skip to content

Commit

Permalink
[qa][person] add tests for: gazu.person.get_department, gazu.person.g…
Browse files Browse the repository at this point in the history
…et_department_by_name, gazu.person.new_department
  • Loading branch information
EvanBldy committed Aug 7, 2024
1 parent 42dc6e3 commit d824787
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gazu/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ def get_department_by_name(name, client=default):


@cache
def get_department(id, client=default):
def get_department(department_id, client=default):
"""
Args:
id (str): An uuid identifying a department.
department_id (str): An uuid identifying a department.
Returns:
dict: Department corresponding to given id.
dict: Department corresponding to given department_id.
"""
return raw.fetch_first("departments", {"id": id}, client=client)
return raw.fetch_one("departments", department_id, client=client)


@cache
Expand Down
33 changes: 33 additions & 0 deletions tests/test_person.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,39 @@ def test_get_person_by_full_name(self):
person = gazu.person.get_person_by_full_name("", "John", "Doe")
self.assertEqual(person["id"], "person-1")

def test_get_department_by_name(self):
with requests_mock.mock() as mock:
mock_route(
mock,
"GET",
"data/departments?name=department-1",
text=[{"name": "department-1"}],
)
department = gazu.person.get_department_by_name("department-1")
self.assertEqual(department["name"], "department-1")

def test_get_department(self):
with requests_mock.mock() as mock:
mock_route(
mock,
"GET",
"data/departments/%s" % fakeid("department-1"),
text={"name": "department-1"},
)
department = gazu.person.get_department(fakeid("department-1"))
self.assertEqual(department["name"], "department-1")

def test_new_department(self):
with requests_mock.mock() as mock:
result = {"name": "department-1"}
mock_route(
mock, "GET", "data/departments?name=department-1", text=[]
)
mock_route(mock, "POST", "data/departments", text=result)
self.assertEqual(
gazu.person.new_department("department-1"), result
)

def test_get_person_by_desktop_login(self):
with requests_mock.mock() as mock:
mock.get(
Expand Down

0 comments on commit d824787

Please sign in to comment.