def get_phasetool_results(self, args, mock_write_plist): """Put args into sys.argv and run phasetool. Args: args (list of strings): Positional args, flags, commands, supplied as commandline arguments to phasetool. Returns: Takes mock.MagicMock object's call_args_list for mocked plistlib.writePlist and returns a list of just the plist files that were "written". """ sys.argv = build_args(args) phasetool.main() result = ([call[0][0] for call in mock_write_plist.call_args_list] if mock_write_plist.called else None) return result
def test_collect_updates(self, mock_repo): """Test collecting updates from a repo for phase testing.""" expected_result = ("## November Phase Testing Updates\n\n" "- Crypt - enables FileVault encryption 0.8.0\n" "- Crypt - enables FileVault encryption 0.9.0\n" "- Crypt - enables FileVault encryption 1.0.0\n" "- Crypt - enables FileVault encryption 1.5.0") expected_files = ("test/resources/repo/pkgsinfo/Crypt-0.8.0.pkginfo\n" "test/resources/repo/pkgsinfo/Crypt-0.9.0.pkginfo\n" "test/resources/repo/pkgsinfo/Crypt-1.0.0.pkginfo\n" "test/resources/repo/pkgsinfo/Crypt-1.5.0.pkginfo") # Leif is testing the collection of updates to see what it # finds sys.argv = build_args(["--repo", "test/resources/repo", "collect"]) phasetool.main() result_content = mock_repo.call_args_list[0][0][0] result_files = mock_repo.call_args_list[1][0][0] assert_equal(expected_result, result_content) assert_equal(expected_files, result_files)