<commit_before>import unittest
import datetime as dt
import sqlite3
import sjcx_payments.payments as payments
import os


class Payments(unittest.TestCase):

    def test_add_balances(self):
        conn = sqlite3.connect('data/test_rewards.db')
        cursor = conn.cursor()
        test_date = dt.datetime(2015, 11, 1, 0, 0, 0)
        payments.add_balances(conn, cursor, test_date)
        cursor.execute('''SELECT MAX(balance) FROM rewards WHERE payment_date=?''',
                       (str(test_date),))
        max_balance =cursor.fetchone()[0]
        self.assertTrue(max_balance > 0)
        conn.close()

    def test_assign_points(self):
        conn = sqlite3.connect('data/test_rewards.db')
        cursor = conn.cursor()
        test_date = dt.datetime(2015, 11, 1, 0, 0, 0)
        payments.assign_points(conn, cursor, test_date)
        cursor.execute('''SELECT MAX(points) FROM rewards WHERE payment_date=?''',
                       (str(test_date),))
        points = cursor.fetchone()[0]
        self.assertTrue(points > 0)
        conn.close()

    def test_distribute_sjcx(self):
        conn = sqlite3.connect('data/test_rewards.db')
        cursor = conn.cursor()
        test_date = dt.datetime(2015, 11, 1, 0, 0, 0)
        payments.distribute_sjcx(conn, cursor, test_date)
        cursor.execute('''SELECT SUM(sjcx_reward) FROM rewards WHERE
                          payment_date = ?''', (str(test_date),))
        total = cursor.fetchone()[0]
        self.assertAlmostEqual(total, 100000)
        conn.close()

    def test_update_total_rewards(self):
        conn = sqlite3.connect('data/test_rewards.db')
        cursor = conn.cursor()
        test_date = dt.datetime(2015, 11, 1, 0, 0, 0)
        payments.update_total_rewards(conn, cursor, test_date)
        cursor.execute('''SELECT MAX(total_usd_reward) FROM rewards WHERE
                          payment_date = ?''', (str(test_date),))
        usd_reward = cursor.fetchone()[0]
        self.assertTrue(usd_reward > 0)
        cursor.execute('''UPDATE rewards SET balance = 0, sjcx_reward = 0,<commit_msg>create test<commit_after>import unittest
import datetime as dt
import sqlite3
import sjcx_payments.payments as payments
import os


class Payments(unittest.TestCase):

    def test_add_balances(self):
        conn = sqlite3.connect('data/test_rewards.db')
        cursor = conn.cursor()
        test_date = dt.datetime(2015, 11, 1, 0, 0, 0)
        payments.add_balances(conn, cursor, test_date)
        cursor.execute('''SELECT MAX(balance) FROM rewards WHERE payment_date=?''',
                       (str(test_date),))
        max_balance =cursor.fetchone()[0]
        self.assertTrue(max_balance > 0)
        conn.close()

    def test_assign_points(self):
        conn = sqlite3.connect('data/test_rewards.db')
        cursor = conn.cursor()
        test_date = dt.datetime(2015, 11, 1, 0, 0, 0)
        payments.assign_points(conn, cursor, test_date)
        cursor.execute('''SELECT MAX(points) FROM rewards WHERE payment_date=?''',
                       (str(test_date),))
        points = cursor.fetchone()[0]
        self.assertTrue(points > 0)
        conn.close()

    def test_create_table(self):
        conn = sqlite3.connect('unittest.db')
        cursor = conn.cursor()
        payments.create_table(conn, cursor)
        dir = os.path.abspath('unittest.db')
        boolean = os.path.exists(dir)
        self.assertTrue(boolean)

    def test_distribute_sjcx(self):
        conn = sqlite3.connect('data/test_rewards.db')
        cursor = conn.cursor()
        test_date = dt.datetime(2015, 11, 1, 0, 0, 0)
        payments.distribute_sjcx(conn, cursor, test_date)
        cursor.execute('''SELECT SUM(sjcx_reward) FROM rewards WHERE
                          payment_date = ?''', (str(test_date),))
        total = cursor.fetchone()[0]
        self.assertAlmostEqual(total, 100000)
        conn.close()

    def test_update_total_rewards(self):
        conn = sqlite3.connect('data/test_rewards.db')
        cursor = conn.cursor()
        test_date = dt.datetime(2015, 11, 1, 0, 0, 0)
        payments.update_total_rewards(conn, cursor, test_date)
        cursor.execute('''SELECT MAX(total_usd_reward) FROM rewards WHERE
                          payment_date = ?''', (str(test_date),))
        usd_reward = cursor.fetchone()[0]
        self.assertTrue(usd_reward > 0)
        cursor.execute('''UPDATE rewards SET balance = 0, sjcx_reward = 0,
{'fraction_non_alphanumeric': 0.12340139107022662, 'fraction_numerical': 0.027148306035449855, 'mean_word_length': 2.6185064935064934, 'pattern_counts': {'":': 0, '<': 3, '<?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': '624484', 'n_tokens_mistral': 1486, 'n_tokens_neox': 1381, 'n_words': 281}