Skip to content

Commit

Permalink
Add test and fix bugs test found
Browse files Browse the repository at this point in the history
  • Loading branch information
audiodude committed Aug 19, 2024
1 parent f68ba25 commit f667497
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
9 changes: 5 additions & 4 deletions wp1/wikilang_db.py
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 14 additions & 0 deletions wp1/wikilang_db_test.py
Original file line number Diff line number Diff line change
@@ -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')

0 comments on commit f667497

Please sign in to comment.