1
0

test_mac_portspkg.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # -*- coding: utf-8 -*-
  2. """
  3. integration tests for mac_ports
  4. """
  5. from __future__ import absolute_import, print_function, unicode_literals
  6. import pytest
  7. from tests.support.case import ModuleCase
  8. @pytest.mark.skip_if_not_root
  9. @pytest.mark.skip_unless_on_darwin
  10. @pytest.mark.skip_if_binaries_missing("port")
  11. class MacPortsModuleTest(ModuleCase):
  12. """
  13. Validate the mac_ports module
  14. """
  15. AGREE_INSTALLED = False
  16. def setUp(self):
  17. """
  18. Get current settings
  19. """
  20. self.AGREE_INSTALLED = "agree" in self.run_function("pkg.list_pkgs")
  21. self.run_function("pkg.refresh_db")
  22. def tearDown(self):
  23. """
  24. Reset to original settings
  25. """
  26. if not self.AGREE_INSTALLED:
  27. self.run_function("pkg.remove", ["agree"])
  28. @pytest.mark.destructive_test
  29. def test_list_pkgs(self):
  30. """
  31. Test pkg.list_pkgs
  32. """
  33. self.run_function("pkg.install", ["agree"])
  34. self.assertIsInstance(self.run_function("pkg.list_pkgs"), dict)
  35. self.assertIn("agree", self.run_function("pkg.list_pkgs"))
  36. @pytest.mark.destructive_test
  37. def test_latest_version(self):
  38. """
  39. Test pkg.latest_version
  40. """
  41. self.run_function("pkg.install", ["agree"])
  42. result = self.run_function("pkg.latest_version", ["agree"], refresh=False)
  43. self.assertIsInstance(result, dict)
  44. self.assertIn("agree", result)
  45. @pytest.mark.destructive_test
  46. def test_remove(self):
  47. """
  48. Test pkg.remove
  49. """
  50. self.run_function("pkg.install", ["agree"])
  51. removed = self.run_function("pkg.remove", ["agree"])
  52. self.assertIsInstance(removed, dict)
  53. self.assertIn("agree", removed)
  54. @pytest.mark.destructive_test
  55. def test_install(self):
  56. """
  57. Test pkg.install
  58. """
  59. self.run_function("pkg.remove", ["agree"])
  60. installed = self.run_function("pkg.install", ["agree"])
  61. self.assertIsInstance(installed, dict)
  62. self.assertIn("agree", installed)
  63. def test_list_upgrades(self):
  64. """
  65. Test pkg.list_upgrades
  66. """
  67. self.assertIsInstance(
  68. self.run_function("pkg.list_upgrades", refresh=False), dict
  69. )
  70. @pytest.mark.destructive_test
  71. def test_upgrade_available(self):
  72. """
  73. Test pkg.upgrade_available
  74. """
  75. self.run_function("pkg.install", ["agree"])
  76. self.assertFalse(
  77. self.run_function("pkg.upgrade_available", ["agree"], refresh=False)
  78. )
  79. def test_refresh_db(self):
  80. """
  81. Test pkg.refresh_db
  82. """
  83. self.assertTrue(self.run_function("pkg.refresh_db"))
  84. @pytest.mark.destructive_test
  85. def test_upgrade(self):
  86. """
  87. Test pkg.upgrade
  88. """
  89. results = self.run_function("pkg.upgrade", refresh=False)
  90. self.assertIsInstance(results, dict)
  91. self.assertTrue(results["result"])