|
9 | 9 |
|
10 | 10 | class TestStorage:
|
11 | 11 |
|
| 12 | + test_user = None |
| 13 | + |
| 14 | + def test_user_for_storage(self, auth): |
| 15 | + self.__class__.test_user = auth.sign_in_anonymous() |
| 16 | + assert self.__class__.test_user is not None |
| 17 | + |
12 | 18 | def test_child(self, storage):
|
13 | 19 | assert storage.child('firebase-test-001')
|
14 | 20 |
|
15 | 21 | def test_put(self, storage):
|
16 |
| - assert storage.child('uploaded-file.txt').put("tests/static/test-file.txt") is None |
| 22 | + assert storage.child('uploaded-file.txt').put("tests/static/test-file.txt", self.__class__.test_user.get('idToken')) |
17 | 23 |
|
18 | 24 | def test_get_url(self, storage):
|
19 |
| - assert storage.child('firebase-test-001').child('uploaded-file.txt').get_url(None) |
| 25 | + assert storage.child('firebase-test-001').child('uploaded-file.txt').get_url(self.__class__.test_user.get('idToken')) |
20 | 26 |
|
21 | 27 | def test_download(self, storage):
|
22 |
| - assert storage.child('firebase-test-001').child('uploaded-file.txt').download('tests/static/downloaded.txt') is None |
| 28 | + assert storage.child('firebase-test-001').child('uploaded-file.txt').download('tests/static/downloaded.txt', self.__class__.test_user.get('idToken')) is None |
23 | 29 | assert os.path.exists('tests/static/downloaded.txt')
|
24 | 30 |
|
25 | 31 | def test_delete(self, storage):
|
26 | 32 | os.remove('tests/static/downloaded.txt')
|
27 |
| - assert storage.child('firebase-test-001/uploaded-file.txt').delete() is None |
| 33 | + assert storage.child('firebase-test-001/uploaded-file.txt').delete(self.__class__.test_user.get('idToken')) is None |
28 | 34 |
|
29 | 35 | def test_list_of_files(self, storage):
|
30 |
| - assert storage.list_files() |
| 36 | + with pytest.raises(AttributeError) as exc_info: |
| 37 | + storage.list_files() |
| 38 | + assert 'bucket' in str(exc_info.value) |
| 39 | + |
| 40 | + def test_clean_user(self, auth): |
| 41 | + assert auth.delete_user_account(self.__class__.test_user.get('idToken')) |
| 42 | + |
| 43 | + |
| 44 | +class TestStorageAdmin: |
| 45 | + |
| 46 | + def test_child(self, storage_admin): |
| 47 | + assert storage_admin.child('firebase-test-001') |
| 48 | + |
| 49 | + def test_put(self, storage_admin): |
| 50 | + assert storage_admin.child('uploaded-file.txt').put("tests/static/test-file.txt") is None |
| 51 | + |
| 52 | + def test_get_url(self, storage_admin): |
| 53 | + assert storage_admin.child('firebase-test-001').child('uploaded-file.txt').get_url(None) |
| 54 | + |
| 55 | + def test_download(self, storage_admin): |
| 56 | + assert storage_admin.child('firebase-test-001').child('uploaded-file.txt').download('tests/static/downloaded.txt') is None |
| 57 | + assert os.path.exists('tests/static/downloaded.txt') |
| 58 | + |
| 59 | + def test_delete(self, storage_admin): |
| 60 | + os.remove('tests/static/downloaded.txt') |
| 61 | + assert storage_admin.child('firebase-test-001/uploaded-file.txt').delete() is None |
| 62 | + |
| 63 | + def test_list_of_files(self, storage_admin): |
| 64 | + assert storage_admin.list_files() |
0 commit comments