Commit b98d44d6 authored by Laurent Meiller's avatar Laurent Meiller

3389 Add create dao action

parent 1436bd3a
......@@ -34,6 +34,10 @@ def get(label_id):
query = Session.query(Labels).filter_by(id=label_id)
return query.first()
def create(label):
Session.add(label)
Session.flush()
return label
def search(**parameters):
rows, total = label_search.search(Session, parameters)
......
......@@ -20,6 +20,7 @@ from xivo_dao.resources.utils.search import SearchResult
from xivo_dao.tests.test_dao import DAOTestCase
from xivo_dao.resources.labels import dao as label_dao
from xivo_dao.resources.user import dao as user_dao
from xivo_dao.alchemy.labels import Labels
class TestLabelExist(DAOTestCase):
......@@ -47,6 +48,15 @@ class TestLabelExist(DAOTestCase):
assert_that(result[1][0].users_count, equal_to(0))
assert_that(result, equal_to(expected))
def test_create_label(self):
props = {
'display_name': 'MyLabel',
'description': 'Any Label'
}
label = label_dao.create(Labels(**props))
expected = label_dao.get(label.id)
assert_that(label, equal_to(expected))
def test_get_all_labels_with_associated_user(self):
label_row = self.add_label()
user = self.add_user(callerid='"John Doe"')
......
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