Exemplo n.º 1
0
def test_items(app, client):
    title = 'Directory listing for /items/'
    with app.test_request_context():
        url = url_for('items', node=1)
        response = client.get(url)
        assert ((title in get_text(response) or 'No Such Resource' in get_text(response))
                and not is_mobileui(response))
Exemplo n.º 2
0
def test_page(app, client):
    with app.test_request_context():
        for view, title in VIEW_TITLE_MAP.items():
            url = url_for(view, node=1)
            response = client.get(url)
            assert title in get_text(response) and not is_mobileui(response)

    app.config['SCRAPYD_SERVERS'] = app.config['SCRAPYD_SERVERS'][::-1]
    with app.test_request_context():
        url = url_for('dashboard', node=1)
        response = client.get(url)
        assert 'status_code: -1' in get_text(response)

        for view, title in VIEW_TITLE_MAP.items():
            url = url_for(view, node=2)
            response = client.get(url)
            assert title in get_text(response) and not is_mobileui(response)
Exemplo n.º 3
0
def test_page(app, client):
    set_single_scrapyd(app)

    with app.test_request_context():
        for view, title in VIEW_TITLE_MAP.items():
            url = url_for(view, node=1)
            response = client.get(url)
            assert title in get_text(response) and not is_mobileui(response)
Exemplo n.º 4
0
def test_log_stats(app, client):
    with app.test_request_context():
        url = url_for('log',
                      node=1,
                      opt='stats',
                      project=PROJECT,
                      spider=SPIDER,
                      job=jobid,
                      ui='mobile')
        response = client.get(url)
        assert 'current_time' in get_text(response) and is_mobileui(response)
Exemplo n.º 5
0
def test_log_utf8(app, client):
    with app.test_request_context():
        url = url_for('log',
                      node=1,
                      opt='utf8',
                      project=PROJECT,
                      spider=SPIDER,
                      job=jobid,
                      ui='mobile')
        response = client.get(url)
        assert 'PROJECT (%s)' % PROJECT in get_text(response) and is_mobileui(
            response)
Exemplo n.º 6
0
def test_listprojects(app, client):
    # upload_file_deploy(app, client, filename='demo.egg', project=PROJECT, redirect_project=PROJECT)
    upload_file_deploy(app,
                       client,
                       filename='demo.zip',
                       project=PROJECT,
                       redirect_project=PROJECT)

    title = 'Get the list of projects uploaded'
    with app.test_request_context():
        url = url_for('manage', node=1)
        response = client.get(url)
        assert title in get_text(response) and not is_mobileui(response)
Exemplo n.º 7
0
def test_logs_inside(app, client):
    with app.test_request_context():
        for project, spider in [(PROJECT, None), (PROJECT, SPIDER)]:
            title = 'Directory listing for /logs/%s/%s' % (project, spider
                                                           or '')
            url = url_for('logs', node=1, project=project, spider=spider)
            response = client.get(url)
            text = get_text(response)
            assert title in text and not is_mobileui(response)

            if spider:
                url_run_spider = url_for('schedule.schedule',
                                         node=1,
                                         project=PROJECT,
                                         version=DEFAULT_LATEST_VERSION,
                                         spider=SPIDER)
                assert url_run_spider in text
Exemplo n.º 8
0
def test_dashboard(app, client):
    with app.test_request_context():
        url = url_for('dashboard', node=1, ui='mobile')
        response = client.get(url)
        assert 'dashboard - mobileui - ScrapydWeb' in get_text(
            response) and is_mobileui(response)
Exemplo n.º 9
0
def test_log_utf8_stats(app, client):
    upload_file_deploy(app,
                       client,
                       filename='demo.egg',
                       project=PROJECT,
                       redirect_project=PROJECT)

    with app.test_request_context():
        url = url_for('api',
                      node=1,
                      opt='start',
                      project=PROJECT,
                      version_spider_job=SPIDER)
        response = client.get(url)
        js = load_json(response)
        jobid = js['jobid']

        sleep()

        # Log page
        url = url_for('log',
                      node=1,
                      opt='utf8',
                      project=PROJECT,
                      spider=SPIDER,
                      job=jobid)
        response = client.get(url)
        assert 'log - ScrapydWeb' in get_text(
            response) and not is_mobileui(response)

        # Stats page
        url = url_for('log',
                      node=1,
                      opt='stats',
                      project=PROJECT,
                      spider=SPIDER,
                      job=jobid)
        response = client.get(url)
        assert 'Stats collection' in get_text(
            response) and not is_mobileui(response)

        # Dashboard page
        url = url_for('dashboard', node=1)
        response = client.get(url)
        url_stop = url_for('api',
                           node=1,
                           opt='stop',
                           project=PROJECT,
                           version_spider_job=jobid)
        assert url_stop in get_text(response)

        client.get(
            url_for('api',
                    node=1,
                    opt='forcestop',
                    project=PROJECT,
                    version_spider_job=jobid))

        # /1/schedule/ScrapydWeb-demo/default:%20the%20latest%20version/test/
        response = client.get(url)
        url_start = url_for('schedule.schedule',
                            node=1,
                            project=PROJECT,
                            version=DEFAULT_LATEST_VERSION,
                            spider=SPIDER)
        assert url_start in get_text(response)
Exemplo n.º 10
0
def test_parse_uploaded_demo_txt(app, client):
    with app.test_request_context():
        url = url_for('parse.uploaded', node=1, filename='demo.txt')
        response = client.get(url)
        assert 'Stats collection' in get_text(
            response) and not is_mobileui(response)