Merge lp:~zematynnad/software-center/rename_host_var_918270 into lp:software-center

Proposed by Danny Tamez on 2012-01-18
Status: Merged
Merged at revision: 2678
Proposed branch: lp:~zematynnad/software-center/rename_host_var_918270
Merge into: lp:software-center
Diff against target: 236 lines (+31/-31)
3 files modified
README (+1/-1)
softwarecenter/enums.py (+7/-7)
test/test_database.py (+23/-23)
To merge this branch: bzr merge lp:~zematynnad/software-center/rename_host_var_918270
Reviewer Review Type Date Requested Status
Gary Lasker (community) 2012-01-18 Approve on 2012-01-18
Review via email: mp+89148@code.launchpad.net

Commit message

Environment variable rename.

Description of the change

Overview
========
This branch changes the name of one of the environment variables so that it is more easily understood.

Details
=======
The environment variable SOFTWARE_CENTER_BUY_HOST points to a software center agent host. So to clear up some confusion it has been renamed to SOFTWARE_CENTER_AGENT_HOST.
If an environment variable is found for SOFTWARE_CENTER_AGENT_HOST then it will be used. If it is not found then we will attempt to find and use SOFTWARE_CENTER_BUY_HOST.

To test:
$cd test
$make

To post a comment you must log in.
Gary Lasker (gary-lasker) wrote :

