<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest
import sqlite3
import mosql.sqlite
from mosql.util import param
from mosql.query import insert, select, update, delete, replace
from mosql.db import Database, all_to_dicts

class TestSQLite(unittest.TestCase):

    def setUp(self):

        self.db = Database(sqlite3, 'test_sqlite.db')

        with self.db as cur:
            cur.execute('''
                CREATE TABLE IF NOT EXISTS person (
                    person_id TEXT PRIMARY KEY,
                    name      TEXT
                );
            ''')

    def test_insert(self):
        with self.db as cur:
            cur.execute(insert('person', {
                'person_id': 'mosky',
                'name'     : '<NAME>'
            }))
            self.db._conn.rollback()

    def test_replace(self):
        with self.db as cur:
            cur.execute(replace('person', {
                'person_id': 'mosky',
                'name'     : '<NAME>'
            }))
            self.db._conn.rollback()

    def test_update(self):
        with self.db as cur:
            cur.execute(update('person', {'person_id': 'mosky'}, {'name': '<NAME>'}))<commit_msg>patch it as sqlite before every test in test_sqlite.py<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest
import sqlite3
import mosql.sqlite
from mosql.util import param
from mosql.query import insert, select, update, delete, replace
from mosql.db import Database, all_to_dicts

class TestSQLite(unittest.TestCase):

    def setUp(self):

        mosql.sqlite.patch()

        self.db = Database(sqlite3, 'test_sqlite.db')

        with self.db as cur:
            cur.execute('''
                CREATE TABLE IF NOT EXISTS person (
                    person_id TEXT PRIMARY KEY,
                    name      TEXT
                );
            ''')

    def test_insert(self):
        with self.db as cur:
            cur.execute(insert('person', {
                'person_id': 'mosky',
                'name'     : '<NAME>'
            }))
            self.db._conn.rollback()

    def test_replace(self):
        with self.db as cur:
            cur.execute(replace('person', {
                'person_id': 'mosky',
                'name'     : '<NAME>'
            }))
            self.db._conn.rollback()

    def test_update(self):
        with self.db as cur:
            cur.execute(update('person', {'person_id': 'mosky'}, {'name': '<NAME>'}))
{'fraction_non_alphanumeric': 0.12424607961399277, 'fraction_numerical': 0.0024125452352231603, 'mean_word_length': 1.710239651416122, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '74670', 'n_tokens_mistral': 750, 'n_tokens_neox': 705, 'n_words': 180}