src/tests/cli/t_api_info.py
author Shawn Walker <srw@sun.com>
Wed, 02 Dec 2009 22:07:06 -0600
changeset 1538 78ac66abc186
parent 1537 00a5b4d54eb8
child 1603 84bd53597209
permissions -rw-r--r--
12130 install/update operations should always refresh publisher metadata (when allowed) 4419 misleading error message when pkg not found because refresh failed 10976 operations should report when refresh failed if appropriate
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
     1
#!/usr/bin/python
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     2
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     3
# CDDL HEADER START
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     4
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     8
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    11
# See the License for the specific language governing permissions
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    12
# and limitations under the License.
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    13
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    19
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    20
# CDDL HEADER END
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    21
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    22
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
    23
#
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
    24
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    25
# Use is subject to license terms.
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
    26
#
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    27
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    28
import testutils
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    29
if __name__ == "__main__":
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    30
	testutils.setup_environment("../../../proto")
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    31
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    32
import unittest
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    33
import os
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    34
import re
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    35
import shutil
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    36
import difflib
715
5620652f5927 4886 api.info shouldn't be reloading the catalog from disk needlessly
Brock Pytlik <bpytlik@sun.com>
parents: 707
diff changeset
    37
import time
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    38
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    39
import pkg.client.api as api
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    40
import pkg.client.api_errors as api_errors
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    41
import pkg.client.progress as progress
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    42
1538
78ac66abc186 12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents: 1537
diff changeset
    43
API_VERSION = 26
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    44
PKG_CLIENT_NAME = "pkg"
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    45
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    46
class TestApiInfo(testutils.SingleDepotTestCase):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    47
        # Only start/stop the depot once (instead of for every test)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    48
        persistent_depot = True
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    49
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    50
        def test_info_local_remote(self):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    51
                self.image_create(self.dc.get_depot_url())
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    52
                progresstracker = progress.NullProgressTracker()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    53
                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    54
                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    55
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    56
                self.assertRaises(api_errors.NoPackagesInstalledException,
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    57
                    api_obj.info, [], True, api.PackageInfo.ALL_OPTIONS -
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    58
                    (frozenset([api.PackageInfo.LICENSES]) |
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    59
                    api.PackageInfo.ACTION_OPTIONS))
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    60
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    61
                self.assertRaises(api_errors.UnrecognizedOptionsToInfo,
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    62
                    api_obj.info, [], True, set([-1]))
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    63
                self.assertRaises(api_errors.UnrecognizedOptionsToInfo,
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    64
                    api_obj.info, [], True, set('a'))
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    65
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    66
                misc_files = ["/tmp/copyright1", "/tmp/example_file"]
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    67
                for p in misc_files:
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    68
                        f = open(p, "w")
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    69
                        f.write(p)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    70
                        f.close()
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    71
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    72
                pkg1 = """
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    73
                    open [email protected],5.11-0
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    74
                    add dir mode=0755 owner=root group=bin path=/bin
834
f8b3396500b3 4883 import failure for non-sunos platforms due to missing pspawn
Tom Mueller <Tom.Mueller@sun.com>
parents: 715
diff changeset
    75
                    add set name=info.classification value="org.opensolaris.category.2008:Applications/Sound and Video"
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    76
                    close
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    77
                """
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    78
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    79
                pkg2 = """
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    80
                    open [email protected],5.11-0
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    81
                    add dir mode=0755 owner=root group=bin path=/bin
688
32a3ca40676e 4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents: 615
diff changeset
    82
                    add set name=info.classification value=org.opensolaris.category.2008:System/Security/Foo/bar/Baz
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    83
                    close
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    84
                """
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    85
715
5620652f5927 4886 api.info shouldn't be reloading the catalog from disk needlessly
Brock Pytlik <bpytlik@sun.com>
parents: 707
diff changeset
    86
                pkg3 = """
5620652f5927 4886 api.info shouldn't be reloading the catalog from disk needlessly
Brock Pytlik <bpytlik@sun.com>
parents: 707
diff changeset
    87
                    open [email protected],5.11-0
5620652f5927 4886 api.info shouldn't be reloading the catalog from disk needlessly
Brock Pytlik <bpytlik@sun.com>
parents: 707
diff changeset
    88
                    close
5620652f5927 4886 api.info shouldn't be reloading the catalog from disk needlessly
Brock Pytlik <bpytlik@sun.com>
parents: 707
diff changeset
    89
                """
