<commit_before># -*- encoding: utf-8 -*-
#
# Copyright 2015 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import base64
import json
import shutil
import subprocess
import tempfile
import time

import testtools


class DCITestCase(testtools.TestCase):

    def setUp(self):
        super(DCITestCase, self).setUp()
        self._db_dir = tempfile.mkdtemp()
        subprocess.call(['initdb', '--no-locale', '--nosync', self._db_dir])
        subprocess.call(['sed', '-i',
                         "s,#listen_addresses.*,listen_addresses = '',",
                         '%s/postgresql.conf' % self._db_dir])
        self._pg = subprocess.Popen(['postgres', '-F',
                                     '-k', self._db_dir,
                                     '-D', self._db_dir])
        time.sleep(1)
        subprocess.call(['psql', '--quiet',
                         '--echo-hidden', '-h', self._db_dir,
                         '-f', 'db_schema/dci-control-server.sql',
                         'template1'])
        time.sleep(1)
        db_uri = (
            "postgresql:///?host=%s&dbname=template1" % self._db_dir)
        import server.app
        self.app = server.app.init_app(db_uri)
        self.app.config['TESTING'] = True
        self.test_client = self.app.test_client()

    def tearDown(self):
        super(DCITestCase, self).tearDown()
        self._pg.kill()
        time.sleep(2)
        shutil.rmtree(self._db_dir)

    def client_call(self, method, username, password, path, **argv):
        encoded_basic_auth = base64.b64encode(<commit_msg>test: wait 2 sec after DB schema init<commit_after># -*- encoding: utf-8 -*-
#
# Copyright 2015 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import base64
import json
import shutil
import subprocess
import tempfile
import time

import testtools


class DCITestCase(testtools.TestCase):

    def setUp(self):
        super(DCITestCase, self).setUp()
        self._db_dir = tempfile.mkdtemp()
        subprocess.call(['initdb', '--no-locale', '--nosync', self._db_dir])
        subprocess.call(['sed', '-i',
                         "s,#listen_addresses.*,listen_addresses = '',",
                         '%s/postgresql.conf' % self._db_dir])
        self._pg = subprocess.Popen(['postgres', '-F',
                                     '-k', self._db_dir,
                                     '-D', self._db_dir])
        time.sleep(1)
        subprocess.call(['psql', '--quiet',
                         '--echo-hidden', '-h', self._db_dir,
                         '-f', 'db_schema/dci-control-server.sql',
                         'template1'])
        time.sleep(2)
        db_uri = (
            "postgresql:///?host=%s&dbname=template1" % self._db_dir)
        import server.app
        self.app = server.app.init_app(db_uri)
        self.app.config['TESTING'] = True
        self.test_client = self.app.test_client()

    def tearDown(self):
        super(DCITestCase, self).tearDown()
        self._pg.kill()
        time.sleep(2)
        shutil.rmtree(self._db_dir)

    def client_call(self, method, username, password, path, **argv):
        encoded_basic_auth = base64.b64encode(
{'fraction_non_alphanumeric': 0.12404397705544933, 'fraction_numerical': 0.00979923518164436, 'mean_word_length': 2.2391640866873064, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6310800', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1203, 'n_words': 328}