# Path: test/test_functionality.py
# class TestWithQGISLauncher(unittest.TestCase):
#     """
#     All test classes who want to have a QGIS application available with the plugin set up should
#     inherit this
#     """
# 
#     @classmethod
#     def setUpClass(cls):
#         os.environ["QGIS_DEBUG"] = str(-1)
# 
#         QtCore.QCoreApplication.setOrganizationName('QGIS')
#         QtCore.QCoreApplication.setApplicationName('QGIS2')
# 
#         # OLD (that is
#         # prefix = os_util.get_possible_prefix_path() if PREFIX_PATH is None else PREFIX_PATH
#         # QgsApplication.setPrefixPath(prefix, True)
#         # QgsApplication.initQgis()
#         #
#         # if len(QgsProviderRegistry.instance().providerList()) == 0:
#         #     raise Exception("Could not detect the QGIS prefix path. Maybe you installed "
#         #                     "QGIS in a non standard location. It is possible to figure "
#         #                     "this from the Python console within a running QGIS. Type  "
#         #                     "QgsApplication.showSettings().split(\"\\t\") and look for a " \
#         #                     "filepath after the " \
#         #                     "word Prefix and "
#         #                     "then set it as "
#         #                     "PREFIX_PATH='foo' "
#         #                     "on the top of the "
#         #                     "file "
#         #                     "test_functionality.py")
# 
#     def setUp(self):
# 
#         prefix = os_util.get_possible_prefix_path() if PREFIX_PATH is None else PREFIX_PATH
# 
#         args = [arg.encode('utf-8') for arg in sys.argv]
#         self.qgs = QgsApplication(args, False)
#         self.qgs.setPrefixPath(prefix, True)
#         self.qgs.initQgis()
# 
#         self.iface = Mock()
#         self.ctrl = RiggedTimeManagerControl(self.iface)
#         self.ctrl.load()
#         self.tlm = self.ctrl.getTimeLayerManager()


from builtins import range
from qgis.core import QgsVectorLayer, QgsDataSourceURI, QgsApplication
from pyspatialite import dbapi2 as db
from datetime import datetime, timedelta
from timemanager.time_util import datetime_to_str, DEFAULT_FORMAT
from .test_functionality import TestWithQGISLauncher
from timemanager.query_builder import STRINGCAST_FORMAT, INT_FORMAT, STRING_FORMAT
from timemanager.layer_settings import LayerSettings
from mock import Mock
import os
import unittest
import timemanager.time_util as time_util
import timemanager.timevectorlayer as timevectorlayer
from __future__ import print_function
from __future__ import absolute_import

# if using ipython: do this on bash before
# export QT_API=pyqt



STARTTIME = 1420746289  # 8 January 2015
TEST_TABLE = "test_table"
DB_FILE = "testdata/test_db.sqlite"
DB_FILE_WITH_DATETIMES = "testdata/data_with_datetime.sqlite"
INTEGER_TIMESTAMP = "epoch_seconds"

# Path: test/test_functionality.py
# class TestWithQGISLauncher(unittest.TestCase):
#     """
#     All test classes who want to have a QGIS application available with the plugin set up should
#     inherit this
#     """
# 
#     @classmethod
#     def setUpClass(cls):
#         os.environ["QGIS_DEBUG"] = str(-1)
# 
#         QtCore.QCoreApplication.setOrganizationName('QGIS')
#         QtCore.QCoreApplication.setApplicationName('QGIS2')
# 
#         # OLD (that is
#         # prefix = os_util.get_possible_prefix_path() if PREFIX_PATH is None else PREFIX_PATH
#         # QgsApplication.setPrefixPath(prefix, True)
#         # QgsApplication.initQgis()
#         #
#         # if len(QgsProviderRegistry.instance().providerList()) == 0:
#         #     raise Exception("Could not detect the QGIS prefix path. Maybe you installed "
#         #                     "QGIS in a non standard location. It is possible to figure "
#         #                     "this from the Python console within a running QGIS. Type  "
#         #                     "QgsApplication.showSettings().split(\"\\t\") and look for a " \
#         #                     "filepath after the " \
#         #                     "word Prefix and "
#         #                     "then set it as "
#         #                     "PREFIX_PATH='foo' "
#         #                     "on the top of the "
#         #                     "file "
#         #                     "test_functionality.py")
# 
#     def setUp(self):
# 
#         prefix = os_util.get_possible_prefix_path() if PREFIX_PATH is None else PREFIX_PATH
# 
#         args = [arg.encode('utf-8') for arg in sys.argv]
#         self.qgs = QgsApplication(args, False)
#         self.qgs.setPrefixPath(prefix, True)
#         self.qgs.initQgis()
# 
#         self.iface = Mock()
#         self.ctrl = RiggedTimeManagerControl(self.iface)
#         self.ctrl.load()
#         self.tlm = self.ctrl.getTimeLayerManager()


# Path: test/spatialite_experiments.py
from builtins import range
from qgis.core import QgsVectorLayer, QgsDataSourceURI, QgsApplication
from pyspatialite import dbapi2 as db
from datetime import datetime, timedelta
from timemanager.time_util import datetime_to_str, DEFAULT_FORMAT
from .test_functionality import TestWithQGISLauncher
from timemanager.query_builder import STRINGCAST_FORMAT, INT_FORMAT, STRING_FORMAT
from timemanager.layer_settings import LayerSettings
from mock import Mock
import os
import unittest
import timemanager.time_util as time_util
import timemanager.timevectorlayer as timevectorlayer

from __future__ import print_function
from __future__ import absolute_import

# if using ipython: do this on bash before
# export QT_API=pyqt



STARTTIME = 1420746289  # 8 January 2015
TEST_TABLE = "test_table"
DB_FILE = "testdata/test_db.sqlite"
DB_FILE_WITH_DATETIMES = "testdata/data_with_datetime.sqlite"
INTEGER_TIMESTAMP = "epoch_seconds"

STRING_TIMESTAMP = "datetime"