5620652f5927 4886 api.info shouldn't be reloading the catalog from disk needlessly
Brock Pytlik <bpytlik@sun.com>
parents: 707
diff changeset
    90
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    91
                pkg4 = """
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    92
                    open [email protected],5.11-0
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    93
                    add depend fmri=pkg:/[email protected] type=require
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    94
                    add dir mode=0755 owner=root group=bin path=/bin
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    95
                    add file /tmp/example_file mode=0555 owner=root group=bin path=/bin/example_path
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    96
                    add hardlink path=/bin/example_path2 target=/bin/example_path
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    97
                    add link path=/bin/example_path3 target=/bin/example_path
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    98
                    add set description='FOOO bAr O OO OOO'
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
    99
                    add license /tmp/copyright1 license=copyright
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   100
                    add set name=info.classification value=org.opensolaris.category.2008:System/Security/Foo/bar/Baz
1389
1827f487a235 8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents: 1352
diff changeset
   101
                    add set pkg.description="DESCRIPTION 1"
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   102
                    close """
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   103
1140
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   104
                pkg5 = """
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   105
                    open [email protected],5.11-0
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   106
                    add dir mode=0755 owner=root group=bin path=/bin
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   107
                    add set pkg.summary='SUMMARY: Example Package 5'
1389
1827f487a235 8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents: 1352
diff changeset
   108
                    add set pkg.description="DESCRIPTION 2"
1140
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   109
                    close
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   110
                """
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   111
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   112
                pkg6 = """
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   113
                    open [email protected],5.11-0
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   114
                    add dir mode=0755 owner=root group=bin path=/bin
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   115
                    add set description='DESCRIPTION: Example Package 6'
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   116
                    add set pkg.summary='SUMMARY: Example Package 6'
1389
1827f487a235 8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents: 1352
diff changeset
   117
                    add set pkg.description="DESCRIPTION 3"
1140
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   118
                    close
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   119
                """
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   120
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   121
                durl = self.dc.get_depot_url()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   122
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   123
                self.pkgsend_bulk(durl, pkg1)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   124
                self.pkgsend_bulk(durl, pkg2)
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   125
                self.pkgsend_bulk(durl, pkg4)
1140
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   126
                self.pkgsend_bulk(durl, pkg5)
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   127
                self.pkgsend_bulk(durl, pkg6)
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   128
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   129
                self.image_create(durl)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   130
715
5620652f5927 4886 api.info shouldn't be reloading the catalog from disk needlessly
Brock Pytlik <bpytlik@sun.com>
parents: 707
diff changeset
   131
                local = True
5620652f5927 4886 api.info shouldn't be reloading the catalog from disk needlessly
Brock Pytlik <bpytlik@sun.com>
parents: 707
diff changeset
   132
                get_license = False
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   133
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   134
                info_needed = api.PackageInfo.ALL_OPTIONS - \
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   135
                    (api.PackageInfo.ACTION_OPTIONS |
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   136
                    frozenset([api.PackageInfo.LICENSES]))
715
5620652f5927 4886 api.info shouldn't be reloading the catalog from disk needlessly
Brock Pytlik <bpytlik@sun.com>
parents: 707
diff changeset
   137
                
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   138
                ret = api_obj.info(["jade"], local, info_needed)
715
5620652f5927 4886 api.info shouldn't be reloading the catalog from disk needlessly
Brock Pytlik <bpytlik@sun.com>
parents: 707
diff changeset
   139
                self.assert_(not ret[api.ImageInterface.INFO_FOUND])
5620652f5927 4886 api.info shouldn't be reloading the catalog from disk needlessly
Brock Pytlik <bpytlik@sun.com>
parents: 707
diff changeset
   140
                self.assert_(len(ret[api.ImageInterface.INFO_MISSING]) == 1)
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   141
                
