Add get_context in user_dao

parent b75b0ce3
......@@ -349,13 +349,18 @@ class TestUserFeaturesDAO(DAOTestCase):
def _add_user_with_line(self, name, context='default'):
def _add_user(self, name):
user = UserFeatures()
user.firstname = name
return user
def _add_user_with_line(self, name, context='default'):
user = self._add_user(name)
line = LineFeatures()
line.iduserfeatures =
line.context = context
......@@ -724,3 +729,17 @@ class TestUserFeaturesDAO(DAOTestCase):
self.assertEquals(, line_id_result)
def test_get_context(self):
user, line = self._add_user_with_line('test_user1')
context = user_dao.get_context(
self.assertEquals(context, line.context)
def test_get_context_no_line(self):
user = self._add_user('test_user1')
context = user_dao.get_context(
self.assertEqual(context, None)
......@@ -211,3 +211,15 @@ def get_device_id(user_id):
if not row:
raise LookupError('Cannot find a device from this user id %s' % user_id)
return int(row.device)
def get_context(user_id):
res = (_session()
.filter(LineFeatures.iduserfeatures == user_id)
if not res:
return None
return res.context
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