Beispiel #1
0
 def test_ambiguous(self):
     repo = SimpleTree({
         'spork': {'foon': ('1',)},
         'spork2': {'foon': ('2',)}})
     installed_repos = SimpleTree({'foo': {'bar': ('1',)}})
     with pytest.raises(pmerge.AmbiguousQuery):
         pmerge.parse_target(parse_match("foon"), repo, installed_repos)
Beispiel #2
0
 def test_no_matches(self):
     repo = SimpleTree({
         'spork': {'foon': ('1',)},
         'spork2': {'foon': ('2',)}})
     installed_repos = SimpleTree({'foo': {'bar': ('1',)}})
     with pytest.raises(pmerge.NoMatches):
         pmerge.parse_target(parse_match("foo"), repo, installed_repos)
Beispiel #3
0
 def test_base_targets(self):
     repo = SimpleTree({'spork': {'foon': ('1', '1.0.1', '2')}})
     installed_repos = SimpleTree({'foo': {'bar': ('1',)}})
     for cat in ('', 'spork/'):
         a = pmerge.parse_target(parse_match(f'={cat}foon-1'), repo, installed_repos)
         assert len(a) == 1
         assert a[0].key == 'spork/foon'
         assert [x.fullver for x in repo.itermatch(a[0])] == ['1']
         a = pmerge.parse_target(parse_match(f'{cat}foon'), repo, installed_repos)
         assert len(a) == 1
         assert a[0].key == 'spork/foon'
         assert (
             sorted(x.fullver for x in repo.itermatch(a[0])) ==
             sorted(['1', '1.0.1', '2'])
         )
Beispiel #4
0
 def test_globbing(self):
     repo = SimpleTree({
         'spork': {'foon': ('1',)},
         'spork2': {'foon': ('2',)}})
     installed_repos = SimpleTree({'foo': {'bar': ('1',)}})
     a = pmerge.parse_target(parse_match('*/foon'), repo, installed_repos)
     assert len(a) == 2
Beispiel #5
0
 def test_globbing(self):
     repo = SimpleTree({
         'spork': {'foon': ('1',)},
         'spork2': {'foon': ('2',)}})
     installed_repos = SimpleTree({'foo': {'bar': ('1',)}})
     a = pmerge.parse_target(parse_match('*/foon'), repo, installed_repos)
     assert len(a) == 2
Beispiel #6
0
 def test_collision_livefs(self):
     # test pkg name collision between real and virtual pkgs on livefs
     # repos, the real pkg will be selected over the virtual
     installed_repos = SimpleTree({'foo': {'bar': ('1',)}, 'virtual': {'bar': ('0',)}})
     repo = SimpleTree({'foo': {'bar': ('1',)}, 'virtual': {'bar': ('1',)}})
     a = pmerge.parse_target(parse_match("bar"), repo, installed_repos)
     assert len(a) == 1
     assert a[0].key == 'foo/bar'
     assert [x.key for x in repo.match(a[0])] == ['foo/bar']
Beispiel #7
0
 def test_collision_livefs(self):
     # test pkg name collision between real and virtual pkgs on livefs
     # repos, the real pkg will be selected over the virtual
     installed_repos = SimpleTree({'foo': {'bar': ('1',)}, 'virtual': {'bar': ('0',)}})
     repo = SimpleTree({'foo': {'bar': ('1',)}, 'virtual': {'bar': ('1',)}})
     a = pmerge.parse_target(parse_match("bar"), repo, installed_repos)
     assert len(a) == 1
     assert a[0].key == 'foo/bar'
     assert [x.key for x in repo.match(a[0])] == ['foo/bar']
Beispiel #8
0
    def test_parse_target(self):
        repo = util.SimpleTree({'spork': {'foon': ('1', '1.0.1', '2')}})
        livefs_repos = util.SimpleTree({'foo': {'bar': ('1')}})
        for cat in ('', 'spork/'):
            a = pmerge.parse_target(parse_match('=%sfoon-1' % (cat,)), repo, livefs_repos)
            self.assertEqual(len(a), 1)
            self.assertEqual(a[0].key, 'spork/foon')
            self.assertEqual(
                [x.fullver for x in repo.itermatch(a[0])],
                ['1'])
            a = pmerge.parse_target(parse_match('%sfoon' % (cat,)), repo, livefs_repos)
            self.assertEqual(len(a), 1)
            self.assertEqual(a[0].key, 'spork/foon')
            self.assertEqual(
                sorted(x.fullver for x in repo.itermatch(a[0])),
                sorted(['1', '1.0.1', '2']))

        repo = util.SimpleTree({
            'spork': {'foon': ('1',)},
            'spork2': {'foon': ('2',)}})
        self.assertRaises(
            pmerge.NoMatches,
            pmerge.parse_target, parse_match("foo"), repo, livefs_repos)
        self.assertRaises(
            pmerge.AmbiguousQuery,
            pmerge.parse_target, parse_match("foon"), repo, livefs_repos)
        # test unicode conversion.
        a = pmerge.parse_target(parse_match(u'=spork/foon-1'), repo, livefs_repos)
        self.assertEqual(len(a), 1)
        self.assertEqual(a[0].key, 'spork/foon')
        self.assertTrue(isinstance(a[0].key, str))
        # test globbing
        a = pmerge.parse_target(parse_match(u'*/foon'), repo, livefs_repos)
        self.assertEqual(len(a), 2)

        # test pkg name collisions between real and virtual pkgs on livefs
        # repos, the real pkg will be selected over the virtual
        livefs_repos = util.SimpleTree({'foo': {'bar': ('1')}, 'virtual': {'bar': ('0')}})
        repo = util.SimpleTree({'foo': {'bar': ('1',)}, 'virtual': {'bar': ('1',)}})
        a = pmerge.parse_target(parse_match("bar"), repo, livefs_repos)
        self.assertEqual(len(a), 1)
        self.assertEqual(a[0].key, 'foo/bar')
        self.assertTrue(isinstance(a[0].key, str))
Beispiel #9
0
 def test_collision_slotted(self):
     pkgs = [
         FakePkg('foo/bar-1.0.1', slot='0'),
         FakePkg('foo/bar-2.0.2', slot='2'),
         FakePkg('foon/bar-3.4.5', slot='0'),
     ]
     installed_pkgs = [
         FakePkg('foo/bar-1.0.0', slot='0'),
         FakePkg('foo/bar-2.0.1', slot='2'),
     ]
     installed_repos = FakeRepo(pkgs=installed_pkgs)
     repo = FakeRepo(pkgs=pkgs)
     a = pmerge.parse_target(parse_match("bar:0"), repo, installed_repos)
     assert len(a) == 1
     assert a[0].key == 'foo/bar'
     assert a[0].match(atom('foo/bar:0'))
     assert not a[0].match(atom('foo/bar:2'))
Beispiel #10
0
 def test_collision_slotted(self):
     pkgs = [
         FakePkg('foo/bar-1.0.1', slot='0'),
         FakePkg('foo/bar-2.0.2', slot='2'),
         FakePkg('foon/bar-3.4.5', slot='0'),
     ]
     installed_pkgs = [
         FakePkg('foo/bar-1.0.0', slot='0'),
         FakePkg('foo/bar-2.0.1', slot='2'),
     ]
     installed_repos = FakeRepo(pkgs=installed_pkgs)
     repo = FakeRepo(pkgs=pkgs)
     a = pmerge.parse_target(parse_match("bar:0"), repo, installed_repos)
     assert len(a) == 1
     assert a[0].key == 'foo/bar'
     assert a[0].match(atom('foo/bar:0'))
     assert not a[0].match(atom('foo/bar:2'))