コード例 #1
0
ファイル: test_dao.py プロジェクト: jlebleu/xivo-dao
    def test_fetch_device_and_config_when_device_does_not_exist(self):
        with self.provd_managers() as (device_manager, config_manager, _):
            device_manager.get.side_effect = HTTPError('', 404, '', '', StringIO(''))

            device, config = device_dao.fetch_device_and_config(self.deviceid)

            assert_that(device, none())
            assert_that(config, none())
            device_manager.get.assert_called_once_with(self.deviceid)
            assert_that(config_manager.find.call_count, equal_to(0))
コード例 #2
0
ファイル: test_dao.py プロジェクト: jlebleu/xivo-dao
    def test_fetch_device_and_config_when_device_exists_and_references_no_config(self):
        with self.provd_managers() as (device_manager, config_manager, _):
            expected_device = device_manager.get.return_value = {'id': self.deviceid}

            device, config = device_dao.fetch_device_and_config(self.deviceid)

            assert_that(device, same_instance(expected_device))
            assert_that(config, none())
            device_manager.get.assert_called_once_with(self.deviceid)
            assert_that(config_manager.find.call_count, equal_to(0))
コード例 #3
0
    def test_fetch_device_and_config_when_device_does_not_exist(self):
        with self.provd_managers() as (device_manager, config_manager, _):
            device_manager.get.side_effect = HTTPError('', 404, '', '',
                                                       StringIO(''))

            device, config = device_dao.fetch_device_and_config(self.deviceid)

            assert_that(device, none())
            assert_that(config, none())
            device_manager.get.assert_called_once_with(self.deviceid)
            assert_that(config_manager.find.call_count, equal_to(0))
コード例 #4
0
ファイル: test_dao.py プロジェクト: jlebleu/xivo-dao
    def test_fetch_device_and_config_when_device_and_config_exist(self):
        with self.provd_managers() as (device_manager, config_manager, _):
            expected_device = device_manager.get.return_value = {'id': self.deviceid,
                                                                 'config': self.config_id}
            expected_config = config_manager.get.return_value = Mock()
            device, config = device_dao.fetch_device_and_config(self.deviceid)

            assert_that(device, same_instance(expected_device))
            assert_that(config, same_instance(expected_config))
            device_manager.get.assert_called_once_with(self.deviceid)
            config_manager.get.assert_called_once_with(self.config_id)
コード例 #5
0
    def test_fetch_device_and_config_when_device_exists_and_references_no_config(
            self):
        with self.provd_managers() as (device_manager, config_manager, _):
            expected_device = device_manager.get.return_value = {
                'id': self.deviceid
            }

            device, config = device_dao.fetch_device_and_config(self.deviceid)

            assert_that(device, same_instance(expected_device))
            assert_that(config, none())
            device_manager.get.assert_called_once_with(self.deviceid)
            assert_that(config_manager.find.call_count, equal_to(0))
コード例 #6
0
    def test_fetch_device_and_config_when_device_and_config_exist(self):
        with self.provd_managers() as (device_manager, config_manager, _):
            expected_device = device_manager.get.return_value = {
                'id': self.deviceid,
                'config': self.config_id
            }
            expected_config = config_manager.get.return_value = Mock()
            device, config = device_dao.fetch_device_and_config(self.deviceid)

            assert_that(device, same_instance(expected_device))
            assert_that(config, same_instance(expected_config))
            device_manager.get.assert_called_once_with(self.deviceid)
            config_manager.get.assert_called_once_with(self.config_id)