def test_get_song(self): req = { 'method': 'GET', 'args': ['group'], 'values': {'group': 'test2'} } self.assertEqual(request_handler(req)[0], "Despacito")
def test_get_no_song(self): req = { 'method': 'GET', 'args': ['group'], 'values': {'group': 'test1'} } self.assertEqual(request_handler(req), list())
def test_get_invalid_group(self): req = { 'method': 'GET', 'args': ['group'], 'values': {'group': 'test3'} } self.assertEqual(request_handler(req), "Invalid group")
def test_get_no_group(self): req = { 'method': 'GET', 'args': [], 'values': {} } self.assertEqual(request_handler(req), "Specify a group")
def test_post_invalid_pass(self): req = { 'method': 'POST', 'args': [], 'values': {}, 'content-type': 'application/x-www-form-urlencoded', 'is_json': False, 'data': b'group=test1&password=pass1&action=pause&song=None', 'form': {'group': 'test2', 'password': '******', 'action':'pause', 'song': 'None'} } self.assertEqual(request_handler(req), "Incorrect group or password")
def test_post_no_action(self): req = { 'method': 'POST', 'args': [], 'values': {}, 'content-type': 'application/x-www-form-urlencoded', 'is_json': False, 'data': b'group=test1&password=pass1&action=&song=None', 'form': {'group': 'test1', 'password': '******', 'action':'', 'song': 'None'} } self.assertEqual(request_handler(req), "No action specified")
def test_post_resume(self): req = { 'method': 'POST', 'args': [], 'values': {}, 'content-type': 'application/x-www-form-urlencoded', 'is_json': False, 'data': b'group=test1&password=pass1&action=resume&song=None', 'form': {'group': 'test1', 'password': '******', 'action':'resume', 'song': 'None'} } self.assertEqual(request_handler(req), "Handle resume instructions here")
def test_post_play_s(self): req = { 'method': 'POST', 'args': [], 'values': {}, 'content-type': 'application/x-www-form-urlencoded', 'is_json': False, 'data': b'group=test2&password=pass2&action=play&song=Despacito', 'form': {'group': 'test2', 'password': '******', 'action':'play', 'song': 'Despacito'} } self.assertEqual(request_handler(req), "Song: Despacito added to the queue!")
def test_post_skip(self): req = { 'method': 'POST', 'args': [], 'values': {}, 'content-type': 'application/x-www-form-urlencoded', 'is_json': False, 'data': b'group=test2&password=pass2&action=skip&song=None', 'form': {'group': 'test2', 'password': '******', 'action':'skip', 'song': 'None'} } res = request_handler(req) self.assertEqual(res, "Handle skip instructions here")
def test_skip_with_two_songs(self): req = { 'method': 'POST', 'args': [], 'values': {}, 'content-type': 'application/x-www-form-urlencoded', 'is_json': False, 'data': b'group=test1&password=pass1&action=play&song=lovefool', 'form': {'group': 'test1', 'password': '******', 'action':'play', 'song': 'lovefool'} } self.assertEqual(request_handler(req), "Song: lovefool added to the queue!") req3 = { 'method': 'POST', 'args': [], 'values': {}, 'content-type': 'application/x-www-form-urlencoded', 'is_json': False, 'data': b'group=test1&password=pass1&action=finished&song=None', 'form': {'group': 'test1', 'password': '******', 'action':'finished', 'song': 'feverdream'} } print(request_handler(req3))
} print(request_handler(req3) print("\n\nAdd Song") req = { 'method': 'POST', 'args': [], 'values': {}, 'content-type': 'application/x-www-form-urlencoded', 'is_json': False, 'data': b'group=test1&password=pass1&action=play&song=lovefool', 'form': {'group': 'test1', 'password': '******', 'action':'play', 'song': 'test6'} } print(request_handler(req)) ''' print("\n\nSkip Song") req3 = { 'method': 'POST', 'args': [], 'values': {}, 'content-type': 'application/x-www-form-urlencoded', 'is_json': False, 'data': b'group=test1&password=pass1&action=finished&song=None', 'form': {'group': 'test1', 'password': '******', 'action':'finished', 'song': 'feverdream'} } print(request_handler(req3))