57
66
mock_details = mock_app.get_details(None)
58
67
mock_details.purchase_date = "2011-11-20 17:45:01"
59
68
mock_details._error_not_found = "error not found"
69
mock_details.price = "1.00"
70
mock_details.pkgname = "abiword"
60
71
self.view.app_details = mock_details
73
# the states and what labels we expect in the pkgstatusbar
74
# first string is status text, second is button text
75
pkg_states_to_labels = {
76
PkgStates.INSTALLED : ("Purchased on 2011-11-20", "Remove"),
77
PkgStates.UNINSTALLED : ('Free', 'Install'),
78
PkgStates.NEEDS_PURCHASE : ('US$ 1.00', u'Buy\u2026'),
79
PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED : ('Purchased on 2011-11-20', 'Install'),
62
82
# show a app through the various states
63
83
for var in vars(PkgStates):
64
84
# FIXME: this just ensures we are not crashing, also
201
229
self.view._submit_reviews_done_callback(None, 0)
203
231
self.assertTrue(button.is_sensitive())
234
class HardwareRequirementsTestCase(unittest.TestCase):
238
# Set these as class attributes as we don't modify either
240
from softwarecenter.testutils import get_test_db
241
cls.db = get_test_db()
242
cls.win = get_test_window_appdetails()
243
cls.view = cls.win.get_data("view")
246
def tearDownClass(cls):
247
GObject.timeout_add(TIMEOUT, lambda: cls.win.destroy())
251
app = Application("", "software-center")
252
self.app_mock = get_mock_app_from_real_app(app)
253
self.app_mock.details.pkg_state = PkgStates.UNINSTALLED
255
def test_show_hardware_requirements(self):
256
self.app_mock.details.hardware_requirements = {
257
'hardware::video:opengl' : 'yes',
258
'hardware::gps' : 'no',
260
self.app_mock.details.hardware_requirements_satisfied = False
261
self.view.show_app(self.app_mock)
263
# ensure we have the data
265
self.view.hardware_info.value_label.get_property("visible"))
267
type(HardwareRequirementsBox()),
268
type(self.view.hardware_info.value_label))
270
self.view.hardware_info.key, _("Also requires"))
271
# ensure that the button is correct
273
self.view.pkg_statusbar.button.get_label(), "Install Anyway")
274
# and again for purchase
275
self.app_mock.details.pkg_state = PkgStates.NEEDS_PURCHASE
276
self.view.show_app(self.app_mock)
278
self.view.pkg_statusbar.button.get_label(),
279
_(u"Buy Anyway\u2026").encode("utf-8"))
280
# check if the warning bar is displayed
281
self.assertTrue(self.view.pkg_warningbar.get_property("visible"))
282
self.assertEqual(self.view.pkg_warningbar.label.get_text(),
283
_('This software requires a GPS, '
284
'but the computer does not have one.'))
286
def test_no_show_hardware_requirements(self):
287
self.app_mock.details.hardware_requirements = {}
288
self.app_mock.details.hardware_requirements_satisfied = True
289
self.view.show_app(self.app_mock)
291
# ensure we do not show anything if there are no HW requirements
293
self.view.hardware_info.get_property("visible"))
294
# ensure that the button is correct
296
self.view.pkg_statusbar.button.get_label(), _("Install"))
297
# and again for purchase
298
self.app_mock.details.pkg_state = PkgStates.NEEDS_PURCHASE
299
self.view.show_app(self.app_mock)
301
self.view.pkg_statusbar.button.get_label(),
302
_(u'Buy\u2026').encode("utf-8"))
303
# check if the warning bar is invisible
304
self.assertFalse(self.view.pkg_warningbar.get_property("visible"))
306
class RegionRequirementsTestCase(unittest.TestCase):
310
# Set these as class attributes as we don't modify either
312
from softwarecenter.testutils import get_test_db
313
cls.db = get_test_db()
314
cls.win = get_test_window_appdetails()
315
cls.view = cls.win.get_data("view")
318
def tearDownClass(cls):
319
GObject.timeout_add(TIMEOUT, lambda: cls.win.destroy())
323
app = Application("", "software-center")
324
self.app_mock = get_mock_app_from_real_app(app)
325
self.app_mock.details.pkg_state = PkgStates.UNINSTALLED
327
def test_show_region_requirements(self):
328
self.app_mock.details.region_requirements_satisfied = False
329
self.view.show_app(self.app_mock)
331
# ensure that the button is correct
333
self.view.pkg_statusbar.button.get_label(), "Install Anyway")
334
# and again for purchase
335
self.app_mock.details.pkg_state = PkgStates.NEEDS_PURCHASE
336
self.view.show_app(self.app_mock)
338
self.view.pkg_statusbar.button.get_label(),
339
_(u"Buy Anyway\u2026").encode("utf-8"))
340
# check if the warning bar is displayed
341
self.assertTrue(self.view.pkg_warningbar.get_property("visible"))
342
self.assertEqual(self.view.pkg_warningbar.label.get_text(),
343
REGION_WARNING_STRING)
206
346
class PurchasedAppDetailsStatusBarTestCase(unittest.TestCase):