<commit_before>import testutils
import json
import string
import psycopg2


class TestCollectionCount(testutils.BedquiltTestCase):

    def test_count_on_empty_collection(self):
        _ = self._query("select bq_create_collection('people');")
        result = self._query("""
        select bq_count('people');
        """)
        self.assertEqual(result, [(0,)])

    def test_count_on_non_exsistant_collection(self):
        result = self._query("""
        select bq_count('people')
        """)
        self.assertEqual(result, [(0,)])

class TestFindDocuments(testutils.BedquiltTestCase):

    def test_find_on_empty_collection(self):

        queries = [
            {},
            {"likes": ["icecream"]},
            {"name": "Mike"},
            {"_id": "mike"}
        ]

        for q in queries:
            # find_one
            self.cur.execute("""
            select bq_find_one('people', '{query}')
            """.format(query=json.dumps(q)))
            result = self.cur.fetchall()
            self.assertEqual(result, [])

            # find
            self.cur.execute("""
            select bq_find('people', '{query}')
            """.format(query=json.dumps(q)))
            result = self.cur.fetchall()
            self.assertEqual(result, [])

    def test_find_one_existing_document(self):

        sarah = {'_id': "<EMAIL>",
                 'name': "Sarah",<commit_msg>[#5] Test with one document<commit_after>import testutils
import json
import string
import psycopg2


class TestCollectionCount(testutils.BedquiltTestCase):

    def test_count_on_empty_collection(self):
        _ = self._query("select bq_create_collection('people');")
        result = self._query("""
        select bq_count('people');
        """)
        self.assertEqual(result, [(0,)])

    def test_count_on_non_exsistant_collection(self):
        result = self._query("""
        select bq_count('people')
        """)
        self.assertEqual(result, [(0,)])

    def test_count_with_one_doc(self):
        _ = self._query("""
        select bq_insert('things', '{"a": 1}')
        """)

        result = self._query("""
        select bq_count('things')
        """)
        self.assertEqual(result, [(1,)])

class TestFindDocuments(testutils.BedquiltTestCase):

    def test_find_on_empty_collection(self):

        queries = [
            {},
            {"likes": ["icecream"]},
            {"name": "Mike"},
            {"_id": "mike"}
        ]

        for q in queries:
            # find_one
            self.cur.execute("""
            select bq_find_one('people', '{query}')
            """.format(query=json.dumps(q)))
            result = self.cur.fetchall()
            self.assertEqual(result, [])

            # find
            self.cur.execute("""
            select bq_find('people', '{query}')
            """.format(query=json.dumps(q)))
            result = self.cur.fetchall()
            self.assertEqual(result, [])

    def test_find_one_existing_document(self):

        sarah = {'_id': "<EMAIL>",
                 'name': "Sarah",
{'fraction_non_alphanumeric': 0.1501628664495114, 'fraction_numerical': 0.0029315960912052116, 'mean_word_length': 2.140081799591002, 'pattern_counts': {'":': 7, '<': 5, '<?xml version=': 0, '>': 5, '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': '5803083', 'n_tokens_mistral': 943, 'n_tokens_neox': 898, 'n_words': 152}