1505
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1461
diff changeset
   142
                api_obj.plan_install(["jade"])
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   143
                api_obj.prepare()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   144
                api_obj.execute_plan()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   145
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   146
                self.pkg("verify -v")
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   147
                
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   148
                ret = api_obj.info(["jade", "turquoise", "emerald"],
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   149
                    local, info_needed)
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   150
                pis = ret[api.ImageInterface.INFO_FOUND]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   151
                notfound = ret[api.ImageInterface.INFO_MISSING]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   152
                illegals = ret[api.ImageInterface.INFO_ILLEGALS]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   153
                self.assert_(len(pis) == 1)
1461
fdf40c8c6765 820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents: 1389
diff changeset
   154
                self.assert_(api.PackageInfo.INSTALLED in pis[0].states)
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   155
                self.assert_(pis[0].pkg_stem == 'jade')
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   156
                self.assert_(len(notfound) == 2)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   157
                self.assert_(len(illegals) == 0)
688
32a3ca40676e 4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents: 615
diff changeset
   158
                self.assert_(len(pis[0].category_info_list) == 1)
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   159
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   160
                ret = api_obj.info(["j*"], local, info_needed)
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   161
                pis = ret[api.ImageInterface.INFO_FOUND]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   162
                notfound = ret[api.ImageInterface.INFO_MISSING]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   163
                illegals = ret[api.ImageInterface.INFO_ILLEGALS]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   164
                self.assert_(len(pis))
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   165
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   166
                ret = api_obj.info(["*a*"], local, info_needed)
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   167
                pis = ret[api.ImageInterface.INFO_FOUND]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   168
                notfound = ret[api.ImageInterface.INFO_MISSING]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   169
                illegals = ret[api.ImageInterface.INFO_ILLEGALS]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   170
                self.assert_(len(pis))
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   171
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   172
                local = False
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   173
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   174
                ret = api_obj.info(["jade"], local, info_needed)
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   175
                pis = ret[api.ImageInterface.INFO_FOUND]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   176
                notfound = ret[api.ImageInterface.INFO_MISSING]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   177
                illegals = ret[api.ImageInterface.INFO_ILLEGALS]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   178
                self.assert_(len(pis) == 1)
1461
fdf40c8c6765 820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents: 1389
diff changeset
   179
                self.assert_(api.PackageInfo.INSTALLED in pis[0].states)
688
32a3ca40676e 4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents: 615
diff changeset
   180
                self.assert_(len(pis[0].category_info_list) == 1)
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   181
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   182
                ret = api_obj.info(["turquoise"], local, info_needed)
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   183
                pis = ret[api.ImageInterface.INFO_FOUND]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   184
                notfound = ret[api.ImageInterface.INFO_MISSING]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   185
                illegals = ret[api.ImageInterface.INFO_ILLEGALS]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   186
                self.assert_(len(pis) == 1)
1537
00a5b4d54eb8 5872 List APIs required
Shawn Walker <srw@sun.com>
parents: 1516
diff changeset
   187
                self.assert_(api.PackageInfo.INSTALLED not in pis[0].states)
688
32a3ca40676e 4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents: 615
diff changeset
   188
                self.assert_(len(pis[0].category_info_list) == 1)
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   189
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   190
                ret = api_obj.info(["example_pkg"], local,
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   191
                    api.PackageInfo.ALL_OPTIONS)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   192
                pis = ret[api.ImageInterface.INFO_FOUND]
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   193
                self.assert_(len(pis) == 1)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   194
                res = pis[0]
