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
                break
283
284
        rv = self.app.get('/counter')
285
        self.assertEqual(rv.status_code, 200)
286
        data = json.loads(utils.text(rv.data))
287
        self.assertGreater(len(data), 0)
288
        self.assertGreater(data['test_project']['5m']['success'], 3)
289
        self.assertGreater(data['test_project']['1h']['success'], 3)
290
        self.assertGreater(data['test_project']['1d']['success'], 3)
291
        self.assertGreater(data['test_project']['all']['success'], 3)
292
293
    def test_a15_queues(self):
294
        rv = self.app.get('/queues')
295
        self.assertEqual(rv.status_code, 200)
296
        data = json.loads(utils.text(rv.data))
297
        self.assertGreater(len(data), 0)
298
        self.assertIn('scheduler2fetcher', data)
299
        self.assertIn('fetcher2processor', data)
300
        self.assertIn('processor2result', data)
301
        self.assertIn('newtask_queue', data)
302
        self.assertIn('status_queue', data)
303
304
    def test_a20_tasks(self):
305
        rv = self.app.get('/tasks')