<commit_before>from multiprocessing import Process

import pytest
import requests

import proxypool.proxy_server as proxy_server
from proxypool.config import HOST, PORT


@pytest.fixture
def api(db):
    db.put_list(['127.0.0.1:80', '127.0.0.1:443', '127.0.0.1:1080'])
    proxy_server.conn = db # replace with test db
    server = Process(target=proxy_server.server_run)
    server.start()
    yield 'http://{0}:{1}'.format(HOST, PORT)
    db.pop_list(3)
    server.terminate()

def test_server_get(db, api):
    proxies = ['127.0.0.1:80', '127.0.0.1:443', '127.0.0.1:1080']

    assert requests.get('{0}/get'.format(api)).json()['proxies'][0] in proxies

    assert requests.get('{0}/get/3'.format(api)).json()['proxies'].sort() == proxies.sort()

    assert requests.get('{0}/get/10'.format(api)).json()['proxies'].sort() == proxies.sort()

    assert db.count == requests.get('{0}/count'.format(api)).json()['count']
<commit_msg>add some asserts<commit_after>from multiprocessing import Process

import pytest
import requests

import proxypool.proxy_server as proxy_server
from proxypool.config import HOST, PORT


@pytest.fixture
def api(db):
    db.put_list(['127.0.0.1:80', '127.0.0.1:443', '127.0.0.1:1080'])
    proxy_server.conn = db # replace with test db
    server = Process(target=proxy_server.server_run)
    server.start()
    yield 'http://{0}:{1}'.format(HOST, PORT)
    db.pop_list(3)
    server.terminate()

def test_server_get(db, api):
    proxies = ['127.0.0.1:80', '127.0.0.1:443', '127.0.0.1:1080']

    assert requests.get('{}/get'.format(api)).json()['proxies'][0] in proxies

    assert requests.get('{}/get/proxy'.format(api)).status_code == 404

    assert requests.get('{}/get/0'.format(api)).json()['count'] == 0

    assert requests.get('{}/get/3'.format(api)).json()['proxies'].sort() == proxies.sort()

    assert requests.get('{}/get/10'.format(api)).json()['proxies'].sort() == proxies.sort()

    assert db.count == requests.get('{}/count'.format(api)).json()['count']

{'fraction_non_alphanumeric': 0.2062780269058296, 'fraction_numerical': 0.06527154957648232, 'mean_word_length': 4.298153034300792, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 12, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1639065', 'n_tokens_mistral': 816, 'n_tokens_neox': 744, 'n_words': 122}