<commit_before>#!/usr/bin/env python

from time import sleep
from unittest import TestCase, main
import json
import requests

DIRB_ROOT = 'http://localhost:8000/'
TEST_ROOT = 'http://localhost:5000/'
BUST_RESOURCE_URL = DIRB_ROOT + 'bust'

class TestDirBustErl(TestCase):
    def setUp(self):
        self.session = requests.session()

    def start_bust(self, **params):
        return self.session.post(BUST_RESOURCE_URL, data=json.dumps(params),
                headers={'Content-Type': 'application/json'})

    def simple_bust(self, url):
        bust = self.start_bust(url=url, wordlist='TEST.txt',
                follow_dirs=True, follow_redirs=True, parse_body=True)
        self.assertEquals(bust.status_code, requests.codes.created)
        self.assertTrue(bust.url.startswith(DIRB_ROOT))
        return bust.headers['location']

    def test_smoke(self):
        bust_url = self.simple_bust(TEST_ROOT)
        _, bust_id = bust_url.rsplit('/', 1)
        for _ in xrange(500):
            sleep(0.1)
            results = self.session.get(BUST_RESOURCE_URL).json()
            result = next(r for r in results if r['id'] == bust_id)
            if result['status'] == 'finished':
                break
        else:
            self.fail("Bust didn't finish within 5 seconds")
        findings = self.session.get(bust_url).json()
        self.assertEquals(findings, [{'url': TEST_ROOT, 'code': requests.codes.ok}])


if __name__ == '__main__':
    main()<commit_msg>test_smoke: break long line<commit_after>#!/usr/bin/env python

from time import sleep
from unittest import TestCase, main
import json
import requests

DIRB_ROOT = 'http://localhost:8000/'
TEST_ROOT = 'http://localhost:5000/'
BUST_RESOURCE_URL = DIRB_ROOT + 'bust'

class TestDirBustErl(TestCase):
    def setUp(self):
        self.session = requests.session()

    def start_bust(self, **params):
        return self.session.post(BUST_RESOURCE_URL, data=json.dumps(params),
                headers={'Content-Type': 'application/json'})

    def simple_bust(self, url):
        bust = self.start_bust(url=url, wordlist='TEST.txt',
                follow_dirs=True, follow_redirs=True, parse_body=True)
        self.assertEquals(bust.status_code, requests.codes.created)
        self.assertTrue(bust.url.startswith(DIRB_ROOT))
        return bust.headers['location']

    def test_smoke(self):
        bust_url = self.simple_bust(TEST_ROOT)
        _, bust_id = bust_url.rsplit('/', 1)
        for _ in xrange(500):
            sleep(0.1)
            results = self.session.get(BUST_RESOURCE_URL).json()
            result = next(r for r in results if r['id'] == bust_id)
            if result['status'] == 'finished':
                break
        else:
            self.fail("Bust didn't finish within 5 seconds")
        findings = self.session.get(bust_url).json()
        self.assertEquals(findings,
                [{'url': TEST_ROOT, 'code': requests.codes.ok}])


if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.1289350301406564, 'fraction_numerical': 0.010046885465505693, 'mean_word_length': 2.819693094629156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '2941463', 'n_tokens_mistral': 979, 'n_tokens_neox': 949, 'n_words': 190}