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)
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')
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')
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')
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'})
def test_default_params(self): sr = mow.SimpleRequest('1.2.3.4') result = sr.create_url() self.assertEqual(result, 'http://1.2.3.4')
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)
def test_invalid_args(self): with self.assertRaises(Exception): mow.SimpleRequest('1.2.3.4', args=44)
def test_invalid_request(self): with self.assertRaises(Exception): mow.SimpleRequest('1.2.3.4', request=12)
def test_invalid_port(self): with self.assertRaises(Exception): mow.SimpleRequest('1.2.3.4', port='80')
def test_invalid_host(self): with self.assertRaises(Exception): mow.SimpleRequest(12)