コード例 #1
0
    def test_autocomplete(self):
        """Tests the autocomplete function"""

        self.assertEqual(
            'user@host/db/',
            dbc.PostgreSQLConnection(
                'uri', 'host', '3333', 'db', 'user', 'password'
            ).autocomplete())
        self.assertEqual(
            'user@host/',
            dbc.PostgreSQLConnection(
                'uri', 'host', '3333', None, 'user', 'password'
            ).autocomplete())
コード例 #2
0
    def test_filter(self):
        """Tests the filter function"""

        self.assertEqual(
            True,
            dbc.PostgreSQLConnection(
                'uri', 'host', '3333', 'db', 'user', 'password'
            ).filter_(Config.init(['user@host/db/'], navigator.args.parser)))
        self.assertEqual(
            False,
            dbc.PostgreSQLConnection(
                'postgresql+pg8000://{user}:{password}@{host}/{database}',
                'host', '3333', 'db', 'user', 'password'
            ).filter_({'postgresql': Opts(user='******', host=None)}))
コード例 #3
0
    def test_subtitle(self):
        """Tests the subtitle function"""

        self.assertEqual(
            'PostgreSQL Connection',
            dbc.PostgreSQLConnection(
                'uri', 'host', '3333', 'db', 'user', 'password'
            ).subtitle())
コード例 #4
0
    def test_repr(self):
        """Tests the repr method"""

        con = dbc.PostgreSQLConnection(
            'postgresql+pg8000://{user}:{password}@{host}/{database}',
            'host', '3333', 'db', 'user', 'password'
        )

        self.assertEqual(repr(con), con.__repr__())
コード例 #5
0
    def test_matches(self):
        """Tests the matches method"""

        self.assertEqual(
            False,
            dbc.PostgreSQLConnection(
                'postgresql+pg8000://{user}:{password}@{host}/{database}',
                'host', '3333', 'db', 'user', 'password'
            ).matches(Opts(gen='foo@bar')))
コード例 #6
0
    def test_init_tables(self):
        """Tests the init_tables method"""

        self.assertRaises(
            Exception,
            dbc.PostgreSQLConnection(
                'postgresql+pg8000://{user}:{password}@{host}/{database}',
                'host', '3333', 'db', 'user', 'password'
            ).init_tables,
            [None])
コード例 #7
0
    def test_connect(self):
        """Tests the connect function"""

        self.assertRaises(
            InterfaceError,
            dbc.PostgreSQLConnection(
                'postgresql+pg8000://{user}:{password}@{host}/{database}',
                'host', '3333', 'db', 'user', 'password'
            ).connect,
            [None])
        self.assertEqual(
            None,
            dbc.PostgreSQLConnection(
                MOCK_URI.format(
                    file=path.join(MOCK_DIR, '../resources/dbmanagr.sqlite')),
                'host', '3333', 'db', 'user', 'password'
            ).connect(None))
        self.assertEqual(
            None,
            dbc.PostgreSQLConnection(
                MOCK_URI.format(
                    file=path.join(MOCK_DIR, '../resources/dbmanagr.sqlite')),
                'host', '3333', 'db', 'user', 'password'
            ).connect(None))
        self.assertEqual(
            None,
            dbc.PostgreSQLConnection(
                MOCK_URI.format(
                    file=path.join(
                        MOCK_DIR, '../resources/dbmanagr.sqlite')),
                'host', '3333', 'db', 'user', 'password'
            ).connect('db'))
        self.assertEqual(
            None,
            dbc.PostgreSQLConnection(
                MOCK_URI.format(
                    file=path.join(
                        MOCK_DIR, '../resources/{database}/dbmanagr.sqlite')),
                'host', '3333', 'db', 'user', 'password'
            ).connect('db'))
コード例 #8
0
    def test_databases(self):
        """Tests the databases function"""

        con = dbc.PostgreSQLConnection(
            'postgresql+pg8000://{user}:{password}@{host}/{database}',
            'host', '3333', 'db', 'user', 'password'
        )

        self.assertRaises(
            Exception,
            con.databases)

        con._databases = []
        self.assertEqual(
            [],
            con.databases())