Merge lp:~jelmer/brz/config-win32 into lp:brz/3.2

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/config-win32
Merge into: lp:brz/3.2
Diff against target: 94 lines (+65/-1)
2 files modified
breezy/bedding.py (+7/-1)
breezy/tests/test_bedding.py (+58/-0)
To merge this branch: bzr merge lp:~jelmer/brz/config-win32
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Aleksandr Smyshliaev (community) Approve
Review via email: mp+414133@code.launchpad.net

Commit message

Require that AppData is known on Windows. (Aleksandr Smyshliaev, Jelmer Vernooij)

Description of the change

Require that AppData is known on Windows.

Derived from lp:~a1s/brz/3.2 (and with appropriate author).

To post a comment you must log in.
Revision history for this message
Aleksandr Smyshliaev (a1s) :
review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) :
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/bedding.py'
--- breezy/bedding.py 2020-06-01 19:35:12 +0000
+++ breezy/bedding.py 2022-01-14 14:42:31 +0000
@@ -96,7 +96,13 @@
96 if base is None:96 if base is None:
97 base = win32utils.get_appdata_location()97 base = win32utils.get_appdata_location()
98 if base is None:98 if base is None:
99 base = win32utils.get_home_location()99 # Assume that AppData location is ALWAYS DEFINED,
100 # and don't look for %HOME%, as we aren't sure about
101 # where the files should be stored in %HOME%:
102 # on other platforms the directory is ~/.config/,
103 # but that would be incompatible with older Bazaar versions.
104 raise RuntimeError('Unable to determine AppData location')
105
100 if base is None:106 if base is None:
101 base = os.environ.get('XDG_CONFIG_HOME')107 base = os.environ.get('XDG_CONFIG_HOME')
102 if base is None:108 if base is None:
103109
=== modified file 'breezy/tests/test_bedding.py'
--- breezy/tests/test_bedding.py 2020-06-01 19:35:12 +0000
+++ breezy/tests/test_bedding.py 2022-01-14 14:42:31 +0000
@@ -26,6 +26,8 @@
26 tests,26 tests,
27 )27 )
2828
29if sys.platform == "win32":
30 from .. import win32utils
2931
30def override_whoami(test):32def override_whoami(test):
31 test.overrideEnv('EMAIL', None)33 test.overrideEnv('EMAIL', None)
@@ -96,6 +98,62 @@
96 self.bzr_home + '/authentication.conf')98 self.bzr_home + '/authentication.conf')
9799
98100
101class TestConfigPathFallbackWindows(tests.TestCaseInTempDir):
102
103 def mock_special_folder_path(self, csidl):
104 if csidl == win32utils.CSIDL_APPDATA:
105 return self.appdata
106 elif csidl == win32utils.CSIDL_PERSONAL:
107 return self.test_dir
108 return None
109
110 def setUp(self):
111 if sys.platform != 'win32':
112 raise tests.TestNotApplicable(
113 'This test is specific to Windows platform')
114 super(TestConfigPathFallbackWindows, self).setUp()
115 # Note: No HOME fallback on Windows. The configs MUST be in AppData,
116 # and we only fall back from breezy to bazaar configuration files.
117 self.appdata = os.path.join(self.test_dir, 'appdata')
118 self.appdata_bzr = os.path.join(self.appdata, 'bazaar', '2.0')
119 os.makedirs(self.appdata_bzr)
120 self.overrideAttr(
121 win32utils, "_get_sh_special_folder_path",
122 self.mock_special_folder_path)
123 # The safety net made by super() has set BZR_HOME and BRZ_HOME
124 # to the temporary directory. As they take precedence, we need
125 # to erase the variables in order to check Windows special folders.
126 self.overrideEnv('BRZ_HOME', None)
127 self.overrideEnv('BZR_HOME', None)
128
129 def test_config_dir(self):
130 self.assertIsSameRealPath(bedding.config_dir(), self.appdata_bzr)
131
132 def test_config_dir_is_unicode(self):
133 self.assertIsInstance(bedding.config_dir(), str)
134
135 def test_config_path(self):
136 self.assertIsSameRealPath(
137 bedding.config_path(),
138 self.appdata_bzr + '/bazaar.conf')
139 self.overrideAttr(win32utils, "get_appdata_location", lambda: None)
140 self.assertRaises(RuntimeError, bedding.config_path)
141
142 def test_locations_config_path(self):
143 self.assertIsSameRealPath(
144 bedding.locations_config_path(),
145 self.appdata_bzr + '/locations.conf')
146 self.overrideAttr(win32utils, "get_appdata_location", lambda: None)
147 self.assertRaises(RuntimeError, bedding.locations_config_path)
148
149 def test_authentication_config_path(self):
150 self.assertIsSameRealPath(
151 bedding.authentication_config_path(),
152 self.appdata_bzr + '/authentication.conf')
153 self.overrideAttr(win32utils, "get_appdata_location", lambda: None)
154 self.assertRaises(RuntimeError, bedding.authentication_config_path)
155
156
99class TestXDGConfigDir(tests.TestCaseInTempDir):157class TestXDGConfigDir(tests.TestCaseInTempDir):
100 # must be in temp dir because config tests for the existence of the bazaar158 # must be in temp dir because config tests for the existence of the bazaar
101 # subdirectory of $XDG_CONFIG_HOME159 # subdirectory of $XDG_CONFIG_HOME

Subscribers

People subscribed via source and target branches