# Path: boris/db_functions.py
# def load_events_in_db(pj: dict,
#                       selected_subjects: list,
#                       selected_observations: list,
#                       selected_behaviors: list,
#                       time_interval: str = TIME_FULL_OBS):
# def load_aggregated_events_in_db(pj: dict, selected_subjects: list, selected_observations: list,
#                                  selected_behaviors: list):
# def load_aggregated_events_in_intervals(pj: dict, selected_subjects: list, selected_observations: list,
#                                         selected_behaviors: list):


import os
import sys
import json
from boris import db_functions

        pj = json.loads(open("files/test.boris").read())

        ok, msg, db = db_functions.load_aggregated_events_in_db(pj, [], ["observation #1", "observation #2"], [])
        out = ""
        for line in db.iterdump():
            out += line + "\n"

        print(out == open("files/test_db_functions_test1").read())


    def test_not_ok(self):
        """
        test with observation with state events NOT PAIRED
        """

        pj = json.loads(open("files/test.boris").read())

        ok, msg, db = db_functions.load_aggregated_events_in_db(pj, [], ["live not paired"], [])

        assert ok == False


    def test_no_observation(self):
        """
        test with no observation
        """

        pj = json.loads(open("files/test.boris").read())


# Path: boris/db_functions.py
# def load_events_in_db(pj: dict,
#                       selected_subjects: list,
#                       selected_observations: list,
#                       selected_behaviors: list,
#                       time_interval: str = TIME_FULL_OBS):
# def load_aggregated_events_in_db(pj: dict, selected_subjects: list, selected_observations: list,
#                                  selected_behaviors: list):
# def load_aggregated_events_in_intervals(pj: dict, selected_subjects: list, selected_observations: list,
#                                         selected_behaviors: list):


# Path: tests/test_db_functions.py
import os
import sys
import json
from boris import db_functions


        pj = json.loads(open("files/test.boris").read())

        ok, msg, db = db_functions.load_aggregated_events_in_db(pj, [], ["observation #1", "observation #2"], [])
        out = ""
        for line in db.iterdump():
            out += line + "\n"

        print(out == open("files/test_db_functions_test1").read())


    def test_not_ok(self):
        """
        test with observation with state events NOT PAIRED
        """

        pj = json.loads(open("files/test.boris").read())

        ok, msg, db = db_functions.load_aggregated_events_in_db(pj, [], ["live not paired"], [])

        assert ok == False


    def test_no_observation(self):
        """
        test with no observation
        """

        pj = json.loads(open("files/test.boris").read())


        ok, msg, db = db_functions.load_aggregated_events_in_db(pj, [], [], [])