コード例 #1
0
ファイル: test_formatter.py プロジェクト: jaunis/xivo-restapi
class TestLineExtensionFormatter(unittest.TestCase):
    def setUp(self):
        self.formatter = LineExtensionFormatter()

    def test_dict_to_model(self):
        data = {'extension_id': EXTENSION_ID}

        expected = LineExtension(line_id=LINE_ID, extension_id=EXTENSION_ID)

        result = self.formatter.dict_to_model(LINE_ID, data)

        assert_that(result, equal_to(expected))

    def test_model_from_ids(self):
        expected = LineExtension(line_id=LINE_ID, extension_id=EXTENSION_ID)

        result = self.formatter.model_from_ids(LINE_ID, EXTENSION_ID)

        assert_that(result, equal_to(expected))
コード例 #2
0
ファイル: test_formatter.py プロジェクト: jaunis/xivo-restapi
class TestLineExtensionFormatter(unittest.TestCase):

    def setUp(self):
        self.formatter = LineExtensionFormatter()

    def test_dict_to_model(self):
        data = {'extension_id': EXTENSION_ID}

        expected = LineExtension(line_id=LINE_ID, extension_id=EXTENSION_ID)

        result = self.formatter.dict_to_model(LINE_ID, data)

        assert_that(result, equal_to(expected))

    def test_model_from_ids(self):
        expected = LineExtension(line_id=LINE_ID, extension_id=EXTENSION_ID)

        result = self.formatter.model_from_ids(LINE_ID, EXTENSION_ID)

        assert_that(result, equal_to(expected))
コード例 #3
0
ファイル: test_formatter.py プロジェクト: jaunis/xivo-restapi
 def setUp(self):
     self.formatter = LineExtensionFormatter()
コード例 #4
0
# 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, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

from xivo_dao.data_handler.line_extension import services as line_extension_services
from xivo_dao.data_handler.exception import NonexistentParametersError
from xivo_dao.data_handler.exception import AssociationNotExistsError

from xivo_restapi.resources.line_extension_collection.formatter import LineExtensionFormatter

formatter = LineExtensionFormatter()


def associate_extension(line_id, parameters):
    model = formatter.dict_to_model(line_id, parameters)
    created_model = line_extension_services.associate(model)
    return formatter.to_api(created_model)


def dissociate_extension(line_id, extension_id):
    model = formatter.model_from_ids(line_id, extension_id)
    try:
        line_extension_services.dissociate(model)
    except NonexistentParametersError as e:
        raise AssociationNotExistsError(str(e))
    return ''
コード例 #5
0
ファイル: test_formatter.py プロジェクト: jaunis/xivo-restapi
 def setUp(self):
     self.formatter = LineExtensionFormatter()