src/tests/api/t_api.py
changeset 2117 83afe4aabe78
parent 2092 0ef66bf272d3
child 2144 2ac203b826ab
child 2572 20cf41d565de
equal deleted inserted replaced
2116:01cac360e383 2117:83afe4aabe78
    89             close """
    89             close """
    90 
    90 
    91         # Third iteration now requires acceptance of license.
    91         # Third iteration now requires acceptance of license.
    92         licensed13 = """
    92         licensed13 = """
    93             open [email protected],5.11-0
    93             open [email protected],5.11-0
       
    94             add depend type=require [email protected]
       
    95             add file libc.so.1 mode=0555 owner=root group=bin path=/lib/libc.so.1
       
    96             add license copyright.licensed license=copyright.licensed must-display=True
       
    97             add license license.licensed license=license.licensed must-accept=True
       
    98             close """
       
    99 
       
   100         # Fourth iteration is completely unchanged, so shouldn't require
       
   101         # acceptance.
       
   102         licensed14 = """
       
   103             open [email protected],5.11-0
    94             add depend type=require [email protected]
   104             add depend type=require [email protected]
    95             add file libc.so.1 mode=0555 owner=root group=bin path=/lib/libc.so.1
   105             add file libc.so.1 mode=0555 owner=root group=bin path=/lib/libc.so.1
    96             add license copyright.licensed license=copyright.licensed must-display=True
   106             add license copyright.licensed license=copyright.licensed must-display=True
    97             add license license.licensed license=license.licensed must-accept=True
   107             add license license.licensed license=license.licensed must-accept=True
    98             close """
   108             close """
   938                 # Prepare should succeed this time; so execute afterwards.
   948                 # Prepare should succeed this time; so execute afterwards.
   939                 api_obj.prepare()
   949                 api_obj.prepare()
   940                 api_obj.execute_plan()
   950                 api_obj.execute_plan()
   941                 api_obj.reset()
   951                 api_obj.reset()
   942 
   952 
       
   953                 plist.extend(self.pkgsend_bulk(self.rurl, self.licensed14))
       
   954                 api_obj.refresh()
       
   955                 api_obj.reset()
       
   956 
       
   957                 # Next, verify that an update to a newer version of a package
       
   958                 # where the license hasn't changed and it previously required
       
   959                 # acceptance is treated as already having been accepted.
       
   960                 api_obj.plan_update_all(sys.argv[0])
       
   961                 plan = api_obj.describe()
       
   962                 pfmri = fmri.PkgFmri(plist[5])
       
   963                 lics = sorted(plan.get_licenses(), cmp=lic_sort)
       
   964                 for dest_fmri, src, dest, accepted, displayed in lics:
       
   965                         # License information should only be for "[email protected]".
       
   966                         self.assertEqual(pfmri, dest_fmri)
       
   967 
       
   968                         if dest.must_accept:
       
   969                                 # Since the license hasn't changed and was
       
   970                                 # previously accepted, then acceptance shouldn't
       
   971                                 # be required here.
       
   972                                 self.assertTrue(accepted)
       
   973                 api_obj.reset()
       
   974 
   943                 # Finally, verify that an uninstall won't trigger license
   975                 # Finally, verify that an uninstall won't trigger license
   944                 # errors as acceptance should never be applied to it.
   976                 # errors as acceptance should never be applied to it.
   945                 api_obj.plan_uninstall(["*"], False)
   977                 api_obj.plan_uninstall(["*"], False)
   946                 api_obj.prepare()
   978                 api_obj.prepare()
   947                 api_obj.execute_plan()
   979                 api_obj.execute_plan()