Very nice, Danny, thank you!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README'
2--- README 2012-01-18 14:39:10 +0000
3+++ README 2012-01-18 21:36:26 +0000
4@@ -45,7 +45,7 @@
5 SOFTWARE_CENTER_USE_BUILTIN_LOGIN - use built-in login instead of ubuntu-sso-client
6 SOFTWARE_CENTER_APPDETAILS_WEBKIT - use the webkit appdetails instead of gtk
7 APPVIEW_DEBUG_TERMS - show debug output for the terms in a search
8-SOFTWARE_CENTER_BUY_HOST - use a alternative hosts to query for pay software
9+SOFTWARE_CENTER_AGENT_HOST - use a alternative hosts to query for pay software
10 SOFTWARE_CENTER_REVIEWS_HOST - a alternative host for the ratings&reviews
11 SOFTWARE_CENTER_DEBUG_HTTP - enable httplib2 debuging
12
13
14=== modified file 'softwarecenter/enums.py'
15--- softwarecenter/enums.py 2012-01-05 15:20:45 +0000
16+++ softwarecenter/enums.py 2012-01-18 21:36:26 +0000
17@@ -27,12 +27,12 @@
18 SOFTWARE_CENTER_SSO_DESCRIPTION = _(
19 "To reinstall previous purchases, sign in to the "
20 "Ubuntu Single Sign-On account you used to pay for them.")
21-
22+
23
24 # buy-something base url
25 #BUY_SOMETHING_HOST = "http://localhost:8000/"
26-BUY_SOMETHING_HOST = os.environ.get("SOFTWARE_CENTER_BUY_HOST") or "https://software-center.ubuntu.com"
27-BUY_SOMETHING_HOST_ANONYMOUS = os.environ.get("SOFTWARE_CENTER_BUY_HOST") or "http://software-center.ubuntu.com"
28+BUY_SOMETHING_HOST = os.environ.get("SOFTWARE_CENTER_AGENT_HOST") or os.environ.get("SOFTWARE_CENTER_BUY_HOST") or "https://software-center.ubuntu.com"
29+BUY_SOMETHING_HOST_ANONYMOUS = os.environ.get("SOFTWARE_CENTER_AGENT_HOST") or os.environ.get("SOFTWARE_CENTER_BUY_HOST") or "http://software-center.ubuntu.com"
30
31 # recommender
32 RECOMMENDER_HOST = os.environ.get("SOFTWARE_CENTER_RECOMMENDER_HOST") or "https://recommender.software-center.ubuntu.com"
33@@ -43,7 +43,7 @@
34 SSO_LOGIN_HOST = UBUNTU_SSO_SERVICE
35
36
37-# version of the database, every time something gets added (like
38+# version of the database, every time something gets added (like
39 # terms for mime-type) increase this (but keep as a string!)
40 DB_SCHEMA_VERSION = "6"
41
42@@ -175,7 +175,7 @@
43 PURCHASED_BUT_REPO_MUST_BE_ENABLED,
44 ERROR,
45 # the package is not found in the DB or cache
46- NOT_FOUND,
47+ NOT_FOUND,
48 # this *needs* to be last (for test_appdetails.py) and means
49 # something went wrong and we don't have a state for this PKG
50 UNKNOWN,
51@@ -218,8 +218,8 @@
52 TOP_RATED_CAROUSEL_LIMIT = 12
53
54 from .version import VERSION, DISTRO, RELEASE, CODENAME
55-USER_AGENT="Software Center/%s (N;) %s/%s (%s)" % (VERSION,
56- DISTRO,
57+USER_AGENT="Software Center/%s (N;) %s/%s (%s)" % (VERSION,
58+ DISTRO,
59 RELEASE,
60 CODENAME)
61
62
63=== modified file 'test/test_database.py'
64--- test/test_database.py 2012-01-16 14:42:49 +0000
65+++ test/test_database.py 2012-01-18 21:36:26 +0000
66@@ -36,7 +36,7 @@
67 def test_update_from_desktop_file(self):
68 # ensure we index with german locales to test i18n
69 os.environ["LANGUAGE"] = "de"
70- db = xapian.WritableDatabase("./data/test.db",
71+ db = xapian.WritableDatabase("./data/test.db",
72 xapian.DB_CREATE_OR_OVERWRITE)
73 res = update_from_app_install_data(db, self.cache, datadir="./data/desktop")
74 self.assertTrue(res)
75@@ -48,7 +48,7 @@
76 self.assertEqual(i, 1)
77
78 def test_update_from_appstream_xml(self):
79- db = xapian.WritableDatabase("./data/test.db",
80+ db = xapian.WritableDatabase("./data/test.db",
81 xapian.DB_CREATE_OR_OVERWRITE)
82 res = update_from_appstream_xml(db, self.cache, "./data/app-info/")
83 self.assertTrue(res)
84@@ -64,7 +64,7 @@
85 def test_update_from_var_lib_apt_lists(self):
86 # ensure we index with german locales to test i18n
87 os.environ["LANGUAGE"] = "de"
88- db = xapian.WritableDatabase("./data/test.db",
89+ db = xapian.WritableDatabase("./data/test.db",
90 xapian.DB_CREATE_OR_OVERWRITE)
91 res = update_from_var_lib_apt_lists(db, self.cache, listsdir="./data/app-info/")
92 self.assertTrue(res)
93@@ -88,7 +88,7 @@
94
95 def test_update_from_json_string(self):
96 from softwarecenter.db.update import update_from_json_string
97- db = xapian.WritableDatabase("./data/test.db",
98+ db = xapian.WritableDatabase("./data/test.db",
99 xapian.DB_CREATE_OR_OVERWRITE)
100 cache = apt.Cache()
101 p = os.path.abspath("./data/app-info-json/apps.json")
102@@ -97,7 +97,7 @@
103 self.assertEqual(db.get_doccount(), 1)
104
105 def test_build_from_software_center_agent(self):
106- db = xapian.WritableDatabase("./data/test.db",
107+ db = xapian.WritableDatabase("./data/test.db",
108 xapian.DB_CREATE_OR_OVERWRITE)
109 cache = apt.Cache()
110 # monkey patch distro to ensure we get data
111@@ -114,7 +114,7 @@
112 doc = db.get_document(p.docid)
113 ppa = doc.get_value(XapianValues.ARCHIVE_PPA)
114 self.assertTrue(ppa.startswith("commercial-ppa") and
115- ppa.count("/") == 1,
116+ ppa.count("/") == 1,
117 "ARCHIVE_PPA value incorrect, got '%s'" % ppa)
118 self.assertTrue(
119 "-icon-" in doc.get_value(XapianValues.ICON))
120@@ -127,11 +127,11 @@
121 def test_license_string_data_from_software_center_agent(self):
122 from softwarecenter.testutils import get_test_pkg_info
123 #os.environ["SOFTWARE_CENTER_DEBUG_HTTP"] = "1"
124- os.environ["SOFTWARE_CENTER_BUY_HOST"] = "http://sc.staging.ubuntu.com/"
125+ os.environ["SOFTWARE_CENTER_AGENT_HOST"] = "http://sc.staging.ubuntu.com/"
126 # staging does not have a valid cert
127 os.environ["PISTON_MINI_CLIENT_DISABLE_SSL_VALIDATION"] = "1"
128 cache = get_test_pkg_info()
129- db = xapian.WritableDatabase("./data/test.db",
130+ db = xapian.WritableDatabase("./data/test.db",
131 xapian.DB_CREATE_OR_OVERWRITE)
132 res = update_from_software_center_agent(db, cache, ignore_cache=True)
133 self.assertTrue(res)
134@@ -140,7 +140,7 @@
135 license = doc.get_value(XapianValues.LICENSE)
136 self.assertNotEqual(license, "")
137 self.assertNotEqual(license, None)
138- del os.environ["SOFTWARE_CENTER_BUY_HOST"]
139+ del os.environ["SOFTWARE_CENTER_AGENT_HOST"]
140
141 def test_application(self):
142 db = StoreDatabase("/var/cache/software-center/xapian", self.cache)
143@@ -149,7 +149,7 @@
144 self.assertRaises(ValueError, AppDetails, db)
145
146 def test_application_details(self):
147- db = xapian.WritableDatabase("./data/test.db",
148+ db = xapian.WritableDatabase("./data/test.db",
149 xapian.DB_CREATE_OR_OVERWRITE)
150 res = update_from_app_install_data(db, self.cache, datadir="./data/desktop")
151 self.assertTrue(res)
152@@ -191,7 +191,7 @@
153 self.assertTrue(len(appdetails.version) > 2)
154 # FIXME: screenshots will only work on ubuntu
155 self.assertTrue(re.match(
156- "http://screenshots.ubuntu.com/screenshot-with-version/software-center/[\d.]+",
157+ "http://screenshots.ubuntu.com/screenshot-with-version/software-center/[\d.]+",
158 appdetails.screenshot))
159 self.assertTrue(re.match(
160 "http://screenshots.ubuntu.com/thumbnail-with-version/software-center/[\d.]+",
161@@ -210,9 +210,9 @@
162 from softwarecenter.distro import get_distro
163 distro = get_distro().get_codename()
164 self.assertEqual(app.request, 'channel=' + distro + '-partner')
165-
166+
167 def ensure_installation_date_and_lazy_history_loading(self, appdetails):
168- # we run two tests, the first is to ensure that we get a
169+ # we run two tests, the first is to ensure that we get a
170 # result from installation_data immediately (at this point the
171 # history is not loaded yet) so we expect "None"
172 self.assertEqual(appdetails.installation_date, None)
173@@ -227,7 +227,7 @@
174 self.assertNotEqual(appdetails.installation_date, None)
175
176 def test_package_states(self):
177- db = xapian.WritableDatabase("./data/test.db",
178+ db = xapian.WritableDatabase("./data/test.db",
179 xapian.DB_CREATE_OR_OVERWRITE)
180 res = update_from_app_install_data(db, self.cache, datadir="./data/desktop")
181 self.assertTrue(res)
182@@ -282,37 +282,37 @@
183 doc = m.document
184 doc.get_value(value_time) >= last_time
185 last_time = doc.get_value(value_time)
186-
187+
188 # FIXME: re-enable both tests once sc.staging.ubuntu.com has the new
189 # version of scagent with support for the publication date
190 def disabled_test_for_purchase_apps_date_published(self):
191 from softwarecenter.testutils import get_test_pkg_info
192 #os.environ["SOFTWARE_CENTER_DEBUG_HTTP"] = "1"
193- os.environ["SOFTWARE_CENTER_BUY_HOST"] = "http://sc.staging.ubuntu.com/"
194+ os.environ["SOFTWARE_CENTER_AGENT_HOST"] = "http://sc.staging.ubuntu.com/"
195 # staging does not have a valid cert
196 os.environ["PISTON_MINI_CLIENT_DISABLE_SSL_VALIDATION"] = "1"
197 cache = get_test_pkg_info()
198- db = xapian.WritableDatabase("./data/test.db",
199+ db = xapian.WritableDatabase("./data/test.db",
200 xapian.DB_CREATE_OR_OVERWRITE)
201 res = update_from_software_center_agent(db, cache, ignore_cache=True)
202 self.assertTrue(res)
203-
204+
205 for p in db.postlist(""):
206 doc = db.get_document(p.docid)
207 date_published = doc.get_value(XapianValues.DATE_PUBLISHED)
208 # make sure that a date_published value is provided
209 self.assertNotEqual(date_published, "")
210 self.assertNotEqual(date_published, None)
211- del os.environ["SOFTWARE_CENTER_BUY_HOST"]
212-
213+ del os.environ["SOFTWARE_CENTER_AGENT_HOST"]
214+
215 def disabled_test_for_purchase_apps_cataloged_time(self):
216 from softwarecenter.testutils import get_test_pkg_info
217 #os.environ["SOFTWARE_CENTER_DEBUG_HTTP"] = "1"
218- os.environ["SOFTWARE_CENTER_BUY_HOST"] = "http://sc.staging.ubuntu.com/"
219+ os.environ["SOFTWARE_CENTER_AGENT_HOST"] = "http://sc.staging.ubuntu.com/"
220 # staging does not have a valid cert
221 os.environ["PISTON_MINI_CLIENT_DISABLE_SSL_VALIDATION"] = "1"
222 cache = get_test_pkg_info()
223- db = xapian.WritableDatabase("./data/test.db",
224+ db = xapian.WritableDatabase("./data/test.db",
225 xapian.DB_CREATE_OR_OVERWRITE)
226 res = update_from_software_center_agent(db, cache, ignore_cache=True)
227 self.assertTrue(res)
228@@ -333,7 +333,7 @@
229 # later time than axi package Ubuntu Software Center
230 self.assertTrue(for_purch_cataloged_time > sc_cataloged_time)
231
232- del os.environ["SOFTWARE_CENTER_BUY_HOST"]
233+ del os.environ["SOFTWARE_CENTER_AGENT_HOST"]
234
235 def test_parse_axi_values_file(self):
236 s = """