コード例 #1
0
def test_post_apmc_train_regression_ok(secrets_mock, test_client):
    secrets_mock.token_hex.return_value = 100

    customer, plain_password = create_customer()
    login_customer(test_client, customer.login, plain_password)

    pre_train_data = dict()
    pre_train_data['project_name'] = "Test project name"
    file_content = get_dataset_data('usa_dataset.csv')
    pre_train_data['file'] = (BytesIO(file_content.encode()),
                              'apmc_test_dataset.csv')
    pre_train_data['model_type'] = "regression"
    pre_train_data['normalization'] = False

    test_client.post(URL.APMC_PRE_TRAIN_POST,
                     data=pre_train_data,
                     content_type='multipart/form-data')

    apmc_data = APMCData.query.first()

    train_data = dict()
    train_data['data_id'] = apmc_data.id
    train_data['selected_model'] = "llr"

    response = test_client.post(URL.APMC_TRAIN_POST,
                                data=json.dumps(train_data),
                                content_type='application/json')

    assert response.status_code == 200
def test_get_add_feed_superuser(test_client):
    customer, plain_password = create_superuser_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.post(URL.USERPANEL_FEED_ADD)

    assert response.status_code == 200
    assert b'Add new feed' in response.data
コード例 #3
0
def test_get_userpanel(test_client):
    customer, plain_password = create_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_GET, follow_redirects=True)

    assert response.status_code == 200
    assert b'Dashboard' in response.data
コード例 #4
0
def test_get_logout_ok(test_client):
    customer, plain_password = create_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_LOGOUT_GET, follow_redirects=True)

    assert response.status_code == 200
    assert b'Login to your account' in response.data
コード例 #5
0
def test_get_statistics_all_models_with_normal_customer(test_client):
    customer, plain_password = create_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_STATISTICS_ALL_MODELS)

    assert response.status_code == 200
    assert b'You do not have access here!' in response.data
コード例 #6
0
def test_get_statistics_all_models(test_client):
    customer, plain_password = create_superuser_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_STATISTICS_ALL_MODELS)

    assert response.status_code == 200
    assert b'All models' in response.data
コード例 #7
0
def test_get_edit_profile(test_client):
    customer, plain_password = create_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_EDITPROFILE_GET)

    assert response.status_code == 200
    assert b'Edit profile' in response.data
コード例 #8
0
def test_get_all_emails_normal_customer(test_client):
    customer, plain_password = create_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_MAILS_ALL)

    assert response.status_code == 200
    assert b'You do not have access here!' in response.data
def test_get_generate_social_post_view_normal_customer(test_client):
    customer, plain_password = create_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_GENERATE_SOCIAL_POST, follow_redirects=True)

    assert response.status_code == 200
    assert b'You do not have access here!' in response.data
コード例 #10
0
def test_get_add_mail_package(test_client):
    customer, plain_password = create_superuser_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.post(URL.USERPANEL_ADD_PACKAGE)

    assert response.status_code == 200
    assert b'Add new package' in response.data
コード例 #11
0
def test_get_aggregator_run_view_normal_customer(test_client):
    customer, plain_password = create_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_RUN_AGGREGATOR, follow_redirects=True)

    assert response.status_code == 200
    assert b'You do not have access here!' in response.data
コード例 #12
0
def test_get_pages_with_normal_customer(test_client):
    customer, plain_password = create_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_PAGES_GET)

    assert response.status_code == 200
    assert b'You do not have access here!' in response.data
コード例 #13
0
def test_get_add_article_normal_customer(test_client):
    customer, plain_password = create_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_ARTICLE_ADD)

    assert response.status_code == 200
    assert b'You do not have access here!' in response.data
コード例 #14
0
def test_get_all_articles_super_user(test_client):
    customer, plain_password = create_superuser_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_ARTICLES_ALL)

    assert response.status_code == 200
    assert b'Articles' in response.data
コード例 #15
0
def test_get_run_scrapper_super_user(test_client):
    customer, plain_password = create_superuser_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_RUN_SCRAPPER)

    assert response.status_code == 200
    assert b'Run scrapper' in response.data
コード例 #16
0
def test_get_run_scrapper_normal_customer(test_client):
    customer, plain_password = create_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_RUN_SCRAPPER)

    assert response.status_code == 200
    assert b'You do not have access here!' in response.data
コード例 #17
0
def test_get_add_mail(test_client):
    customer, plain_password = create_superuser_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_MAIL_ADD)

    assert response.status_code == 200
    assert b'Add new e-mail' in response.data
