49
49
self.cache = get_pkg_info()
52
def test_multiple_versions_sorting(self):
54
app = Application("", "software-center")
55
details = AppDetails(db, application=app)
57
details._pkg.installed = Mock()
58
details._pkg.installed.version = "2.0"
59
self.assertEqual(details.version, "2.0")
60
v0 = { "version" : None, }
61
v1 = { "version" : "1.0", }
62
v2 = { "version" : "2.0", }
63
v3 = { "version" : "3.0", }
64
screenshots_list = [ v0, v1, v2, v3 ]
65
res = details._sort_screenshots_by_best_version(screenshots_list)
66
self.assertEqual(res, [ v2, v1, v0 ])
52
69
def test_update_from_desktop_file(self):
53
70
# ensure we index with german locales to test i18n
54
71
os.environ["LANGUAGE"] = "de"
586
610
PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED,
613
class MultipleVersionsSupportTestCase(unittest.TestCase):
615
def _make_version(self, not_automatic):
616
from softwarecenter.db.pkginfo import _Version
618
ver.description ="not_automatic: %s" % not_automatic
619
ver.summary ="summary not_automatic: %s" % not_automatic
620
ver.version = "version not_automatic: %s" % not_automatic
623
mock_origin.archive = "precise-backports"
625
mock_origin.archive = "precise"
626
ver.origins = [ mock_origin ]
627
ver.not_automatic = not_automatic
630
def test_not_automatic_channel_support(self):
632
app = Application("", "software-center")
633
details = app.get_details(db)
635
self._make_version(not_automatic=True),
636
self._make_version(not_automatic=False) ]
637
details._pkg.versions = versions
638
details._pkg.candidate = versions[1]
640
details.get_not_automatic_archive_versions(),
641
[ (versions[1].version, "precise"),
642
(versions[0].version, "precise-backports") ])
644
def test_multiple_version_pkg_states(self):
646
app = Application("", "software-center")
647
details = app.get_details(db)
648
normal_version = self._make_version(not_automatic=False)
649
not_automatic_version = self._make_version(not_automatic=True)
650
details._pkg.versions = [normal_version, not_automatic_version]
651
details._pkg.installed = normal_version
652
details._pkg.is_installed = True
653
details._pkg.is_upgradable = True
654
self.assertEqual(details.pkg_state, PkgStates.UPGRADABLE)
655
app.archive_suite = not_automatic_version
656
self.assertEqual(details.pkg_state, PkgStates.FORCE_VERSION)
658
def test_not_automatic_version(self):
660
app = Application("", "software-center")
661
details = app.get_details(db)
662
normal_version = self._make_version(not_automatic=False)
663
not_automatic_version = self._make_version(not_automatic=True)
664
details._pkg.versions = [normal_version, not_automatic_version]
665
# force not-automatic with invalid data
667
ValueError, details.force_not_automatic_archive_suite, "random-string")
668
# force not-automatic with valid data
669
self.assertTrue(details.force_not_automatic_archive_suite(
670
not_automatic_version.origins[0].archive))
671
# ensure we get the description of the not-automatic version
672
self.assertEqual(details.description,
673
not_automatic_version.description)
674
self.assertEqual(details.summary,
675
not_automatic_version.summary)
676
self.assertEqual(details.version,
677
not_automatic_version.version)
678
self.assertEqual(app.archive_suite,
679
not_automatic_version.origins[0].archive)
681
details.force_not_automatic_archive_suite("")
682
self.assertEqual(app.archive_suite, "")
591
685
if __name__ == "__main__":
593
logging.basicConfig(level=logging.DEBUG)
687
#logging.basicConfig(level=logging.DEBUG)