"""
=============================================================================

    This module contains tests for the functionalities in the database module.

=============================================================================

    Copyright 2022 ACK Cyfronet AGH. All Rights Reserved.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

=============================================================================

    This work was supported by the EuroHPC PL project funded at the Smart Growth
    Operational Programme 2014-2020, Measure 4.2 under the grant agreement no.
    POIR.04.02.00-00-D014/20-00.

=============================================================================
"""

__author__ = "Tomasz Rybotycki"

import os
import unittest

from aqmlator.database import export_data_to_sqlite_database


class TestDatabaseFunctionalities(unittest.TestCase):
    """
    A `TestCase` class for the functionalities in the `database` module.
    """

    def setUp(self) -> None:
        """
        Sets up the class for the tests.
        """
        self.sqlite_db_name: str = "aqmlatorSQLite.db"

    def tearDown(self) -> None:
        """
        Cleans up after tests.
        """
        if os.path.exists(self.sqlite_db_name):
            os.remove(self.sqlite_db_name)

    def test_exporting_to_sqlite_database(self) -> None:
        """
        Checks if the SQLite database is properly created.
        """
        export_data_to_sqlite_database(self.sqlite_db_name)
        self.assertTrue(os.path.exists(self.sqlite_db_name))
