예제 #1
0
 def test_get_cluster_inexistent(self):
     """
     Ensure that raises an exception when it is required to
     return a connection to a cluster that is not present in the config
     """
     pool = MongoPool(self.config)
     with self.assertRaises(AttributeError):
         pool.get_cluster('_doesntexist')
예제 #2
0
    def test_get_cluster_existent(self, ReconnectingConnection_mock):
        """
        Ensures that get_cluster returns the correct connection to a cluster
        """
        pool = MongoPool(self.config)
        pool.get_cluster('label1')

        ReconnectingConnection_mock.assert_called_once_with(**self.call_arguments)
        pool.db1
        # Test that is the same connection used for databases in mongoi dbpath
        ReconnectingConnection_mock.assert_called_once_with(**self.call_arguments)