|
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): |
@@ -158,6 +159,40 @@ def test_org_installation(self): |
158 | 159 | bot = store.find_bot(enterprise_id="EO111", team_id=None) |
159 | 160 | self.assertIsNone(bot) |
160 | 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") |
| 192 | + self.assertIsNone(i) |
| 193 | + bot = await store.async_find_bot(enterprise_id="E111", team_id="T111") |
| 194 | + self.assertIsNone(bot) |
| 195 | + |
161 | 196 | def test_save_and_find_token_rotation(self): |
162 | 197 | store = SQLite3InstallationStore(database="logs/test.db", client_id="111.222") |
163 | 198 |
|
|
0 commit comments