<s> """<STR_LIT>""" <EOL> from __future__ import division , absolute_import , print_function <EOL> from test . _common import unittest <EOL> from test import _common <EOL> import json <EOL> import beetsplug <EOL> from beets . library import Item , Album <EOL> beetsplug . __path__ = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> from beetsplug import web <EOL> class WebPluginTest ( _common . LibTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( WebPluginTest , self ) . setUp ( ) <EOL> for track in self . lib . items ( ) : <EOL> track . remove ( ) <EOL> self . lib . add ( Item ( title = u'<STR_LIT:title>' , path = '<STR_LIT>' , id = <NUM_LIT:1> ) ) <EOL> self . lib . add ( Item ( title = u'<STR_LIT>' , path = '<STR_LIT>' , id = <NUM_LIT:2> ) ) <EOL> self . lib . add ( Album ( album = u'<STR_LIT>' , id = <NUM_LIT:3> ) ) <EOL> self . lib . add ( Album ( album = u'<STR_LIT>' , id = <NUM_LIT:4> ) ) <EOL> web . app . config [ '<STR_LIT>' ] = True <EOL> web . app . config [ '<STR_LIT>' ] = self . lib <EOL> self . client = web . app . test_client ( ) <EOL> def test_get_all_items ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> response . json = json . loads ( response . data ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( len ( response . json [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> def test_get_single_item_by_id ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> response . json = json . loads ( response . data ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . json [ '<STR_LIT:id>' ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( response . json [ '<STR_LIT:title>' ] , u'<STR_LIT:title>' ) <EOL> def test_get_multiple_items_by_id ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> response . json = json . loads ( response . data ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( len ( response . json [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> response_titles = [ item [ '<STR_LIT:title>' ] for item in response . json [ '<STR_LIT>' ] ] <EOL> self . assertItemsEqual ( response_titles , [ u'<STR_LIT:title>' , u'<STR_LIT>' ] ) <EOL> def test_get_single_item_not_found ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> def test_get_item_empty_query ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> response . json = json . loads ( response . data ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( len ( response . json [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> def test_get_simple_item_query ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> response . json = json . loads ( response . data ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( len ( response . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( response . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:title>' ] , <EOL> u'<STR_LIT>' ) <EOL> def test_get_all_albums ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> response . json = json . loads ( response . data ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> response_albums = [ album [ '<STR_LIT>' ] for album in response . json [ '<STR_LIT>' ] ] <EOL> self . assertItemsEqual ( response_albums , [ u'<STR_LIT>' , u'<STR_LIT>' ] ) <EOL> def test_get_single_album_by_id ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> response . json = json . loads ( response . data ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . json [ '<STR_LIT:id>' ] , <NUM_LIT:2> ) <EOL> self . assertEqual ( response . json [ '<STR_LIT>' ] , u'<STR_LIT>' ) <EOL> def test_get_multiple_albums_by_id ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> response . json = json . loads ( response . data ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> response_albums = [ album [ '<STR_LIT>' ] for album in response . json [ '<STR_LIT>' ] ] <EOL> self . assertItemsEqual ( response_albums , [ u'<STR_LIT>' , u'<STR_LIT>' ] ) <EOL> def test_get_album_empty_query ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> response . json = json . loads ( response . data ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( len ( response . json [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> def suite ( ) : <EOL> return unittest . TestLoader ( ) . loadTestsFromName ( __name__ ) <EOL> if __name__ == b'<STR_LIT:__main__>' : <EOL> unittest . main ( defaultTest = '<STR_LIT>' ) </s>
