Commit bfaddad1 authored by Etienne Allovon's avatar Etienne Allovon

Merge branch 'master' into 3392-update-label

parents 51ecfd91 c7b6f71d
xivo-dao (2020.14.00) xivo-freya; urgency=medium
[Tomas Taraba]
* 3438 Disassociate users from label when the label is deleted
[Rim Jamali]
* 3392 update labels API
-- Rim Jamali <rjamali@xivo.solutions> Wed, 05 Aug 2020 10:36:53 +0200
-- Tomas Taraba <ttaraba@avencall.com> Tue, 04 Aug 2020 16:14:32 +0200
xivo-dao (2020.13.00) xivo-freya; urgency=medium
......
......@@ -55,10 +55,17 @@ def edit(label):
def delete(label):
label = get(label.id)
_disassociate(label)
Session.delete(label)
Session.flush()
def _disassociate(label):
label.user_features = []
Session.flush()
def search(**parameters):
rows, total = label_search.search(Session, parameters)
return SearchResult(total, rows)
......@@ -91,6 +91,23 @@ class TestLabelCRUD(DAOTestCase):
assert_that(result, equal_to(expected))
def test_delete_associated_label(self):
label_row = self.add_label()
user = self.add_user(callerid='"John Doe"')
user.labels.append(label_row)
label_dao.delete(label_row)
expected_label = SearchResult(total=0, items=[])
result_label = label_dao.search()
result_user = user_dao.find_by_id_uuid(user.id)
assert_that(result_label, equal_to(expected_label))
assert_that(result_user.id, equal_to(user.id))
assert_that(len(result_user.labels), equal_to(0))
def test_edit_label(self):
label = self.add_label()
label.display_name = 'MyLabel'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment