Skip to content

Commit 00f89e9

Browse files
authored
Make SqliteAccountInfo.get_user_account_info_path private
1 parent adeed51 commit 00f89e9

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

b2sdk/account_info/sqlite_account_info.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class SqliteAccountInfo(UrlPoolAccountInfo):
4242
completed.
4343
"""
4444

45-
def __init__(self, file_name=None, last_upgrade_to_run=None, profile=None):
45+
def __init__(self, file_name=None, last_upgrade_to_run=None, profile: Optional[str] = None):
4646
"""
4747
Initialize SqliteAccountInfo.
4848
@@ -70,7 +70,7 @@ def __init__(self, file_name=None, last_upgrade_to_run=None, profile=None):
7070
"""
7171
self.thread_local = threading.local()
7272

73-
self.filename = self.get_user_account_info_path(file_name=file_name, profile=profile)
73+
self.filename = self._get_user_account_info_path(file_name=file_name, profile=profile)
7474
logger.debug('%s file path to use: %s', self.__class__.__name__, self.filename)
7575

7676
self._validate_database(last_upgrade_to_run)
@@ -90,7 +90,7 @@ def __init__(self, file_name=None, last_upgrade_to_run=None, profile=None):
9090
)
9191

9292
@classmethod
93-
def get_user_account_info_path(cls, file_name=None, profile=None):
93+
def _get_user_account_info_path(cls, file_name=None, profile=None):
9494
if profile and not B2_ACCOUNT_INFO_PROFILE_NAME_REGEXP.match(profile):
9595
raise ValueError('Invalid profile name: {}'.format(profile))
9696

test/unit/account_info/test_sqlite_account_info.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,54 +76,54 @@ def setup(self, monkeypatch):
7676

7777
def test_invalid_profile_name(self):
7878
with pytest.raises(ValueError):
79-
SqliteAccountInfo.get_user_account_info_path(profile='&@(*$')
79+
SqliteAccountInfo._get_user_account_info_path(profile='&@(*$')
8080

8181
def test_profile_and_file_name_conflict(self):
8282
with pytest.raises(ValueError):
83-
SqliteAccountInfo.get_user_account_info_path(file_name='foo', profile='bar')
83+
SqliteAccountInfo._get_user_account_info_path(file_name='foo', profile='bar')
8484

8585
def test_profile_and_env_var_conflict(self, monkeypatch):
8686
monkeypatch.setenv(B2_ACCOUNT_INFO_ENV_VAR, 'foo')
8787
with pytest.raises(ValueError):
88-
SqliteAccountInfo.get_user_account_info_path(profile='bar')
88+
SqliteAccountInfo._get_user_account_info_path(profile='bar')
8989

9090
def test_profile_and_xdg_config_env_var(self, monkeypatch):
9191
monkeypatch.setenv(XDG_CONFIG_HOME_ENV_VAR, os.path.join('~', 'custom'))
92-
account_info_path = SqliteAccountInfo.get_user_account_info_path(profile='secondary')
92+
account_info_path = SqliteAccountInfo._get_user_account_info_path(profile='secondary')
9393
assert account_info_path == os.path.expanduser(
9494
os.path.join('~', 'custom', 'b2', 'db-secondary.sqlite')
9595
)
9696

9797
def test_profile(self):
98-
account_info_path = SqliteAccountInfo.get_user_account_info_path(profile='foo')
98+
account_info_path = SqliteAccountInfo._get_user_account_info_path(profile='foo')
9999
assert account_info_path == os.path.expanduser(os.path.join('~', '.b2db-foo.sqlite'))
100100

101101
def test_file_name(self):
102-
account_info_path = SqliteAccountInfo.get_user_account_info_path(
102+
account_info_path = SqliteAccountInfo._get_user_account_info_path(
103103
file_name=os.path.join('~', 'foo')
104104
)
105105
assert account_info_path == os.path.expanduser(os.path.join('~', 'foo'))
106106

107107
def test_env_var(self, monkeypatch):
108108
monkeypatch.setenv(B2_ACCOUNT_INFO_ENV_VAR, os.path.join('~', 'foo'))
109-
account_info_path = SqliteAccountInfo.get_user_account_info_path()
109+
account_info_path = SqliteAccountInfo._get_user_account_info_path()
110110
assert account_info_path == os.path.expanduser(os.path.join('~', 'foo'))
111111

112112
def test_default_file_if_exists(self, monkeypatch):
113113
# ensure that XDG_CONFIG_HOME_ENV_VAR doesn't matter if default file exists
114114
monkeypatch.setenv(XDG_CONFIG_HOME_ENV_VAR, 'some')
115115
with open(os.path.expanduser(B2_ACCOUNT_INFO_DEFAULT_FILE), 'w') as account_file:
116116
account_file.write('')
117-
account_info_path = SqliteAccountInfo.get_user_account_info_path()
117+
account_info_path = SqliteAccountInfo._get_user_account_info_path()
118118
assert account_info_path == os.path.expanduser(B2_ACCOUNT_INFO_DEFAULT_FILE)
119119

120120
def test_xdg_config_env_var(self, monkeypatch):
121121
monkeypatch.setenv(XDG_CONFIG_HOME_ENV_VAR, os.path.join('~', 'custom'))
122-
account_info_path = SqliteAccountInfo.get_user_account_info_path()
122+
account_info_path = SqliteAccountInfo._get_user_account_info_path()
123123
assert account_info_path == os.path.expanduser(
124124
os.path.join('~', 'custom', 'b2', 'account_info')
125125
)
126126

127127
def test_default_file(self):
128-
account_info_path = SqliteAccountInfo.get_user_account_info_path()
128+
account_info_path = SqliteAccountInfo._get_user_account_info_path()
129129
assert account_info_path == os.path.expanduser(B2_ACCOUNT_INFO_DEFAULT_FILE)

0 commit comments

Comments
 (0)