コード例 #18
0
def test_get_page_add(test_client):
    customer, plain_password = create_superuser_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_PAGE_ADD_GET)

    assert response.status_code == 200
    assert b'Add new page' in response.data
コード例 #19
0
def test_get_feeds_view_superuser(test_client):
    customer, plain_password = create_superuser_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_FEEDS_ALL)

    assert b'Feed list' in response.data
    assert b'Feed 1' in response.data
    assert b'Feed 2' in response.data
コード例 #20
0
def test_get_mail_packages_view_superuser(test_client):
    customer, plain_password = create_superuser_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_ALL_PACKAGES)

    assert b'Mail packages' in response.data
    assert b'Test package 1' in response.data
    assert b'Test package 2' in response.data
コード例 #21
0
def test_get_dashboard(test_client):
    customer, plain_password = create_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_DASHBOARD_GET)

    assert response.status_code == 200
    assert customer.login in response.data.decode()
    assert 'Total calculations' in response.data.decode()
    assert 'Total visits' in response.data.decode()
コード例 #22
0
def test_get_article_details_view_normal_customer(test_client):
    customer, plain_password = create_customer()
    login_customer(test_client, customer.login, plain_password)

    articles_fixture = get_fixture('blog_aggregator_articles.json')

    for article_fixture in articles_fixture:
        response = test_client.get(f"{URL.USERPANEL_ARTICLE_DETAILS}{article_fixture.get('id')}")

        assert b'You do not have access here!' in response.data
コード例 #23
0
def test_get_customers(test_client):
    customer, plain_password = create_superuser_customer()
    login_customer(test_client, customer.login, plain_password)

    test_customer, _ = create_customer()

    response = test_client.get(URL.USERPANEL_CUSTOMERS_GET)

    assert response.status_code == 200
    assert test_customer.email in response.data.decode()
コード例 #24
0
def test_get_apmc_as_logged_in_user(test_client):
    customer, plain_password = create_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.APMC_GET)

    assert response.status_code == 200
    assert b'Your project name' in response.data
    assert b'Click to upload file' in response.data
    assert b'Pre-train' in response.data
コード例 #25
0
def test_get_all_emails_super_user(test_client):
    customer, plain_password = create_superuser_customer()
    login_customer(test_client, customer.login, plain_password)

    response = test_client.get(URL.USERPANEL_MAILS_ALL)

    assert response.status_code == 200
    assert b'Scrapped emails' in response.data
    assert b'*****@*****.**' in response.data
    assert b'*****@*****.**' in response.data
コード例 #26
0
def test_get_page_details(test_client):
    customer, plain_password = create_superuser_customer()
    login_customer(test_client, customer.login, plain_password)

    pages_fixture = get_pages_fixture()

    for page_fixture in pages_fixture:
        response = test_client.get(
            f"{URL.USERPANEL_PAGE_DETAILS_GET}{page_fixture.get('id')}")

        assert response.status_code == 200
コード例 #27
0
def test_post_add_mail_package_without_name(test_client):
    customer, plain_password = create_superuser_customer()
    login_customer(test_client, customer.login, plain_password)

    data = {'comment': 'Test package comment'}
    response = test_client.post(URL.USERPANEL_ADD_PACKAGE,
                                data=data,
                                follow_redirects=True)

    assert response.status_code == 200
    assert b'This field is required' in response.data
コード例 #28
0
def test_post_add_mail_package(test_client):
    customer, plain_password = create_superuser_customer()
    login_customer(test_client, customer.login, plain_password)

    data = {'name': 'Test package name', 'comment': 'Test package comment'}
    response = test_client.post(URL.USERPANEL_ADD_PACKAGE,
                                data=data,
                                follow_redirects=True)

    assert response.status_code == 200
    assert b'You have successfully added the package' in response.data
コード例 #29
0
def test_get_article_delete_view(test_client):
    customer, plain_password = create_superuser_customer()
    login_customer(test_client, customer.login, plain_password)

    articles_fixture = get_fixture('blog_aggregator_articles.json')

    for article_fixture in articles_fixture:
        response = test_client.get(f"{URL.USERPANEL_ARTICLE_DELETE}{article_fixture.get('id')}", follow_redirects=True)

        assert response.status_code == 200
        assert b'You have successfully delete the article' in response.data
コード例 #30
0
def test_get_mail_details_view_normal_customer(test_client):
    customer, plain_password = create_customer()
    login_customer(test_client, customer.login, plain_password)

    mails_fixture = get_fixture('ncbi_mails.json')

    for mail_fixture in mails_fixture:
        response = test_client.get(
            f"{URL.USERPANEL_MAIL_DETAILS}{mail_fixture.get('id')}")

        assert b'You do not have access here!' in response.data