|
5 | 5 |
|
6 | 6 | TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets")
|
7 | 7 |
|
| 8 | +CREATE_XML = os.path.join(TEST_ASSET_DIR, "subscription_create.xml") |
8 | 9 | GET_XML = os.path.join(TEST_ASSET_DIR, "subscription_get.xml")
|
9 | 10 | GET_XML_BY_ID = os.path.join(TEST_ASSET_DIR, "subscription_get_by_id.xml")
|
10 | 11 |
|
@@ -48,3 +49,26 @@ def test_get_subscription_by_id(self):
|
48 | 49 | self.assertEqual('c0d5fc44-ad8c-4957-bec0-b70ed0f8df1e', subscription.user_id)
|
49 | 50 | self.assertEqual('Not Found Alert', subscription.subject)
|
50 | 51 | self.assertEqual('7617c389-cdca-4940-a66e-69956fcebf3e', subscription.schedule_id)
|
| 52 | + |
| 53 | + def test_create_subscription(self): |
| 54 | + with open(CREATE_XML, 'rb') as f: |
| 55 | + response_xml = f.read().decode('utf-8') |
| 56 | + with requests_mock.mock() as m: |
| 57 | + m.post(self.baseurl, text=response_xml) |
| 58 | + |
| 59 | + target_item = TSC.Target("960e61f2-1838-40b2-bba2-340c9492f943", "workbook") |
| 60 | + new_subscription = TSC.SubscriptionItem("subject", "4906c453-d5ec-4972-9ff4-789b629bdfa2", |
| 61 | + "8d30c8de-0a5f-4bee-b266-c621b4f3eed0", target_item) |
| 62 | + new_subscription = self.server.subscriptions.create(new_subscription) |
| 63 | + |
| 64 | + self.assertEqual("78e9318d-2d29-4d67-b60f-3f2f5fd89ecc", new_subscription.id) |
| 65 | + self.assertEqual("sub_name", new_subscription.subject) |
| 66 | + self.assertEqual("960e61f2-1838-40b2-bba2-340c9492f943", new_subscription.target.id) |
| 67 | + self.assertEqual("Workbook", new_subscription.target.type) |
| 68 | + self.assertEqual("4906c453-d5ec-4972-9ff4-789b629bdfa2", new_subscription.schedule_id) |
| 69 | + self.assertEqual("8d30c8de-0a5f-4bee-b266-c621b4f3eed0", new_subscription.user_id) |
| 70 | + |
| 71 | + def test_delete_subscription(self): |
| 72 | + with requests_mock.mock() as m: |
| 73 | + m.delete(self.baseurl + '/78e9318d-2d29-4d67-b60f-3f2f5fd89ecc', status_code=204) |
| 74 | + self.server.subscriptions.delete('78e9318d-2d29-4d67-b60f-3f2f5fd89ecc') |
0 commit comments