<commit_before>"""
state_tests.py
"""

import os

from os.path import splitext
from minicps.state import SQLiteState


def test_SQLiteState():

    # TODO: change to /tmp when install SQLitesutdio in ubuntu
    PATH = "temp/state_test_db.sqlite"

    # sqlite use text instead of VARCHAR
    SCHEMA = """
    CREATE TABLE state_test (
        name              TEXT NOT NULL,
        datatype          TEXT NOT NULL,
        value             TEXT,
        pid               INTEGER NOT NULL,
        PRIMARY KEY (name, pid)
    );
    """
    SCHEMA_INIT = """
        INSERT INTO state_test VALUES ('SENSOR1', 'int', '0', 1);
        INSERT INTO state_test VALUES ('SENSOR2', 'float', '0.0', 1);
        INSERT INTO state_test VALUES ('SENSOR3', 'int', '0.0', 2);
        INSERT INTO state_test VALUES ('ACTUATOR1', 'int', '1', 1);
        INSERT INTO state_test VALUES ('ACTUATOR2', 'int', '0', 1);
    """

    path, extension = splitext(PATH)
    sqlite_state = SQLiteState(path, extension)

    os.remove(PATH)
    sqlite_state._create(PATH, SCHEMA)<commit_msg>Use same tagname but different scope<commit_after>"""
state_tests.py
"""

import os

from os.path import splitext
from minicps.state import SQLiteState


def test_SQLiteState():

    # TODO: change to /tmp when install SQLitesutdio in ubuntu
    PATH = "temp/state_test_db.sqlite"

    # sqlite use text instead of VARCHAR
    SCHEMA = """
    CREATE TABLE state_test (
        name              TEXT NOT NULL,
        datatype          TEXT NOT NULL,
        value             TEXT,
        pid               INTEGER NOT NULL,
        PRIMARY KEY (name, pid)
    );
    """
    SCHEMA_INIT = """
        INSERT INTO state_test VALUES ('SENSOR1', 'int', '0', 1);
        INSERT INTO state_test VALUES ('SENSOR2', 'float', '0.0', 1);
        INSERT INTO state_test VALUES ('SENSOR3', 'int', '0.0', 1);
        INSERT INTO state_test VALUES ('SENSOR3', 'int', '0.0', 2);
        INSERT INTO state_test VALUES ('ACTUATOR1', 'int', '1', 1);
        INSERT INTO state_test VALUES ('ACTUATOR2', 'int', '0', 1);
    """

    path, extension = splitext(PATH)
    sqlite_state = SQLiteState(path, extension)

    os.remove(PATH)
    sqlite_state._create(PATH, SCHEMA)
{'fraction_non_alphanumeric': 0.11820224719101123, 'fraction_numerical': 0.01707865168539326, 'mean_word_length': 2.4193548387096775, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1418200', 'n_tokens_mistral': 780, 'n_tokens_neox': 696, 'n_words': 218}