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)
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')