<commit_before>import pytest

import datetime
from test.utils import init_test_logging
from anchore_engine.clients.feeds.feed_service import get_client, InvalidCredentialsError
from anchore_engine.subsys import logger


feed_url = 'https://ancho.re/v1/service/feeds'
client_url = 'https://ancho.re/v1/account/users'
token_url = 'https://ancho.re/oauth/token'


init_test_logging(level='info')

def test_anon_user():
    test_client = get_client(feeds_url=feed_url,
                             token_url=token_url,
                             client_url=client_url,
                             user=('<EMAIL>', '<PASSWORD>'),
                             conn_timeout=3,
                             read_timeout=10)
    for f in test_client.list_feeds().feeds:
        try:
            test_client.list_feed_groups(f.name)
        except Exception as e:
            logger.error(('Caught: {} for feed:  {}'.format(e, f)))
    test_client.get_feed_group_data('vulnerabilities', 'alpine:3.6',since=datetime.datetime.utcnow())


def test_auth_error():
    with pytest.raises(InvalidCredentialsError):
        test_client = get_client(feeds_url=feed_url,
                                 token_url=token_url,
                                 client_url=client_url,
                                 user=('<EMAIL>', '<PASSWORD>'),
                                 conn_timeout=3,
                                 read_timeout=10)
        f = test_client.list_feeds()


def test_feed_sync():
    test_client = get_client(feeds_url=feed_url,
                             token_url=token_url,
                             client_url=client_url,
                             user=('<EMAIL>', '<PASSWORD>'),
                             conn_timeout=3,
                             read_timeout=10)
    for f in test_client.list_feeds().feeds:
        try:
            test_client.list_feed_groups(f.name)
        except Exception as e:
            logger.info(('Caught: {} for feed:  {}'.format(e, f)))


    next_token = False
    since_time = datetime.datetime.utcnow() - datetime.timedelta(days=2)
    since_time = None
    while next_token is not None:
        logger.info('Getting a page of data')
        if next_token:
            last_token = next_token
            logger.info(('Using token: {}'.format(next_token)))<commit_msg>update connection and read timeouts for integration test, to resolve intermittent failures from circleci to ancho.re for feed sync test<commit_after>import pytest

import datetime
from test.utils import init_test_logging
from anchore_engine.clients.feeds.feed_service import get_client, InvalidCredentialsError
from anchore_engine.subsys import logger


feed_url = 'https://ancho.re/v1/service/feeds'
client_url = 'https://ancho.re/v1/account/users'
token_url = 'https://ancho.re/oauth/token'


init_test_logging(level='info')

def test_anon_user():
    test_client = get_client(feeds_url=feed_url,
                             token_url=token_url,
                             client_url=client_url,
                             user=('<EMAIL>', 'pbiU2RYZ2XrmYQ'),
                             conn_timeout=10,
                             read_timeout=30)
    for f in test_client.list_feeds().feeds:
        try:
            test_client.list_feed_groups(f.name)
        except Exception as e:
            logger.error(('Caught: {} for feed:  {}'.format(e, f)))
    test_client.get_feed_group_data('vulnerabilities', 'alpine:3.6',since=datetime.datetime.utcnow())


def test_auth_error():
    with pytest.raises(InvalidCredentialsError):
        test_client = get_client(feeds_url=feed_url,
                                 token_url=token_url,
                                 client_url=client_url,
                                 user=('<EMAIL>', 'foobar'),
                                 conn_timeout=10,
                                 read_timeout=30)
        f = test_client.list_feeds()


def test_feed_sync():
    test_client = get_client(feeds_url=feed_url,
                             token_url=token_url,
                             client_url=client_url,
                             user=('<EMAIL>', 'pbiU2RYZ2XrmYQ'),
                             conn_timeout=10,
                             read_timeout=30)
    for f in test_client.list_feeds().feeds:
        try:
            test_client.list_feed_groups(f.name)
        except Exception as e:
            logger.info(('Caught: {} for feed:  {}'.format(e, f)))


    next_token = False
    since_time = datetime.datetime.utcnow() - datetime.timedelta(days=2)
    since_time = None
    while next_token is not None:
        logger.info('Getting a page of data')
        if next_token:
            last_token = next_token
            logger.info(('Using token: {}'.format(next_token)))
{'fraction_non_alphanumeric': 0.09935295345439366, 'fraction_numerical': 0.0073053642245877685, 'mean_word_length': 1.8884870403857745, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1209218', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1396, 'n_words': 246}