def get_by_extension_id(extension_id): line_extension = find_by_extension_id(extension_id) if line_extension is None: raise LineExtensionNotExistsError.from_extension_id(extension_id) return line_extension
def get_by_extension_id(extension_id): context = context_dao.find_by_extension_id(extension_id) if not context: raise ElementNotExistsError('Extension', id=extension_id) line_extension = _find_line_extension_by_type(context, extension_id) if not line_extension: raise LineExtensionNotExistsError.from_extension_id(extension_id) return line_extension
def test_get_line_associated_to_an_extension_with_no_line(self, line_extension_get_by_extension_id): extension_id = 1 expected_status_code = 404 expected_result = ['Extension with id=%s does not have a line' % extension_id] line_extension_get_by_extension_id.side_effect = LineExtensionNotExistsError.from_extension_id(extension_id) result = self.app.get(EXTENSION_URL % extension_id) assert_that(result.status_code, equal_to(expected_status_code)) assert_that(self._serialize_decode(result.data), equal_to(expected_result))
def test_get_extension_associated_to_a_line_with_no_extension(self, line_extension_get_by_line_id): line_id = 1 expected_status_code = 404 expected_result = ['Line with id=%s does not have an extension' % line_id] line_extension_get_by_line_id.side_effect = LineExtensionNotExistsError.from_line_id(line_id) result = self.app.get(LINE_URL % line_id) assert_that(result.status_code, equal_to(expected_status_code)) assert_that(self._serialize_decode(result.data), equal_to(expected_result))
def test_get_line_associated_to_an_extension_with_no_line( self, line_extension_get_by_extension_id): extension_id = 1 expected_status_code = 404 expected_result = [ 'Extension with id=%s does not have a line' % extension_id ] line_extension_get_by_extension_id.side_effect = LineExtensionNotExistsError.from_extension_id( extension_id) result = self.app.get(EXTENSION_URL % extension_id) assert_that(result.status_code, equal_to(expected_status_code)) assert_that(self._serialize_decode(result.data), equal_to(expected_result))
def test_get_extension_associated_to_a_line_with_no_extension( self, line_extension_get_by_line_id): line_id = 1 expected_status_code = 404 expected_result = [ 'Line with id=%s does not have an extension' % line_id ] line_extension_get_by_line_id.side_effect = LineExtensionNotExistsError.from_line_id( line_id) result = self.app.get(LINE_URL % line_id) assert_that(result.status_code, equal_to(expected_status_code)) assert_that(self._serialize_decode(result.data), equal_to(expected_result))