Skip to content

Commit 5e0818d

Browse files
committed
remove hardcoded db name
1 parent c742429 commit 5e0818d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tests/encryption_/tests.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pymongo
77
from bson import json_util
88
from bson.binary import Binary
9+
from django.conf import settings
910
from django.core.management import call_command
1011
from django.db import connections, models
1112
from django.test import TransactionTestCase, modify_settings, override_settings
@@ -340,12 +341,13 @@ def test_patientrecord(self):
340341

341342
# Test encrypted patient record in unencrypted database.
342343
conn_params = connections["encrypted"].get_connection_params()
344+
db_name = settings.DATABASES["encrypted"]["NAME"]
343345
if conn_params.pop("auto_encryption_opts", False):
344346
# Call MongoClient instead of get_new_connection because
345347
# get_new_connection will return the encrypted connection
346348
# from the connection pool.
347349
with pymongo.MongoClient(**conn_params) as new_connection:
348-
patientrecords = new_connection["test_encrypted"].encryption__patientrecord.find()
350+
patientrecords = new_connection[db_name].encryption__patientrecord.find()
349351
ssn = patientrecords[0]["ssn"]
350352
self.assertTrue(isinstance(ssn, Binary))
351353

0 commit comments

Comments
 (0)