| 182 | |
| 183 | |
| 184 | def test_mock_fs_gcs(): |
| 185 | with test_utils.MockFs(): |
| 186 | tf.io.gfile.makedirs('gs://bucket/dir/subdir') |
| 187 | assert tf.io.gfile.exists('gs://bucket/dir') |
| 188 | assert tf.io.gfile.exists('gs://bucket/dir/subdir') |
| 189 | |
| 190 | with tf.io.gfile.GFile('gs://bucket/dir/file.txt', 'w') as f: |
| 191 | f.write('Content of file') |
| 192 | |
| 193 | assert set(tf.io.gfile.listdir('gs://bucket/dir')) == { |
| 194 | 'file.txt', |
| 195 | 'subdir', |
| 196 | } |
| 197 | |
| 198 | bs = 'big' + 'store' |
| 199 | |
| 200 | # Test |
| 201 | # * gs |
| 202 | # * absolute path |
| 203 | # * relative path |
| 204 | assert tf.io.gfile.glob('gs://bucket/*/file.txt') == [ |
| 205 | 'gs://bucket/dir/file.txt', |
| 206 | ] |
| 207 | assert tf.io.gfile.glob(f'/{bs}/bucket/*/file.txt') == [ |
| 208 | f'/{bs}/bucket/dir/file.txt', |
| 209 | ] |
| 210 | assert tf.io.gfile.glob(f'{bs}/bucket/*/file.txt') == [ |
| 211 | f'{bs}/bucket/dir/file.txt', |
| 212 | ] |
| 213 | |
| 214 | |
| 215 | def test_gcs_access(): |