diff --git a/wp1/wikilang_db.py b/wp1/wikilang_db.py index e1fde4c9..61205b5b 100644 --- a/wp1/wikilang_db.py +++ b/wp1/wikilang_db.py @@ -1,9 +1,10 @@ from functools import partial -from wp1.db import connect +from wp1.db import connect as db_connect def connect(lang): - db = f'{lang}wiki_p' - host = f'{db}.analytics.db.svc.eqiad.wmflabs' - return connect('WIKIDB', host=replica_host, db=db) + wiki = f'{lang}wiki' + db = f'{wiki}_p' + host = f'{wiki}.analytics.db.svc.eqiad.wmflabs' + return db_connect('WIKIDB', host=host, db=db) diff --git a/wp1/wikilang_db_test.py b/wp1/wikilang_db_test.py new file mode 100644 index 00000000..d47bfb76 --- /dev/null +++ b/wp1/wikilang_db_test.py @@ -0,0 +1,14 @@ +import unittest +from unittest.mock import patch + +import wp1.wikilang_db + + +class WikiLangDbTest(unittest.TestCase): + + @patch('wp1.wikilang_db.db_connect') + def test_connect(self, mock_connect): + wp1.wikilang_db.connect('fr') + + mock_connect.assert_called_once_with( + 'WIKIDB', host='frwiki.analytics.db.svc.eqiad.wmflabs', db='frwiki_p')