|
30 | 30 | from geonode.storage.exceptions import DataRetrieverExcepion |
31 | 31 | from geonode.storage.manager import StorageManager |
32 | 32 | from geonode.storage.gcs import GoogleStorageManager |
33 | | -from geonode.storage.dropbox import DropboxStorageManager |
34 | 33 | from geonode.base.populate_test_data import create_single_dataset |
35 | 34 | from geonode.tests.base import GeoNodeBaseTestSupport |
36 | 35 |
|
37 | 36 |
|
38 | | -class TestDropboxStorageManager(SimpleTestCase): |
39 | | - def setUp(self): |
40 | | - with self.settings(DROPBOX_OAUTH2_TOKEN="auth_token"): |
41 | | - self.sut = DropboxStorageManager() |
42 | | - |
43 | | - @patch("geonode.storage.dropbox.DropBoxStorage.delete") |
44 | | - def test_dropbox_deleted(self, dbx): |
45 | | - """ |
46 | | - Will test that the function returns the expected result |
47 | | - and that the DropBoxStorage function as been called with the expected parameters |
48 | | - """ |
49 | | - dbx.return_value = None |
50 | | - output = self.sut.delete("filename") |
51 | | - self.assertIsNone(output) |
52 | | - dbx.assert_called_once_with("filename") |
53 | | - |
54 | | - @patch("geonode.storage.dropbox.DropBoxStorage.exists") |
55 | | - def test_dropbox_exists(self, dbx): |
56 | | - """ |
57 | | - Will test that the function returns the expected result |
58 | | - and that the DropBoxStorage function as been called with the expected parameters |
59 | | - """ |
60 | | - dbx.return_value = True |
61 | | - output = self.sut.exists("filename") |
62 | | - self.assertTrue(output) |
63 | | - dbx.assert_called_once_with("filename") |
64 | | - |
65 | | - @patch("geonode.storage.dropbox.DropBoxStorage.listdir") |
66 | | - def test_dropbox_listdir(self, dbx): |
67 | | - """ |
68 | | - Will test that the function returns the expected result |
69 | | - and that the DropBoxStorage function as been called with the expected parameters |
70 | | - """ |
71 | | - dbx.return_value = (["folder1"], ["file1", "file2"]) |
72 | | - output = self.sut.listdir("Apps/") |
73 | | - self.assertTupleEqual((["folder1"], ["file1", "file2"]), output) |
74 | | - dbx.assert_called_once_with("Apps/") |
75 | | - |
76 | | - @patch("geonode.storage.dropbox.DropBoxStorage._open") |
77 | | - def test_dropbox_open(self, dbx): |
78 | | - """ |
79 | | - Will test that the function returns the expected result |
80 | | - and that the DropBoxStorage function as been called with the expected parameters |
81 | | - """ |
82 | | - dbx.return_value = io.StringIO() |
83 | | - output = self.sut.open("name", mode="xx") |
84 | | - self.assertEqual(type(output), io.StringIO().__class__) |
85 | | - dbx.assert_called_once_with("name", "xx") |
86 | | - |
87 | | - @patch("geonode.storage.dropbox.DropBoxStorage._full_path") |
88 | | - def test_dropbox_path(self, dbx): |
89 | | - """ |
90 | | - Will test that the function returns the expected result |
91 | | - and that the DropBoxStorage function as been called with the expected parameters |
92 | | - """ |
93 | | - dbx.return_value = "/opt/full/path/to/file" |
94 | | - output = self.sut.path("file") |
95 | | - self.assertEqual("/opt/full/path/to/file", output) |
96 | | - dbx.assert_called_once_with("file") |
97 | | - |
98 | | - @patch("geonode.storage.dropbox.DropBoxStorage.save") |
99 | | - def test_dropbox_save(self, dbx): |
100 | | - """ |
101 | | - Will test that the function returns the expected result |
102 | | - and that the DropBoxStorage function as been called with the expected parameters |
103 | | - """ |
104 | | - dbx.return_value = "cleaned_name" |
105 | | - output = self.sut.save("file_name", "content") |
106 | | - self.assertEqual("cleaned_name", output) |
107 | | - dbx.assert_called_once_with("file_name", "content") |
108 | | - |
109 | | - @patch("geonode.storage.dropbox.DropBoxStorage.size") |
110 | | - def test_dropbox_size(self, dbx): |
111 | | - """ |
112 | | - Will test that the function returns the expected result |
113 | | - and that the DropBoxStorage function as been called with the expected parameters |
114 | | - """ |
115 | | - dbx.return_value = 1 |
116 | | - output = self.sut.size("name") |
117 | | - self.assertEqual(1, output) |
118 | | - dbx.assert_called_once_with("name") |
119 | | - |
120 | | - |
121 | 37 | class TestGoogleStorageManager(SimpleTestCase): |
122 | 38 | def setUp(self): |
123 | 39 | self.sut = GoogleStorageManager |
|
0 commit comments