|
10 | 10 | PAGE_SIZE_XML = os.path.join(TEST_ASSET_DIR, 'request_option_page_size.xml') |
11 | 11 | FILTER_EQUALS = os.path.join(TEST_ASSET_DIR, 'request_option_filter_equals.xml') |
12 | 12 | FILTER_TAGS_IN = os.path.join(TEST_ASSET_DIR, 'request_option_filter_tags_in.xml') |
| 13 | +FILTER_MULTIPLE = os.path.join(TEST_ASSET_DIR, 'request_option_filter_tags_in.xml') |
13 | 14 |
|
14 | 15 |
|
15 | 16 | class RequestOptionTests(unittest.TestCase): |
@@ -89,3 +90,20 @@ def test_filter_tags_in(self): |
89 | 90 | self.assertEqual(set(['weather']), matching_workbooks[0].tags) |
90 | 91 | self.assertEqual(set(['safari']), matching_workbooks[1].tags) |
91 | 92 | self.assertEqual(set(['sample']), matching_workbooks[2].tags) |
| 93 | + |
| 94 | + def test_multiple_filter_options(self): |
| 95 | + with open(FILTER_MULTIPLE, 'rb') as f: |
| 96 | + response_xml = f.read().decode('utf-8') |
| 97 | + # To ensure that this is deterministic, run this a few times |
| 98 | + with requests_mock.mock() as m: |
| 99 | + # Sometimes pep8 requires you to do things you might not otherwise do |
| 100 | + url = ''.join((self.baseurl, '/workbooks?pageNumber=1&pageSize=100&', |
| 101 | + 'filter=name:eq:foo,tags:in:[sample,safari,weather]')) |
| 102 | + m.get(url, text=response_xml) |
| 103 | + req_option = TSC.RequestOptions() |
| 104 | + req_option.filter.add(TSC.Filter(TSC.RequestOptions.Field.Tags, TSC.RequestOptions.Operator.In, |
| 105 | + ['sample', 'safari', 'weather'])) |
| 106 | + req_option.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name, TSC.RequestOptions.Operator.Equals, 'foo')) |
| 107 | + for _ in range(100): |
| 108 | + matching_workbooks, pagination_item = self.server.workbooks.get(req_option) |
| 109 | + self.assertEqual(3, pagination_item.total_available) |
0 commit comments