예제 #1
0
 def test_get_song(self):
     req = {
             'method': 'GET', 
             'args': ['group'], 
             'values': {'group': 'test2'}
             }
     self.assertEqual(request_handler(req)[0], "Despacito")
예제 #2
0
 def test_get_no_song(self):
     req = {
             'method': 'GET', 
             'args': ['group'], 
             'values': {'group': 'test1'}
             }
     self.assertEqual(request_handler(req), list())
예제 #3
0
 def test_get_invalid_group(self):
     req = {
             'method': 'GET', 
             'args': ['group'], 
             'values': {'group': 'test3'}
             }
     self.assertEqual(request_handler(req), "Invalid group")
예제 #4
0
 def test_get_no_group(self):
     req = {
             'method': 'GET', 
             'args': [], 
             'values': {}
             }
     self.assertEqual(request_handler(req), "Specify a group")
예제 #5
0
 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")
예제 #6
0
 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")
예제 #7
0
 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")
예제 #8
0
 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!")
예제 #9
0
 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")
예제 #10
0
 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))
예제 #11
0
                }
        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))