|
@@ 113-132 (lines=20) @@
|
| 110 |
|
self.assertIsNotNone(m) |
| 111 |
|
self.assertIn('__START_URL__', json.loads(m.group(1))) |
| 112 |
|
|
| 113 |
|
def test_25_debug_post(self): |
| 114 |
|
rv = self.app.post('/debug/test_project', data={ |
| 115 |
|
'project-name': 'other_project', |
| 116 |
|
'start-urls': 'http://127.0.0.1:14887/pyspider/test.html', |
| 117 |
|
'script-mode': 'script', |
| 118 |
|
}) |
| 119 |
|
self.assertEqual(rv.status_code, 200) |
| 120 |
|
self.assertIn(b'debugger', rv.data) |
| 121 |
|
self.assertIn(b'var task_content = ', rv.data) |
| 122 |
|
self.assertIn(b'var script_content = ', rv.data) |
| 123 |
|
|
| 124 |
|
m = re.search(r'var task_content = (.*);\n', utils.text(rv.data)) |
| 125 |
|
self.assertIsNotNone(m) |
| 126 |
|
self.assertIn('test_project', m.group(1)) |
| 127 |
|
self.__class__.task_content = json.loads(m.group(1)) |
| 128 |
|
|
| 129 |
|
m = re.search(r'var script_content = (.*);\n', utils.text(rv.data)) |
| 130 |
|
self.assertIsNotNone(m) |
| 131 |
|
self.assertIn('127.0.0.1:14887', m.group(1)) |
| 132 |
|
self.__class__.script_content = json.loads(m.group(1)) |
| 133 |
|
|
| 134 |
|
def test_30_run(self): |
| 135 |
|
rv = self.app.post('/debug/test_project/run', data={ |
|
@@ 297-314 (lines=18) @@
|
| 294 |
|
self.assertIn('newtask_queue', data) |
| 295 |
|
self.assertIn('status_queue', data) |
| 296 |
|
|
| 297 |
|
def test_a20_tasks(self): |
| 298 |
|
rv = self.app.get('/tasks') |
| 299 |
|
self.assertEqual(rv.status_code, 200, rv.data) |
| 300 |
|
self.assertIn(b'SUCCESS</span>', rv.data) |
| 301 |
|
self.assertNotIn(b'>ERROR</span>', rv.data) |
| 302 |
|
m = re.search(r'/task/test_project:[^"]+', utils.text(rv.data)) |
| 303 |
|
self.assertIsNotNone(m) |
| 304 |
|
self.__class__.task_url = m.group(0) |
| 305 |
|
self.assertIsNotNone(self.task_url) |
| 306 |
|
m = re.search(r'/debug/test_project[^"]+', utils.text(rv.data)) |
| 307 |
|
self.assertIsNotNone(m) |
| 308 |
|
self.__class__.debug_task_url = m.group(0) |
| 309 |
|
self.assertIsNotNone(self.debug_task_url) |
| 310 |
|
|
| 311 |
|
rv = self.app.get('/tasks?project=test_project') |
| 312 |
|
self.assertEqual(rv.status_code, 200) |
| 313 |
|
self.assertIn(b'SUCCESS</span>', rv.data) |
| 314 |
|
self.assertNotIn(b'>ERROR</span>', rv.data) |
| 315 |
|
|
| 316 |
|
def test_a22_active_tasks(self): |
| 317 |
|
rv = self.app.get('/active_tasks') |