25 import testutils |
25 import testutils |
26 if __name__ == "__main__": |
26 if __name__ == "__main__": |
27 testutils.setup_environment("../../../proto") |
27 testutils.setup_environment("../../../proto") |
28 import pkg5unittest |
28 import pkg5unittest |
29 |
29 |
|
30 import json |
30 import os |
31 import os |
31 import shutil |
32 import shutil |
32 import unittest |
33 import unittest |
33 |
34 |
|
35 import pkg.catalog as catalog |
34 import pkg.actions as actions |
36 import pkg.actions as actions |
35 import pkg.fmri as fmri |
37 import pkg.fmri as fmri |
36 |
38 |
37 class TestPkgInfoBasics(pkg5unittest.SingleDepotTestCase): |
39 class TestPkgInfoBasics(pkg5unittest.SingleDepotTestCase): |
38 # Only start/stop the depot once (instead of for every test) |
40 # Only start/stop the depot once (instead of for every test) |
742 self.assertEqual("tmp/copyright1\n", self.output) |
744 self.assertEqual("tmp/copyright1\n", self.output) |
743 self.pkg("info -l --license bronze") |
745 self.pkg("info -l --license bronze") |
744 self.assertEqual("tmp/copyright1\n", self.output) |
746 self.assertEqual("tmp/copyright1\n", self.output) |
745 self.pkg("info -r --license [email protected]") |
747 self.pkg("info -r --license [email protected]") |
746 self.assertEqual("tmp/copyright0\n", self.output) |
748 self.assertEqual("tmp/copyright0\n", self.output) |
|
749 |
|
750 def test_info_update_install(self): |
|
751 """Test that pkg info will show last update and install time""" |
|
752 |
|
753 os.environ["LC_ALL"] = "C" |
|
754 self.image_create(self.rurl) |
|
755 self.pkg("install [email protected]") |
|
756 path = os.path.join(self.img_path(), |
|
757 "var/pkg/state/installed/catalog.base.C") |
|
758 entry = json.load(open(path))["test"]["bronze"][0]["metadata"] |
|
759 last_install = catalog.basic_ts_to_datetime( |
|
760 entry["last-install"]).strftime("%c") |
|
761 self.pkg(("info bronze | grep 'Last Install Time: " |
|
762 "{0}'").format(last_install)) |
|
763 |
|
764 # Now update the version. |
|
765 self.pkg("install [email protected]") |
|
766 entry = json.load(open(path))["test"]["bronze"][0]["metadata"] |
|
767 last_install = catalog.basic_ts_to_datetime( |
|
768 entry["last-install"]).strftime("%c") |
|
769 self.pkg(("info bronze | grep 'Last Install Time: " |
|
770 "{0}'").format(last_install)) |
|
771 |
|
772 # Last update should be existed this time. |
|
773 last_update = catalog.basic_ts_to_datetime( |
|
774 entry["last-update"]).strftime("%c") |
|
775 self.pkg(("info bronze | grep 'Last Update Time: " |
|
776 "{0}'").format(last_update)) |
747 |
777 |
748 |
778 |
749 class TestPkgInfoPerTestRepo(pkg5unittest.SingleDepotTestCase): |
779 class TestPkgInfoPerTestRepo(pkg5unittest.SingleDepotTestCase): |
750 """A separate test class is needed because these tests modify packages |
780 """A separate test class is needed because these tests modify packages |
751 after they've been published and need to avoid corrupting packages for |
781 after they've been published and need to avoid corrupting packages for |