1537
00a5b4d54eb8 5872 List APIs required
Shawn Walker <srw@sun.com>
parents: 1516
diff changeset
   195
                self.assert_(api.PackageInfo.INSTALLED not in res.states)
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   196
                self.assert_(len(res.category_info_list) == 1)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   197
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   198
                self.assert_(res.pkg_stem is not None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   199
                self.assert_(res.summary is not None)
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   200
                self.assert_(res.publisher is not None)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   201
                self.assert_(res.preferred_publisher is not None)
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   202
                self.assert_(res.version is not None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   203
                self.assert_(res.build_release is not None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   204
                self.assert_(res.branch is not None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   205
                self.assert_(res.packaging_date is not None)
1044
046981c42149 8102 pkg.client.api info reports size of zero for packages with cached manifests
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 996
diff changeset
   206
                total_size = 0
046981c42149 8102 pkg.client.api info reports size of zero for packages with cached manifests
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 996
diff changeset
   207
                for p in misc_files:
046981c42149 8102 pkg.client.api info reports size of zero for packages with cached manifests
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 996
diff changeset
   208
                        total_size += len(p)
046981c42149 8102 pkg.client.api info reports size of zero for packages with cached manifests
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 996
diff changeset
   209
                self.assertEqual(res.size, total_size)
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   210
                self.assert_(res.licenses is not None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   211
                self.assert_(res.links is not None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   212
                self.assert_(res.hardlinks is not None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   213
                self.assert_(res.files is not None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   214
                self.assert_(res.dirs is not None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   215
                self.assert_(res.dependencies is not None)
1389
1827f487a235 8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents: 1352
diff changeset
   216
                # A test for bug 8868 which ensures the pkg.description field
1827f487a235 8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents: 1352
diff changeset
   217
                # is as exected.
1827f487a235 8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents: 1352
diff changeset
   218
                self.assertEqual(res.description, "DESCRIPTION 1")
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   219
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   220
                ret = api_obj.info(["emerald"], local, info_needed)
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   221
                pis = ret[api.ImageInterface.INFO_FOUND]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   222
                notfound = ret[api.ImageInterface.INFO_MISSING]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   223
                illegals = ret[api.ImageInterface.INFO_ILLEGALS]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   224
                self.assert_(len(notfound) == 1)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   225
615
aeeeb9f31173 4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents: 594
diff changeset
   226
                local = True
aeeeb9f31173 4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents: 594
diff changeset
   227
                get_license = False
aeeeb9f31173 4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents: 594
diff changeset
   228
                get_action_info = True
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   229
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   230
                info_needed = api.PackageInfo.ALL_OPTIONS - \
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   231
                    frozenset([api.PackageInfo.LICENSES])
615
aeeeb9f31173 4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents: 594
diff changeset
   232
                
aeeeb9f31173 4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents: 594
diff changeset
   233
                ret = api_obj.info(["jade"],
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   234
                    local, info_needed)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   235
                pis = ret[api.ImageInterface.INFO_FOUND]
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   236
                notfound = ret[api.ImageInterface.INFO_MISSING]
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   237
                illegals = ret[api.ImageInterface.INFO_ILLEGALS]
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   238
                self.assert_(len(pis) == 1)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   239
                self.assert_(len(pis[0].dirs) == 1)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   240
                
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   241
                ret = api_obj.info(["jade"], local, set())
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   242
                pis = ret[api.ImageInterface.INFO_FOUND]
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   243
                self.assert_(len(pis) == 1)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   244
                res = pis[0]
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   245
                self.assert_(res.pkg_stem is None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   246
                self.assert_(res.summary is None)
1537
00a5b4d54eb8 5872 List APIs required
Shawn Walker <srw@sun.com>
parents: 1516
diff changeset
   247
                self.assertEqual(res.category_info_list, [])
00a5b4d54eb8 5872 List APIs required
Shawn Walker <srw@sun.com>
parents: 1516
diff changeset
   248
                self.assertEqual(res.states, set())
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   249
                self.assert_(res.publisher is None)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   250
                self.assert_(res.preferred_publisher is None)
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   251
                self.assert_(res.version is None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   252
                self.assert_(res.build_release is None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   253
                self.assert_(res.branch is None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   254
                self.assert_(res.packaging_date is None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   255
                self.assert_(res.size is None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   256
                self.assert_(res.licenses is None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   257
                self.assert_(res.links is None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   258
                self.assert_(res.hardlinks is None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   259
                self.assert_(res.files is None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   260
                self.assert_(res.dirs is None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   261
                self.assert_(res.dependencies is None)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   262
                
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   263
                local = False
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   264
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   265
                ret = api_obj.info(["jade"],
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   266
                    local, info_needed)
615
aeeeb9f31173 4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents: 594
diff changeset
   267
                pis = ret[api.ImageInterface.INFO_FOUND]
aeeeb9f31173 4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents: 594
diff changeset
   268
                notfound = ret[api.ImageInterface.INFO_MISSING]
aeeeb9f31173 4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents: 594
diff changeset
   269
                illegals = ret[api.ImageInterface.INFO_ILLEGALS]
aeeeb9f31173 4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents: 594
diff changeset
   270
                self.assert_(len(pis) == 1)
aeeeb9f31173 4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents: 594
diff changeset
   271
                self.assert_(len(pis[0].dirs) == 1)
aeeeb9f31173 4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents: 594
diff changeset
   272
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   273
                self.assertRaises(api_errors.UnrecognizedOptionsToInfo,
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   274
                    api_obj.info, ["jade"], local, set([-1]))
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   275
                self.assertRaises(api_errors.UnrecognizedOptionsToInfo,
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   276
                    api_obj.info, ["jade"], local, set('a'))
615
aeeeb9f31173 4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents: 594
diff changeset
   277
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   278
                self.assertRaises(api_errors.UnrecognizedOptionsToInfo,
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   279
                    api_obj.info, ["foo"], local, set([-1]))
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   280
                self.assertRaises(api_errors.UnrecognizedOptionsToInfo,
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 834
diff changeset
   281
                    api_obj.info, ["foo"], local, set('a'))
707
d37b19989de2 4878 pkg info traceback when given invalid input
Brock Pytlik <bpytlik@sun.com>
parents: 688
diff changeset
   282
1140
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   283
                # Test if the package summary has been correctly set if just
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   284
                # a pkg.summary had been set in the package.
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   285
                # See bug #4395 and bug #8829 for more details.
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   286
                ret = api_obj.info(["example_pkg5"], local,
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   287
                    api.PackageInfo.ALL_OPTIONS)
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   288
                pis = ret[api.ImageInterface.INFO_FOUND]
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   289
                self.assert_(len(pis) == 1)
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   290
                res = pis[0]
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   291
                self.assert_(res.summary == "SUMMARY: Example Package 5")
1389
1827f487a235 8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents: 1352
diff changeset
   292
                # A test for bug 8868 which ensures the pkg.description field
1827f487a235 8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents: 1352
diff changeset
   293
                # is as exected.
1827f487a235 8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents: 1352
diff changeset
   294
                self.assertEqual(res.description, "DESCRIPTION 2")
1140
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   295
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   296
                # Test if the package summary has been correctly set if both
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   297
                # a pkg.summary and a description had been set in the package.
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   298
                # See bug #4395 and bug #8829 for more details.
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   299
                ret = api_obj.info(["example_pkg6"], local,
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   300
                    api.PackageInfo.ALL_OPTIONS)
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   301
                pis = ret[api.ImageInterface.INFO_FOUND]
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   302
                self.assert_(len(pis) == 1)
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   303
                res = pis[0]
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   304
                self.assert_(res.summary == "SUMMARY: Example Package 6")
1389
1827f487a235 8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents: 1352
diff changeset
   305
                # A test for bug 8868 which ensures the pkg.description field
1827f487a235 8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents: 1352
diff changeset
   306
                # is as exected.
1827f487a235 8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents: 1352
diff changeset
   307
                self.assertEqual(res.description, "DESCRIPTION 3")
1140
b2aee412ba0d 4395 Use pkg.summary for "pkg info" output
Rich Burridge <rich.burridge@sun.com>
parents: 1087
diff changeset
   308
707
d37b19989de2 4878 pkg info traceback when given invalid input
Brock Pytlik <bpytlik@sun.com>
parents: 688
diff changeset
   309
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   310
if __name__ == "__main__":
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   311
        unittest.main()