예제 #1
0
    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'))
예제 #2
0
    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')
        )
예제 #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()
예제 #4
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_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()