def test_connect(self):
        """Tests the connect function"""

        self.assertRaises(
            OperationalError,
            dbc.MySQLConnection(
                'mysql+pymysql://{user}:{password}@{host}/{database}', 'host',
                '3333', 'db', 'user', 'password').connect, [None])
        self.assertEqual(
            None,
            dbc.MySQLConnection(
                MOCK_URI.format(
                    file=path.join(MOCK_DIR, '../resources/dbmanagr.sqlite')),
                'host', '3333', 'db', 'user', 'password').connect(None))
        self.assertEqual(
            None,
            dbc.MySQLConnection(
                MOCK_URI.format(
                    file=path.join(MOCK_DIR, '../resources/dbmanagr.sqlite')),
                'host', '3333', 'db', 'user', 'password').connect(None))
        self.assertEqual(
            None,
            dbc.MySQLConnection(
                MOCK_URI.format(
                    file=path.join(MOCK_DIR, '../resources/dbmanagr.sqlite')),
                'host', '3333', 'db', 'user', 'password').connect('db'))
        self.assertEqual(
            None,
            dbc.MySQLConnection(
                MOCK_URI.format(file=path.join(
                    MOCK_DIR, '../resources/{database}/dbmanagr.sqlite')),
                'host', '3333', 'db', 'user', 'password').connect('db'))
    def test_connect(self):
        """Tests the connect function"""

        self.assertRaises(
            OperationalError,
            dbc.MySQLConnection(
                'mysql+pymysql://{user}:{password}@{host}/{database}',
                'host', '3333', 'db', 'user', 'password'
            ).connect,
            [None]
        )
        self.assertEqual(
            None,
            dbc.MySQLConnection(
                MOCK_URI.format(
                    file=path.join(MOCK_DIR, '../resources/dbmanagr.sqlite')),
                'host', '3333', 'db', 'user', 'password'
            ).connect(None)
        )
        self.assertEqual(
            None,
            dbc.MySQLConnection(
                MOCK_URI.format(
                    file=path.join(MOCK_DIR, '../resources/dbmanagr.sqlite')),
                'host', '3333', 'db', 'user', 'password'
            ).connect(None)
        )
        self.assertEqual(
            None,
            dbc.MySQLConnection(
                MOCK_URI.format(
                    file=path.join(
                        MOCK_DIR, '../resources/dbmanagr.sqlite')),
                'host', '3333', 'db', 'user', 'password'
            ).connect('db')
        )
        self.assertEqual(
            None,
            dbc.MySQLConnection(
                MOCK_URI.format(
                    file=path.join(
                        MOCK_DIR, '../resources/{database}/dbmanagr.sqlite')),
                'host', '3333', 'db', 'user', 'password'
            ).connect('db')
        )
Example #3
0
    def test_connected(self):
        """Tests the DatabaseConnection connected method"""

        con = databaseconnection.DatabaseConnection()
        con.connect_to(
            MOCK_URI.format(
                file=path.join(MOCK_DIR, '../resources/dbmanagr.sqlite')))

        self.assertEquals(True, con.connected())

        con.close()
    def test_connected(self):
        """Tests the DatabaseConnection connected method"""

        con = databaseconnection.DatabaseConnection()
        con.connect_to(MOCK_URI.format(
            file=path.join(
                MOCK_DIR, '../resources/dbmanagr.sqlite')))

        self.assertEquals(
            True,
            con.connected()
        )

        con.close()
    def test_databases(self):
        """Tests the DatabaseConnection databases method"""

        con = databaseconnection.DatabaseConnection()
        con.connect_to(MOCK_URI.format(
            file=path.join(
                MOCK_DIR, '../resources/dbnav.sqlite')))

        self.assertEquals(
            [],
            con.databases()
        )

        con.close()