Package portage :: Package tests :: Package update :: Module test_move_ent
[hide private]

Source Code for Module portage.tests.update.test_move_ent

  1  # Copyright 2012-2013 Gentoo Foundation 
  2  # Distributed under the terms of the GNU General Public License v2 
  3   
  4  import textwrap 
  5   
  6  import portage 
  7  from portage import os 
  8  from portage.tests import TestCase 
  9  from portage.tests.resolver.ResolverPlayground import ResolverPlayground 
 10  from portage.util import ensure_dirs 
 11  from portage._global_updates import _do_global_updates 
 12   
13 -class MoveEntTestCase(TestCase):
14
15 - def testMoveEnt(self):
16 17 ebuilds = { 18 19 "dev-libs/A-2::dont_apply_updates" : { 20 "EAPI": "4", 21 "SLOT": "2", 22 }, 23 24 } 25 26 installed = { 27 28 "dev-libs/A-1::test_repo" : { 29 "EAPI": "4", 30 }, 31 32 "dev-libs/A-2::dont_apply_updates" : { 33 "EAPI": "4", 34 "SLOT": "2", 35 }, 36 37 } 38 39 binpkgs = { 40 41 "dev-libs/A-1::test_repo" : { 42 "EAPI": "4", 43 }, 44 45 "dev-libs/A-2::dont_apply_updates" : { 46 "EAPI": "4", 47 "SLOT": "2", 48 }, 49 50 } 51 52 updates = textwrap.dedent(""" 53 move dev-libs/A dev-libs/A-moved 54 """) 55 56 playground = ResolverPlayground(binpkgs=binpkgs, 57 ebuilds=ebuilds, installed=installed) 58 59 settings = playground.settings 60 trees = playground.trees 61 eroot = settings["EROOT"] 62 test_repo_location = settings.repositories["test_repo"].location 63 portdb = trees[eroot]["porttree"].dbapi 64 vardb = trees[eroot]["vartree"].dbapi 65 bindb = trees[eroot]["bintree"].dbapi 66 67 updates_dir = os.path.join(test_repo_location, "profiles", "updates") 68 69 try: 70 ensure_dirs(updates_dir) 71 with open(os.path.join(updates_dir, "1Q-2010"), 'w') as f: 72 f.write(updates) 73 74 # Create an empty updates directory, so that this 75 # repo doesn't inherit updates from the main repo. 76 ensure_dirs(os.path.join( 77 portdb.getRepositoryPath("dont_apply_updates"), 78 "profiles", "updates")) 79 80 global_noiselimit = portage.util.noiselimit 81 portage.util.noiselimit = -2 82 try: 83 _do_global_updates(trees, {}) 84 finally: 85 portage.util.noiselimit = global_noiselimit 86 87 # Workaround for cache validation not working 88 # correctly when filesystem has timestamp precision 89 # of 1 second. 90 vardb._clear_cache() 91 92 # A -> A-moved 93 self.assertRaises(KeyError, 94 vardb.aux_get, "dev-libs/A-1", ["EAPI"]) 95 vardb.aux_get("dev-libs/A-moved-1", ["EAPI"]) 96 self.assertRaises(KeyError, 97 bindb.aux_get, "dev-libs/A-1", ["EAPI"]) 98 bindb.aux_get("dev-libs/A-moved-1", ["EAPI"]) 99 100 # dont_apply_updates 101 self.assertRaises(KeyError, 102 vardb.aux_get, "dev-libs/A-moved-2", ["EAPI"]) 103 vardb.aux_get("dev-libs/A-2", ["EAPI"]) 104 self.assertRaises(KeyError, 105 bindb.aux_get, "dev-libs/A-moved-2", ["EAPI"]) 106 bindb.aux_get("dev-libs/A-2", ["EAPI"]) 107 108 finally: 109 playground.cleanup()
110