Changeset 7:0fbac5c2e97d in ralphm-patches for pubsub_resource.patch
- Timestamp:
- Apr 7, 2009, 11:53:45 AM (13 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pubsub_resource.patch
r5 r7 1 diff -r 2ea6196efcdcwokkel/iwokkel.py2 --- a/wokkel/iwokkel.py Wed Mar 25 18:14:07 2009 +01003 +++ b/wokkel/iwokkel.py Mon Mar 30 08:35:052009 +02001 diff -r cf770fa6bcb7 wokkel/iwokkel.py 2 --- a/wokkel/iwokkel.py Tue Apr 07 11:17:23 2009 +0200 3 +++ b/wokkel/iwokkel.py Tue Apr 07 11:25:27 2009 +0200 4 4 @@ -297,75 +297,46 @@ 5 5 """ … … 208 208 Called when a node configuration change request has been received. 209 209 210 diff -r 2ea6196efcdcwokkel/pubsub.py211 --- a/wokkel/pubsub.py Wed Mar 25 18:14:07 2009 +0100212 +++ b/wokkel/pubsub.py Mon Mar 30 08:35:052009 +0200210 diff -r cf770fa6bcb7 wokkel/pubsub.py 211 --- a/wokkel/pubsub.py Tue Apr 07 11:17:23 2009 +0200 212 +++ b/wokkel/pubsub.py Tue Apr 07 11:25:27 2009 +0200 213 213 @@ -13,12 +13,13 @@ 214 214 from zope.interface import implements … … 296 296 @@ -852,17 +845,33 @@ 297 297 298 info.append(form .toElement())298 info.append(form) 299 299 300 300 - d = self.getNodeInfo(requestor, target, nodeIdentifier or '') … … 765 765 + def subscriptionsSet(self, request): 766 766 + return defer.fail(Unsupported('manage-subscriptions')) 767 diff -r 2ea6196efcdc wokkel/test/test_pubsub.py 768 --- a/wokkel/test/test_pubsub.py Wed Mar 25 18:14:07 2009 +0100 769 +++ b/wokkel/test/test_pubsub.py Mon Mar 30 08:35:05 2009 +0200 770 @@ -13,7 +13,7 @@ 771 from twisted.words.protocols.jabber import error 772 from twisted.words.protocols.jabber.jid import JID 773 774 -from wokkel import data_form, iwokkel, pubsub, shim 775 +from wokkel import data_form, disco, iwokkel, pubsub, shim 776 from wokkel.generic import parseXml 777 from wokkel.test.helpers import TestableRequestHandlerMixin, XmlStreamStub 778 779 @@ -1225,7 +1225,8 @@ 767 diff -r cf770fa6bcb7 wokkel/test/test_pubsub.py 768 --- a/wokkel/test/test_pubsub.py Tue Apr 07 11:17:23 2009 +0200 769 +++ b/wokkel/test/test_pubsub.py Tue Apr 07 11:25:27 2009 +0200 770 @@ -1222,7 +1222,8 @@ 780 771 781 772 def setUp(self): … … 787 778 788 779 def test_interface(self): 789 @@ -126 3,19 +1264,120@@780 @@ -1260,12 +1261,12 @@ 790 781 Test getDiscoInfo calls getNodeInfo and returns some minimal info. 791 782 """ … … 805 796 JID('pubsub.example.org'), '') 806 797 d.addCallback(cb) 798 @@ -1282,11 +1283,11 @@ 799 discoInfo.append(item) 800 self.assertIn(('pubsub', 'collection'), discoInfo.identities) 801 802 - def getNodeInfo(requestor, target, nodeIdentifier): 803 + def getInfo(requestor, target, nodeIdentifier): 804 return defer.succeed({'type': 'collection', 805 'meta-data': {}}) 806 807 - self.service.getNodeInfo = getNodeInfo 808 + self.resource.getInfo = getInfo 809 d = self.service.getDiscoInfo(JID('user@example.org/home'), 810 JID('pubsub.example.org'), '') 811 d.addCallback(cb) 812 @@ -1307,20 +1308,100 @@ 813 form = discoInfo.extensions[NS_PUBSUB_META_DATA] 814 self.assertIn('pubsub#node_type', form.fields) 815 816 - def getNodeInfo(requestor, target, nodeIdentifier): 817 + def getInfo(requestor, target, nodeIdentifier): 818 metaData = [{'var': 'pubsub#persist_items', 819 'label': 'Persist items to storage', 820 'value': True}] 821 return defer.succeed({'type': 'leaf', 'meta-data': metaData}) 822 823 - self.service.getNodeInfo = getNodeInfo 824 + self.resource.getInfo = getInfo 825 d = self.service.getDiscoInfo(JID('user@example.org/home'), 826 JID('pubsub.example.org'), '') 827 d.addCallback(cb) 807 828 return d 808 829 809 830 810 831 - def test_onPublish(self): 811 + def test_getDiscoInfoNodeType(self):812 + """813 + Test getDiscoInfo calls getNodeInfo and returns some minimal info.814 + """815 + def cb(info):816 + discoInfo = disco.DiscoInfo()817 + for item in info:818 + discoInfo.append(item)819 + self.assertIn(('pubsub', 'collection'), discoInfo.identities)820 +821 + def getInfo(requestor, target, nodeIdentifier):822 + return defer.succeed({'type': 'collection',823 + 'meta-data': {}})824 +825 + self.resource.getInfo = getInfo826 + d = self.service.getDiscoInfo(JID('user@example.org/home'),827 + JID('pubsub.example.org'), '')828 + d.addCallback(cb)829 + return d830 +831 +832 832 + def test_getDiscoInfoResourceFeatures(self): 833 833 + """ 834 + Test getDiscoInfo calls getNodeInfo and returns some minimal info.834 + Test getDiscoInfo with the resource features. 835 835 + """ 836 836 + def cb(info): … … 914 914 A publish request should result in L{PubSubService.publish} being 915 915 called. 916 @@ -1 293,12 +1395,12 @@916 @@ -1338,12 +1419,12 @@ 917 917 def publish(request): 918 918 return defer.succeed(None) … … 930 930 A successful subscription should return the current subscription. 931 931 """ 932 @@ -13 26,14 +1428,14 @@932 @@ -1371,14 +1452,14 @@ 933 933 self.assertEqual('user@example.org/Home', subscription['jid']) 934 934 self.assertEqual('subscribed', subscription['subscription']) … … 948 948 A successful subscription on root node should return no node attribute. 949 949 """ 950 @@ -1 355,14 +1457,14 @@950 @@ -1400,14 +1481,14 @@ 951 951 def cb(element): 952 952 self.assertFalse(element.subscription.hasAttribute('node')) … … 966 966 A successful unsubscription should return an empty response. 967 967 """ 968 @@ -1 382,14 +1484,14 @@968 @@ -1427,14 +1508,14 @@ 969 969 def cb(element): 970 970 self.assertIdentical(None, element) … … 984 984 Getting subscription options is not supported. 985 985 """ 986 @@ -14 14,7 +1516,7 @@986 @@ -1459,7 +1540,7 @@ 987 987 return d 988 988 … … 993 993 Setting subscription options is not supported. 994 994 """ 995 @@ -14 46,7 +1548,7 @@995 @@ -1491,7 +1572,7 @@ 996 996 return d 997 997 … … 1002 1002 A subscriptions request should result in 1003 1003 L{PubSubService.subscriptions} being called and the result prepared 1004 @@ -1 462,6 +1564,11 @@1004 @@ -1507,6 +1588,11 @@ 1005 1005 </iq> 1006 1006 """ … … 1014 1014 self.assertEqual('pubsub', element.name) 1015 1015 self.assertEqual(NS_PUBSUB, element.uri) 1016 @@ -1 475,20 +1582,14 @@1016 @@ -1520,20 +1606,14 @@ 1017 1017 self.assertEqual('test', subscription['node']) 1018 1018 self.assertEqual('subscribed', subscription['subscription']) … … 1038 1038 A subscriptions request should result in 1039 1039 L{PubSubService.affiliations} being called and the result prepared 1040 @@ -15 04,6 +1605,10 @@1040 @@ -1549,6 +1629,10 @@ 1041 1041 </iq> 1042 1042 """ … … 1049 1049 self.assertEqual('pubsub', element.name) 1050 1050 self.assertEqual(NS_PUBSUB, element.uri) 1051 @@ -15 16,19 +1621,14 @@1051 @@ -1561,19 +1645,14 @@ 1052 1052 self.assertEqual('test', affiliation['node']) 1053 1053 self.assertEqual('owner', affiliation['affiliation']) … … 1072 1072 Replies to create node requests don't return the created node. 1073 1073 """ 1074 @@ -15 48,14 +1648,14 @@1074 @@ -1593,14 +1672,14 @@ 1075 1075 def cb(element): 1076 1076 self.assertIdentical(None, element) … … 1090 1090 Replies to create node requests return the created node if changed. 1091 1091 """ 1092 @@ -1 579,14 +1679,14 @@1092 @@ -1624,14 +1703,14 @@ 1093 1093 self.assertEqual(u'myrenamednode', 1094 1094 element.create.getAttribute('node')) … … 1108 1108 Replies to create instant node requests return the created node. 1109 1109 """ 1110 @@ -16 09,14 +1709,14 @@1110 @@ -1654,14 +1733,14 @@ 1111 1111 self.assertEqual(NS_PUBSUB, element.create.uri) 1112 1112 self.assertEqual(u'random', element.create.getAttribute('node')) … … 1126 1126 A default request should result in 1127 1127 L{PubSubService.getDefaultConfiguration} being called. 1128 @@ -16 41,7 +1741,7 @@1128 @@ -1686,7 +1765,7 @@ 1129 1129 "label": "Deliver payloads with event notifications"} 1130 1130 } … … 1135 1135 1136 1136 def cb(element): 1137 @@ -16 51,15 +1751,15 @@1137 @@ -1696,15 +1775,15 @@ 1138 1138 form = data_form.Form.fromElement(element.default.x) 1139 1139 self.assertEqual(NS_PUBSUB_CONFIG, form.formNamespace) … … 1155 1155 Responses to default requests should depend on passed node type. 1156 1156 """ 1157 @@ -1 690,19 +1790,19 @@1157 @@ -1735,19 +1814,19 @@ 1158 1158 "label": "Deliver payloads with event notifications"} 1159 1159 } … … 1181 1181 1182 1182 xml = """ 1183 @@ -17 24,24 +1824,25 @@1183 @@ -1769,24 +1848,25 @@ 1184 1184 </iq> 1185 1185 """ … … 1213 1213 1214 1214 xml = """ 1215 @@ -1 766,7 +1867,7 @@1215 @@ -1811,7 +1891,7 @@ 1216 1216 "label": "Owner of the node"} 1217 1217 } … … 1222 1222 'pubsub#persist_items': '1', 1223 1223 'pubsub#owner': JID('user@example.org'), 1224 @@ -18 00,19 +1901,18 @@1224 @@ -1845,19 +1925,18 @@ 1225 1225 1226 1226 self.assertNotIn('x-myfield', fields) … … 1247 1247 1248 1248 xml = """ 1249 @@ -18 42,21 +1942,21 @@1249 @@ -1887,21 +1966,21 @@ 1250 1250 "label": "Deliver payloads with event notifications"} 1251 1251 } … … 1276 1276 1277 1277 xml = """ 1278 @@ -1 874,15 +1974,15 @@1278 @@ -1919,15 +1998,15 @@ 1279 1279 </iq> 1280 1280 """ … … 1296 1296 On a node configuration set request unknown fields should be ignored. 1297 1297 """ 1298 @@ -19 14,17 +2014,17 @@1298 @@ -1959,17 +2038,17 @@ 1299 1299 "label": "Deliver payloads with event notifications"} 1300 1300 } … … 1319 1319 On a node configuration set request unknown fields should be ignored. 1320 1320 """ 1321 @@ - 1955,7 +2055,7 @@1321 @@ -2000,7 +2079,7 @@ 1322 1322 return d 1323 1323 … … 1328 1328 On a items request, return all items for the given node. 1329 1329 """ 1330 @@ - 1981,16 +2081,17 @@1330 @@ -2026,16 +2105,17 @@ 1331 1331 self.assertEqual(NS_PUBSUB, item.uri) 1332 1332 self.assertEqual('current', item['id']) … … 1350 1350 1351 1351 xml = """ 1352 @@ -20 08,13 +2109,14 @@1352 @@ -2053,13 +2133,14 @@ 1353 1353 def retract(request): 1354 1354 return defer.succeed(None) … … 1368 1368 """ 1369 1369 1370 @@ -20 30,13 +2132,14 @@1370 @@ -2075,13 +2156,14 @@ 1371 1371 def purge(request): 1372 1372 return defer.succeed(None) … … 1386 1386 """ 1387 1387 1388 @@ -20 52,7 +2155,8 @@1388 @@ -2097,7 +2179,8 @@ 1389 1389 def delete(request): 1390 1390 return defer.succeed(None) … … 1396 1396 1397 1397 1398 @@ -21 03,7 +2207,7 @@1398 @@ -2148,7 +2231,7 @@ 1399 1399 self.assertEqual(redirectURI, message.event.delete.redirect['uri']) 1400 1400 … … 1405 1405 Getting subscription options is not supported. 1406 1406 """ 1407 @@ -21 30,7 +2234,7 @@1407 @@ -2175,7 +2258,7 @@ 1408 1408 return d 1409 1409 … … 1414 1414 Setting subscription options is not supported. 1415 1415 """ 1416 @@ -2 157,7 +2261,7 @@1416 @@ -2202,7 +2285,7 @@ 1417 1417 return d 1418 1418 … … 1423 1423 Getting subscription options is not supported. 1424 1424 """ 1425 @@ -2 184,7 +2288,7 @@1425 @@ -2229,7 +2312,7 @@ 1426 1426 return d 1427 1427 … … 1432 1432 Setting subscription options is not supported. 1433 1433 """ 1434 @@ -22 11,18 +2315,38 @@1434 @@ -2256,18 +2339,38 @@ 1435 1435 return d 1436 1436 … … 1481 1481 1482 1482 def cb(result): 1483 @@ -22 31,7 +2355,7 @@1483 @@ -2276,7 +2379,7 @@ 1484 1484 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri) 1485 1485 self.assertEquals('publish', result.appCondition['feature']) … … 1490 1490 d.addCallback(cb) 1491 1491 return d 1492 @@ -22 39,16 +2363,7 @@1492 @@ -2284,16 +2387,7 @@ 1493 1493 1494 1494 def test_subscribe(self): … … 1508 1508 1509 1509 def cb(result): 1510 @@ -2 257,7 +2372,7 @@1510 @@ -2302,7 +2396,7 @@ 1511 1511 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri) 1512 1512 self.assertEquals('subscribe', result.appCondition['feature']) … … 1517 1517 d.addCallback(cb) 1518 1518 return d 1519 @@ -2 265,16 +2380,7 @@1519 @@ -2310,16 +2404,7 @@ 1520 1520 1521 1521 def test_unsubscribe(self): … … 1535 1535 1536 1536 def cb(result): 1537 @@ -2 283,7 +2389,7 @@1537 @@ -2328,7 +2413,7 @@ 1538 1538 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri) 1539 1539 self.assertEquals('subscribe', result.appCondition['feature']) … … 1544 1544 d.addCallback(cb) 1545 1545 return d 1546 @@ -2 291,16 +2397,7 @@1546 @@ -2336,16 +2421,7 @@ 1547 1547 1548 1548 def test_subscriptions(self): … … 1562 1562 1563 1563 def cb(result): 1564 @@ -23 10,7 +2407,7 @@1564 @@ -2355,7 +2431,7 @@ 1565 1565 self.assertEquals('retrieve-subscriptions', 1566 1566 result.appCondition['feature']) … … 1571 1571 d.addCallback(cb) 1572 1572 return d 1573 @@ -23 18,16 +2415,7 @@1573 @@ -2363,16 +2439,7 @@ 1574 1574 1575 1575 def test_affiliations(self): … … 1589 1589 1590 1590 def cb(result): 1591 @@ -23 37,7 +2425,7 @@1591 @@ -2382,7 +2449,7 @@ 1592 1592 self.assertEquals('retrieve-affiliations', 1593 1593 result.appCondition['feature']) … … 1598 1598 d.addCallback(cb) 1599 1599 return d 1600 @@ -23 45,16 +2433,7 @@1600 @@ -2390,16 +2457,7 @@ 1601 1601 1602 1602 def test_create(self): … … 1616 1616 1617 1617 def cb(result): 1618 @@ -2 363,87 +2442,51 @@1618 @@ -2408,87 +2466,51 @@ 1619 1619 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri) 1620 1620 self.assertEquals('create-nodes', result.appCondition['feature']) … … 1715 1715 1716 1716 def cb(result): 1717 @@ -24 52,7 +2495,7 @@1717 @@ -2497,7 +2519,7 @@ 1718 1718 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri) 1719 1719 self.assertEquals('config-node', result.appCondition['feature']) … … 1724 1724 d.addCallback(cb) 1725 1725 return d 1726 @@ -2 460,15 +2503,7 @@1726 @@ -2505,15 +2527,7 @@ 1727 1727 1728 1728 def test_items(self): … … 1741 1741 1742 1742 def cb(result): 1743 @@ -2 477,7 +2512,7 @@1743 @@ -2522,7 +2536,7 @@ 1744 1744 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri) 1745 1745 self.assertEquals('retrieve-items', result.appCondition['feature']) … … 1750 1750 d.addCallback(cb) 1751 1751 return d 1752 @@ -2 485,18 +2520,7 @@1752 @@ -2530,18 +2544,7 @@ 1753 1753 1754 1754 def test_retract(self): … … 1770 1770 1771 1771 def cb(result): 1772 @@ -25 05,7 +2529,7 @@1772 @@ -2550,7 +2553,7 @@ 1773 1773 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri) 1774 1774 self.assertEquals('retract-items', result.appCondition['feature']) … … 1779 1779 d.addCallback(cb) 1780 1780 return d 1781 @@ -25 13,15 +2537,7 @@1781 @@ -2558,15 +2561,7 @@ 1782 1782 1783 1783 def test_purge(self): … … 1796 1796 1797 1797 def cb(result): 1798 @@ -25 30,7 +2546,7 @@1798 @@ -2575,7 +2570,7 @@ 1799 1799 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri) 1800 1800 self.assertEquals('purge-nodes', result.appCondition['feature']) … … 1805 1805 d.addCallback(cb) 1806 1806 return d 1807 @@ -25 38,15 +2554,7 @@1807 @@ -2583,15 +2578,7 @@ 1808 1808 1809 1809 def test_delete(self): … … 1822 1822 1823 1823 def cb(result): 1824 @@ -2 555,7 +2563,7 @@1824 @@ -2600,7 +2587,7 @@ 1825 1825 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri) 1826 1826 self.assertEquals('delete-nodes', result.appCondition['feature'])
Note: See TracChangeset
for help on using the changeset viewer.