diff --git a/pyipptool/core.py b/pyipptool/core.py index 1dc2b47..848e468 100644 --- a/pyipptool/core.py +++ b/pyipptool/core.py @@ -367,24 +367,18 @@ def create_job_subscription(self, """ Create a per-job subscription object. - Create-Job-Subscription ??? - http://www.cups.org/documentation.php/spec-ipp.html - OR - - Create-Job-Subscriptions ??? + Create-Job-Subscriptions https://tools.ietf.org/html/rfc3995#section-11.1.1 - A ticket is open for the current bug in cups https://www.cups.org/str.php?L4389 """ - raise NotImplementedError kw = {'operation_attributes': {'printer_uri': printer_uri, 'requesting_user_name': requesting_user_name, - 'notify_job_id': notify_job_id, 'job_id': job_id, 'job_uri': job_uri}, + 'notify_job_id': notify_job_id, 'notify_recipient_uri': notify_recipient_uri, 'notify_pull_method': notify_pull_method, 'notify_events': notify_events, diff --git a/pyipptool/schemas.py b/pyipptool/schemas.py index c1f0390..7461859 100644 --- a/pyipptool/schemas.py +++ b/pyipptool/schemas.py @@ -493,6 +493,8 @@ class CreateSubscriptionSchema(BaseIPPSchema): operation_attributes = SubscriptionOperationAttributes( widget=IPPTupleWidget()) object_attributes_tag = 'subscription-attributes-tag' + notify_job_id = colander.SchemaNode(colander.Integer(), + widget=IPPAttributeWidget()) notify_recipient_uri = colander.SchemaNode(Uri(), widget=IPPAttributeWidget()) notify_pull_method = colander.SchemaNode(Keyword(), diff --git a/tests/test_form.py b/tests/test_form.py index 2266797..c796f5b 100644 --- a/tests/test_form.py +++ b/tests/test_form.py @@ -69,15 +69,14 @@ def test_create_printer_subscription_form(): assert 'ATTR integer notify-time-interval 1' in request -@pytest.mark.xfail def test_create_job_subscription_form_for_pull_delivery_method(): from pyipptool.forms import create_job_subscription_form request = create_job_subscription_form.render( {'operation_attributes': {'printer_uri': 'https://localhost:631/printer/p', - 'requesting_user_name': 'admin', - 'notify_job_id': 12}, + 'requesting_user_name': 'admin'}, 'notify_recipient_uri': 'rss://', + 'notify_job_id': 12, 'notify_events': ('job-completed', 'job-created', 'job-progress'), 'notify_attributes': 'notify-subscriber-user-name', 'notify_charset': 'utf-8', @@ -503,19 +502,19 @@ def test_create_job_form(): 'job_impressions': 2048, 'job_media_sheets': 2}, 'sub_operation_attributes': - {'job_priority': 1, - 'job_hold_until': 'indefinite', - 'job_sheets': 'standard', - 'multiple_document_handling': 'single-document', - 'copies': 2, - 'finishings': 'punch', - 'page_ranges': '1-6', - 'sides': 'two-sided-short-edge', - 'number_up': 4, - 'orientation_requested': 'reverse-landscape', - 'media': 'iso-a4-white', - 'printer_resolution': '600dpi', - 'print_quality': 5}, + {'job_priority': 1, + 'job_hold_until': 'indefinite', + 'job_sheets': 'standard', + 'multiple_document_handling': 'single-document', + 'copies': 2, + 'finishings': 'punch', + 'page_ranges': '1-6', + 'sides': 'two-sided-short-edge', + 'number_up': 4, + 'orientation_requested': 'reverse-landscape', + 'media': 'iso-a4-white', + 'printer_resolution': '600dpi', + 'print_quality': 5}, 'auth_info': 'michael', 'job_billing': 'no-idea', 'job_sheets': 'none', @@ -569,19 +568,19 @@ def test_print_job_form(): 'job_impressions': 2048, 'job_media_sheets': 2}, 'sub_operation_attributes': - {'job_priority': 1, - 'job_hold_until': 'indefinite', - 'job_sheets': 'standard', - 'multiple_document_handling': 'single-document', - 'copies': 2, - 'finishings': 'punch', - 'page_ranges': '1-6', - 'sides': 'two-sided-short-edge', - 'number_up': 4, - 'orientation_requested': 'reverse-landscape', - 'media': 'iso-a4-white', - 'printer_resolution': '600dpi', - 'print_quality': 5}, + {'job_priority': 1, + 'job_hold_until': 'indefinite', + 'job_sheets': 'standard', + 'multiple_document_handling': 'single-document', + 'copies': 2, + 'finishings': 'punch', + 'page_ranges': '1-6', + 'sides': 'two-sided-short-edge', + 'number_up': 4, + 'orientation_requested': 'reverse-landscape', + 'media': 'iso-a4-white', + 'printer_resolution': '600dpi', + 'print_quality': 5}, 'auth_info': 'michael', 'job_billing': 'no-idea', 'job_sheets': 'none', diff --git a/tests/test_highlevel.py b/tests/test_highlevel.py index 1dd2f5f..09b3a50 100644 --- a/tests/test_highlevel.py +++ b/tests/test_highlevel.py @@ -12,7 +12,6 @@ import pyipptool -@pytest.mark.xfail @mock.patch.object(pyipptool.wrapper, '_call_ipptool') def test_ipptool_create_job_subscription_pull_delivery_method(_call_ipptool): from pyipptool import create_job_subscription @@ -27,15 +26,17 @@ def test_ipptool_create_job_subscription_pull_delivery_method(_call_ipptool): notify_natural_language='de', notify_time_interval=1) request = _call_ipptool._mock_mock_calls[0][1][0] - assert 'printer-uri https://localhost:631/printer/p' in request - assert 'requesting-user-name admin' in request - assert 'notify-job-id 108' in request - assert 'notify-recipient-uri rss://' in request - assert 'notify-events job-completed,job-created,job-progress' in request - assert 'notify-attributes notify-subscriber-user-name' in request - assert 'notify-charset utf-8' in request - assert 'notify-natural-language de' in request - assert 'notify-time-interval 1' in request + assert 'ATTR uri printer-uri https://localhost:631/printer/p' in request + assert 'ATTR name requesting-user-name admin' in request + assert 'ATTR integer notify-job-id 108' in request + assert 'ATTR uri notify-recipient-uri rss://' in request + assert ('ATTR keyword notify-events job-completed,job-created,job-progress' + in request) + assert ('ATTR keyword notify-attributes notify-subscriber-user-name' + in request) + assert 'ATTR charset notify-charset utf-8' in request + assert 'ATTR language notify-natural-language de' in request + assert 'ATTR integer notify-time-interval 1' in request @mock.patch.object(pyipptool.wrapper, '_call_ipptool')