예제 #1
0
 def test_page_multiple_args(self):
     sr = mow.SimpleRequest('1.2.3.4',
                            request='apply.cgi',
                            args={
                                'ab': 'cd',
                                'ef': 'gh'
                            })
     result = sr.create_url()
     self.assertIn('ab=cd', result)
     self.assertIn('ef=gh', result)
     self.assertIn('http://1.2.3.4/apply.cgi?', result)
     self.assertIn('&', result)
예제 #2
0
 def test_arguments(self):
     sr = mow.SimpleRequest('1.2.3.4', args={'color': 'red'})
     result = sr.create_url()
     self.assertEqual(result, 'http://1.2.3.4?color=red')
예제 #3
0
 def test_non_default_port(self):
     sr = mow.SimpleRequest('1.2.3.4', port=8080)
     result = sr.create_url()
     self.assertEqual(result, 'http://1.2.3.4:8080')
예제 #4
0
 def test_request_page(self):
     sr = mow.SimpleRequest('1.2.3.4', request='apply.cgi')
     result = sr.create_url()
     self.assertEqual(result, 'http://1.2.3.4/apply.cgi')
예제 #5
0
 def test_params(self):
     sr = mow.SimpleRequest('1.2.3.4', 500, 'apply.cgi', {'a': 'b'})
     self.assertEqual(sr.host, '1.2.3.4')
     self.assertEqual(sr.port, 500)
     self.assertEqual(sr.request, 'apply.cgi')
     self.assertEqual(sr.args, {'a': 'b'})
예제 #6
0
 def test_default_params(self):
     sr = mow.SimpleRequest('1.2.3.4')
     result = sr.create_url()
     self.assertEqual(result, 'http://1.2.3.4')
예제 #7
0
 def test_default_params(self):
     sr = mow.SimpleRequest('1.2.3.4')
     self.assertEqual(sr.host, '1.2.3.4')
     self.assertEqual(sr.port, 80)
     self.assertIsNone(sr.request)
     self.assertIsNone(sr.args)
예제 #8
0
 def test_invalid_args(self):
     with self.assertRaises(Exception):
         mow.SimpleRequest('1.2.3.4', args=44)
예제 #9
0
 def test_invalid_request(self):
     with self.assertRaises(Exception):
         mow.SimpleRequest('1.2.3.4', request=12)
예제 #10
0
 def test_invalid_port(self):
     with self.assertRaises(Exception):
         mow.SimpleRequest('1.2.3.4', port='80')
예제 #11
0
 def test_invalid_host(self):
     with self.assertRaises(Exception):
         mow.SimpleRequest(12)