|
5 | 5 | import warnings |
6 | 6 |
|
7 | 7 | from azure.storage.blob import BlobServiceClient |
| 8 | +from azure.core.exceptions import ResourceNotFoundError |
8 | 9 | from requests import exceptions |
9 | 10 | from kbcstorage.buckets import Buckets |
10 | 11 | from kbcstorage.jobs import Jobs |
@@ -134,6 +135,32 @@ def test_load_files_to_workspace(self): |
134 | 135 | ) |
135 | 136 | self.assertEqual('fooBar', blob_client_2.download_blob().readall().decode('utf-8')) |
136 | 137 |
|
| 138 | + # now let's test that we can use the 'and' operator. in this case file2 should not get loaded |
| 139 | + self.workspaces.load_files( |
| 140 | + workspace['id'], |
| 141 | + { |
| 142 | + 'tags': ['sapi-client-python-tests', 'file1'], |
| 143 | + 'operator': 'and', |
| 144 | + 'destination': 'data/in/and_files' |
| 145 | + } |
| 146 | + ) |
| 147 | + # file 1 should be there |
| 148 | + blob_client_1 = blob_service_client.get_blob_client( |
| 149 | + container=workspace['connection']['container'], |
| 150 | + blob='data/in/and_files/%s/%s' % (file1['name'], str(file1['id'])) |
| 151 | + ) |
| 152 | + self.assertEqual('fooBar', blob_client_1.download_blob().readall().decode('utf-8')) |
| 153 | + |
| 154 | + # file 2 should not |
| 155 | + blob_client_2 = blob_service_client.get_blob_client( |
| 156 | + container=workspace['connection']['container'], |
| 157 | + blob='data/in/and_files/%s/%s' % (file2['name'], str(file2['id'])) |
| 158 | + ) |
| 159 | + with self.assertRaises(ResourceNotFoundError) as context: |
| 160 | + blob_client_2.download_blob().readall().decode('utf-8') |
| 161 | + |
| 162 | + self.assertTrue('The specified blob does not exist' in str(context.exception)) |
| 163 | + |
137 | 164 | def __create_table(self, bucket_id, table_name, row): |
138 | 165 | file, path = tempfile.mkstemp(prefix='sapi-test') |
139 | 166 | with open(path, 'w') as csv_file: |
|
0 commit comments