def test_replica_set_uri_has_correct_root_credentials(self):
     config = MONGO_CONFIG.copy()
     mongo = MongoDB(config)
     uri = mongo.replica_set_uri()
     prefix, _ = uri.split('@')
     _, user, password = prefix.split(':')
     user = user.lstrip("/")
     self.assertEqual("root", user)
     self.assertEqual(password, config['root_password'])
    def test_replica_set_uri_sets_correct_credentials(self):
        config = MONGO_CONFIG.copy()
        mongo = MongoDB(config)

        credentials = {"username": "******", "password": "******"}
        uri = mongo.replica_set_uri(credentials)
        prefix, _ = uri.split('@')
        _, user, password = prefix.split(':')
        user = user.lstrip("/")
        self.assertEqual(credentials["username"], user)
        self.assertEqual(password, credentials["password"])
 def test_replica_set_uri_contains_correct_number_of_hosts(self):
     config = MONGO_CONFIG.copy()
     mongo = MongoDB(config)
     uri = mongo.replica_set_uri()
     host_list = uri.split(',')
     self.assertEqual(len(host_list), config['num_peers'])