Merge pull request #159 from snoyes/getProfiles

Add getProfiles action
This commit is contained in:
Alex Yatskov 2020-05-01 12:44:25 -07:00 committed by GitHub
commit a779fa673f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 0 deletions

View File

@ -222,6 +222,26 @@ guarantee that your application continues to function properly in the future.
}
```
* **getProfiles**
Retrieve the list of profiles.
*Sample request*:
```json
{
"action": "getProfiles",
"version": 6
}
```
*Sample result*:
```json
{
"result": ["User 1"],
"error": null
}
```
* **loadProfile**
Selects the profile specified in request.

View File

@ -262,6 +262,9 @@ class AnkiConnect:
def version(self):
return util.setting('apiVersion')
@util.api()
def getProfiles(self):
return self.window().pm.profiles()
@util.api()
def loadProfile(self, name):

View File

@ -14,6 +14,14 @@ class TestMisc(unittest.TestCase):
# sync
util.invoke('sync')
# getProfiles
profiles = util.invoke('getProfiles')
self.assertIsInstance(profiles, list)
self.assertGreater(len(profiles), 0)
# loadProfile
util.invoke('loadProfile', name=profiles[0])
# multi
actions = [util.request('version'), util.request('version'), util.request('version')]
results = util.invoke('multi', actions=actions)