def test_set_members(self): userfeatures = UserFeatures(self._agi, self._cursor, self._args) userfeatures._set_feature_list = Mock() userfeatures._set_caller = Mock() userfeatures._set_lines = Mock() userfeatures._set_user = Mock() userfeatures._set_members() objects.ExtenFeatures = Mock() old_user, objects.User = objects.User, Mock() self.assertEqual(userfeatures._userid, self._variables['XIVO_USERID']) self.assertEqual(userfeatures._dstid, self._variables['XIVO_DSTID']) self.assertEqual(userfeatures._lineid, self._variables['XIVO_LINEID']) self.assertEqual(userfeatures._zone, self._variables['XIVO_CALLORIGIN']) self.assertEqual(userfeatures._bypass_filter, self._variables['XIVO_CALLFILTER_BYPASS']) self.assertEqual(userfeatures._srcnum, self._variables['XIVO_SRCNUM']) self.assertEqual(userfeatures._dstnum, self._variables['XIVO_DSTNUM']) self.assertTrue(userfeatures._set_feature_list.called) self.assertTrue(userfeatures._set_caller.called) self.assertTrue(userfeatures._set_lines.called) self.assertTrue(userfeatures._set_user.called) objects.User, old_user = old_user, None
def test_set_user(self): userfeatures = UserFeatures(self._agi, self._cursor, self._args) userfeatures._set_xivo_user_name = Mock() userfeatures._set_user() self.assertTrue(userfeatures._user is None) self.assertEqual(userfeatures._set_xivo_user_name.call_count, 0) userfeatures._dstid = self._variables['XIVO_DSTID'] with patch.object(objects.User, '__init__') as user_init: user_init.return_value = None userfeatures._set_user() self.assertEqual(userfeatures._set_xivo_user_name.call_count, 1) self.assertTrue(userfeatures._user is not None) self.assertTrue(isinstance(userfeatures._user, objects.User))