Code Duplication    Length = 18-20 lines in 2 locations

tests/test_webui.py 2 locations

@@ 112-131 (lines=20) @@
109
        m = re.search(r'var script_content = (.*);\n', utils.text(rv.data))
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):
@@ 285-302 (lines=18) @@
282
        self.assertGreater(data['test_project']['1h']['success'], 3)
283
        self.assertGreater(data['test_project']['1d']['success'], 3)
284
        self.assertGreater(data['test_project']['all']['success'], 3)
285
286
    def test_a15_queues(self):
287
        rv = self.app.get('/queues')
288
        self.assertEqual(rv.status_code, 200)
289
        data = json.loads(utils.text(rv.data))
290
        self.assertGreater(len(data), 0)
291
        self.assertIn('scheduler2fetcher', data)
292
        self.assertIn('fetcher2processor', data)
293
        self.assertIn('processor2result', data)
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)