-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from unsonic.models import Share | ||
from unsonic.views.rest.createshare import CreateShare | ||
from . import buildCmd, checkResp | ||
|
||
|
||
def testCreateShare(session): | ||
desc = "share1 description" | ||
slist = ["tr-1", "al-2", "tr-3"] | ||
cmd = buildCmd(session, CreateShare, {"description": desc, "id": slist}) | ||
checkResp(cmd.req, cmd()) | ||
row = session.query(Share).filter(Share.description == desc).one_or_none() | ||
assert row is not None | ||
assert row.entries[0].track_id == 1 | ||
assert row.entries[1].album_id == 2 | ||
assert row.entries[2].track_id == 3 | ||
assert row.user.name == "test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from unsonic.models import Share | ||
from unsonic.views.rest.createshare import CreateShare | ||
from unsonic.views.rest.deleteshare import DeleteShare | ||
from . import buildCmd, checkResp | ||
|
||
|
||
def testDeleteShare(session): | ||
desc = "share1 description" | ||
slist = ["tr-1", "al-2", "tr-3"] | ||
cmd = buildCmd(session, CreateShare, {"description": desc, "id": slist}) | ||
sub_resp = checkResp(cmd.req, cmd()) | ||
row = session.query(Share).filter(Share.description == desc).one_or_none() | ||
assert row is not None | ||
|
||
shares = sub_resp.find("{http://subsonic.org/restapi}shares") | ||
share = shares.find("{http://subsonic.org/restapi}share") | ||
sid = share.get("id") | ||
|
||
cmd = buildCmd(session, DeleteShare, {"id": sid}) | ||
checkResp(cmd.req, cmd()) | ||
row = session.query(Share).filter(Share.description == desc).one_or_none() | ||
assert row is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from unsonic.models import Share | ||
from unsonic.views.rest.createshare import CreateShare | ||
from unsonic.views.rest.getshares import GetShares | ||
from . import buildCmd, checkResp | ||
|
||
|
||
def testCreateShare(session): | ||
desc = "share1 description" | ||
slist = ["tr-1", "al-2", "tr-3"] | ||
cmd = buildCmd(session, CreateShare, {"description": desc, "id": slist}) | ||
sub_resp = checkResp(cmd.req, cmd()) | ||
row = session.query(Share).filter(Share.description == desc).one_or_none() | ||
assert row is not None | ||
|
||
shares = sub_resp.find("{http://subsonic.org/restapi}shares") | ||
share = shares.find("{http://subsonic.org/restapi}share") | ||
sid = share.get("id") | ||
|
||
cmd = buildCmd(session, GetShares, {"id": sid}) | ||
checkResp(cmd.req, cmd()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from unsonic.models import Share | ||
from unsonic.views.rest.createshare import CreateShare | ||
from unsonic.views.rest.updateshare import UpdateShare | ||
from . import buildCmd, checkResp | ||
|
||
|
||
def testUpdateShare(session): | ||
desc = "share1 description" | ||
slist = ["tr-1", "al-2", "tr-3"] | ||
cmd = buildCmd(session, CreateShare, {"description": desc, "id": slist}) | ||
sub_resp = checkResp(cmd.req, cmd()) | ||
|
||
shares = sub_resp.find("{http://subsonic.org/restapi}shares") | ||
share = shares.find("{http://subsonic.org/restapi}share") | ||
sid = share.get("id") | ||
|
||
ndesc = "new share1 description" | ||
cmd = buildCmd(session, UpdateShare, {"description": ndesc, "id": sid}) | ||
checkResp(cmd.req, cmd()) | ||
|
||
row = session.query(Share).filter(Share.description == ndesc).one_or_none() | ||
assert row is not None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters