Exemplo n.º 1
0
    def test_get_database(self):
        """Test the `get_database() method."""

        connection._databases = {'first': 1, 'second': 2}

        self.assertEqual(connection.get_database('first'), 1)
        self.assertEqual(connection.get_database('second'), 2)
Exemplo n.º 2
0
    def test_get_database(self):
        """Test the `get_database() method."""

        connection._databases = {'first': 1, 'second': 2}

        self.assertEqual(connection.get_database('first'), 1)
        self.assertEqual(connection.get_database('second'), 2)
Exemplo n.º 3
0
    def test_get_database_connectionerror(self):
        """Test that `get_database()` raises `ConnectionError`."""

        # First with an empty _databases
        with self.assertRaises(connection.ConnectionError):
            connection.get_database('invalidnamethatdoesntexist')

        # Then with _databases
        connection._databases = {'first': 1, 'second': 2}
        with self.assertRaises(connection.ConnectionError):
            connection.get_database('invalidnamethatdoesntexist')
Exemplo n.º 4
0
    def test_get_database_connectionerror(self):
        """Test that `get_database()` raises `ConnectionError`."""

        # First with an empty _databases
        with self.assertRaises(connection.ConnectionError):
            connection.get_database('invalidnamethatdoesntexist')

        # Then with _databases
        connection._databases = {'first': 1, 'second': 2}
        with self.assertRaises(connection.ConnectionError):
            connection.get_database('invalidnamethatdoesntexist')