Commit f11e5dec authored by Jean Aunis's avatar Jean Aunis

Added a base class whom all Sdm objects inherit: defines a todict method

parent 55fe7af2
# -*- coding: utf-8 -*-
# Copyright (C) 2013 Avencall
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
class BaseSdm:
def todict(self):
return self.__dict__
'''
Created on Mar 14, 2013
@author: jean
'''
from xivo_dao.service_data_model.base_sdm import BaseSdm
import unittest
class TestBaseSdm(unittest.TestCase):
def test_todict(self):
base_instance = BaseSdm()
base_instance.attr1 = 'val1'
base_instance.attr2 = 2
base_instance.attr3 = None
expected_result = {'attr1': 'val1',
'attr2': 2,
'attr3': None}
result = base_instance.todict()
self.assertEquals(result, expected_result)
......@@ -15,9 +15,10 @@
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from xivo_dao.service_data_model.base_sdm import BaseSdm
class UserSdm(object):
class UserSdm(BaseSdm):
def __init__(self):
self.id = None
......
......@@ -15,9 +15,10 @@
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from xivo_dao.service_data_model.base_sdm import BaseSdm
class VoicemailSdm(object):
class VoicemailSdm(BaseSdm):
def __init__(self):
# Integer: ID attributed by the database
......
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