<commit_before>import unittest

from provdbconnector.exceptions.database import InvalidOptionsException, AuthException
from provdbconnector.db_adapters.neo4j import Neo4jAdapter, NEO4J_USER, NEO4J_PASS, NEO4J_HOST, NEO4J_BOLT_PORT
from provdbconnector.provapi import ProvApi
from provdbconnector.tests import AdapterTestTemplate
from provdbconnector.tests import ProvApiTestTemplate


class Neo4jAdapterTests(AdapterTestTemplate):
    def setUp(self):
        self.instance = Neo4jAdapter()
        auth_info = {"user_name": NEO4J_USER,
                     "user_password": <PASSWORD>,
                     "host": NEO4J_HOST + ":" + NEO4J_BOLT_PORT
                     }
        self.instance.connect(auth_info)

    @unittest.skip(
        "Skipped because the server configuration currently is set to 'no password', so the authentication will never fail")
    def test_connect_fails(self):
        auth_info = {"user_name": NEO4J_USER,
                     "user_password": '<PASSWORD>',
                     "host": NEO4J_HOST + ":" + NEO4J_BOLT_PORT
                     }
        self.instance.connect(auth_info)
        with self.assertRaises(AuthException):
            self.instance.connect(auth_info)

    def test_connect_invalid_options(self):
        auth_info = {"u": NEO4J_USER,
                     "p": 'xxxxxx',
                     "h": NEO4J_HOST + ":" + NEO4J_BOLT_PORT
                     }
        with self.assertRaises(InvalidOptionsException):
            self.instance.connect(auth_info)

    def tearDown(self):
        session = self.instance._create_session()
        session.run("MATCH (x) DETACH DELETE x")
        del self.instance


class Neo4jAdapterProvApiTests(ProvApiTestTemplate):
    def setUp(self):
        self.auth_info = {"user_name": NEO4J_USER,
                          "user_password": <PASSWORD>,<commit_msg>- add delete to setup method (because if a test fails the teardown method don't execute)<commit_after>import unittest

from provdbconnector.exceptions.database import InvalidOptionsException, AuthException
from provdbconnector.db_adapters.neo4j import Neo4jAdapter, NEO4J_USER, NEO4J_PASS, NEO4J_HOST, NEO4J_BOLT_PORT
from provdbconnector.provapi import ProvApi
from provdbconnector.tests import AdapterTestTemplate
from provdbconnector.tests import ProvApiTestTemplate


class Neo4jAdapterTests(AdapterTestTemplate):
    def setUp(self):
        self.instance = Neo4jAdapter()
        auth_info = {"user_name": NEO4J_USER,
                     "user_password": <PASSWORD>,
                     "host": NEO4J_HOST + ":" + NEO4J_BOLT_PORT
                     }
        self.instance.connect(auth_info)
        session = self.instance._create_session()
        session.run("MATCH (x) DETACH DELETE x")

    @unittest.skip(
        "Skipped because the server configuration currently is set to 'no password', so the authentication will never fail")
    def test_connect_fails(self):
        auth_info = {"user_name": NEO4J_USER,
                     "user_password": '<PASSWORD>',
                     "host": NEO4J_HOST + ":" + NEO4J_BOLT_PORT
                     }
        self.instance.connect(auth_info)
        with self.assertRaises(AuthException):
            self.instance.connect(auth_info)

    def test_connect_invalid_options(self):
        auth_info = {"u": NEO4J_USER,
                     "p": 'xxxxxx',
                     "h": NEO4J_HOST + ":" + NEO4J_BOLT_PORT
                     }
        with self.assertRaises(InvalidOptionsException):
            self.instance.connect(auth_info)

    def tearDown(self):
        session = self.instance._create_session()
        session.run("MATCH (x) DETACH DELETE x")
        del self.instance


class Neo4jAdapterProvApiTests(ProvApiTestTemplate):
    def setUp(self):
        self.auth_info = {"user_name": NEO4J_USER,
                          "user_password": NEO4J_PASS,
{'fraction_non_alphanumeric': 0.087782340862423, 'fraction_numerical': 0.010010266940451745, 'mean_word_length': 2.575229357798165, 'pattern_counts': {'":': 28, '<': 8, '<?xml version=': 0, '>': 8, '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': '5323695', 'n_tokens_mistral': 1183, 'n_tokens_neox': 1137, 'n_words': 235}