|
2 | 2 |
|
3 | 3 | from slack_sdk.oauth.installation_store import Installation |
4 | 4 | from slack_sdk.oauth.installation_store.sqlite3 import SQLite3InstallationStore |
| 5 | +from tests.helpers import async_test |
5 | 6 |
|
6 | 7 |
|
7 | 8 | class TestSQLite3(unittest.TestCase): |
@@ -138,19 +139,58 @@ def test_org_installation(self): |
138 | 139 | self.assertIsNone(i) |
139 | 140 |
|
140 | 141 | # delete installations |
141 | | - store.delete_installation(enterprise_id="E111", team_id=None) |
142 | | - i = store.find_installation(enterprise_id="E111", team_id=None) |
| 142 | + store.delete_installation(enterprise_id="EO111", team_id=None, user_id="UO111") |
| 143 | + i = store.find_installation(enterprise_id="EO111", team_id=None, user_id="UO111") |
| 144 | + self.assertIsNone(i) |
| 145 | + |
| 146 | + store.save(installation) |
| 147 | + store.delete_installation(enterprise_id="EO111", team_id=None) |
| 148 | + i = store.find_installation(enterprise_id="EO111", team_id=None) |
143 | 149 | self.assertIsNone(i) |
144 | 150 |
|
145 | 151 | # delete all |
146 | 152 | store.save(installation) |
147 | | - store.delete_all(enterprise_id="E111", team_id=None) |
| 153 | + store.delete_all(enterprise_id="EO111", team_id=None) |
148 | 154 |
|
149 | | - i = store.find_installation(enterprise_id="E111", team_id=None) |
| 155 | + i = store.find_installation(enterprise_id="EO111", team_id=None) |
| 156 | + self.assertIsNone(i) |
| 157 | + i = store.find_installation(enterprise_id="EO111", team_id=None, user_id="UO111") |
150 | 158 | self.assertIsNone(i) |
151 | | - i = store.find_installation(enterprise_id="E111", team_id=None, user_id="U111") |
| 159 | + bot = store.find_bot(enterprise_id="EO111", team_id=None) |
| 160 | + self.assertIsNone(bot) |
| 161 | + |
| 162 | + @async_test |
| 163 | + async def test_async_delete(self): |
| 164 | + store = SQLite3InstallationStore(database="logs/test.db", client_id="111.222") |
| 165 | + installation = Installation( |
| 166 | + app_id="A111", |
| 167 | + enterprise_id="E111", |
| 168 | + team_id="T111", |
| 169 | + user_id="U111", |
| 170 | + bot_id="B111", |
| 171 | + bot_token="xoxb-111", |
| 172 | + bot_scopes=["chat:write"], |
| 173 | + bot_user_id="U222", |
| 174 | + ) |
| 175 | + await store.async_save(installation) |
| 176 | + |
| 177 | + # delete installations |
| 178 | + await store.async_delete_installation(enterprise_id="E111", team_id="T111", user_id="U111") |
| 179 | + i = await store.async_find_installation(enterprise_id="E111", team_id="T111", user_id="U111") |
| 180 | + self.assertIsNone(i) |
| 181 | + |
| 182 | + # delete bots |
| 183 | + await store.async_delete_bot(enterprise_id="E111", team_id="T111") |
| 184 | + bot = await store.async_find_bot(enterprise_id="E111", team_id="T111") |
| 185 | + self.assertIsNone(bot) |
| 186 | + |
| 187 | + # delete all |
| 188 | + await store.async_save(installation) |
| 189 | + await store.async_delete_all(enterprise_id="E111", team_id="T111") |
| 190 | + |
| 191 | + i = await store.async_find_installation(enterprise_id="E111", team_id="T111") |
152 | 192 | self.assertIsNone(i) |
153 | | - bot = store.find_bot(enterprise_id=None, team_id="T222") |
| 193 | + bot = await store.async_find_bot(enterprise_id="E111", team_id="T111") |
154 | 194 | self.assertIsNone(bot) |
155 | 195 |
|
156 | 196 | def test_save_and_find_token_rotation(self): |
|
0 commit comments