예제 #1
0
    def test_simple_install(self):
        egg = DUMMY_EGG
        base_egg = os.path.basename(egg)
        fetch_opcode = 0

        entries = [
            EnpkgS3IndexEntry(product="free", build=1,
                              egg_basename="dummy", version="1.0.1",
                              available=True),
        ]

        repo = MetadataOnlyStore(entries)
        repo.connect()

        with mock.patch("enstaller.enpkg.Enpkg.fetch") as mocked_fetch:
            enpkg = Enpkg(repo, prefixes=self.prefixes, hook=None,
                          evt_mgr=None, verbose=False, config=Configuration())
            local_repo = JoinedEggCollection([
                EggCollection(prefix, False, None) for prefix in
                self.prefixes])
            local_repo.install = mock.MagicMock()
            enpkg.ec = local_repo

            actions = enpkg.install_actions("dummy")
            enpkg.execute(actions)

            mocked_fetch.assert_called_with(base_egg, force=fetch_opcode)
            local_repo.install.assert_called_with(base_egg, enpkg.local_dir,
                                                  None)
예제 #2
0
def _create_prefix_with_eggs(config, prefix, installed_entries=None, remote_entries=None):
    if remote_entries is None:
        remote_entries = []
    if installed_entries is None:
        installed_entries = []

    repo = MetadataOnlyStore(remote_entries)
    repo.connect()

    enpkg = Enpkg(repo, prefixes=[prefix], hook=None,
                  evt_mgr=None, verbose=False, config=config)
    enpkg.ec = JoinedEggCollection([
        MetaOnlyEggCollection(installed_entries)])
    return enpkg
예제 #3
0
    def test_simple_fetch(self):
        egg = "yoyo.egg"
        fetch_opcode = 0

        repo = MetadataOnlyStore([])
        repo.connect()

        with mock.patch("enstaller.enpkg.Enpkg.fetch") as mocked_fetch:
            enpkg = Enpkg(repo, prefixes=self.prefixes, hook=None,
                          evt_mgr=None, verbose=False, config=Configuration())
            enpkg.ec = mock.MagicMock()
            enpkg.execute([("fetch_{0}".format(fetch_opcode), egg)])

            self.assertTrue(mocked_fetch.called)
            mocked_fetch.assert_called_with(egg, force=fetch_opcode)
예제 #4
0
    def test_remove(self):
        repo = MetadataOnlyStore([])
        repo.connect()

        with mkdtemp() as d:
            makedirs(d)

            for egg in [DUMMY_EGG]:
                egginst = EggInst(egg, d)
                egginst.install()

            local_repo = JoinedEggCollection([EggCollection(d, False, None)])
            enpkg = Enpkg(repo, prefixes=[d], hook=None,
                          evt_mgr=None, verbose=False, config=Configuration())
            enpkg.ec = local_repo

            self.assertTrue(local_repo.find(os.path.basename(DUMMY_EGG)))
            actions = enpkg.remove_actions("dummy")
            self.assertEqual(actions, [("remove", os.path.basename(DUMMY_EGG))])
예제 #5
0
    def test_chained_override_update(self):
        """ Test update to package with latest version in lower prefix
        but an older version in primary prefix.
        """
        l0_egg = NOSE_1_3_0
        l1_egg = NOSE_1_2_1

        expected_actions = [
            ('fetch_0', os.path.basename(l0_egg)),
            ('remove', os.path.basename(l1_egg)),
            ('install', os.path.basename(l0_egg)),
        ]

        entries = [
            dummy_enpkg_entry_factory(*split_eggname(os.path.basename(l0_egg))),
        ]

        repo = MetadataOnlyStore(entries)
        repo.connect()

        with mkdtemp() as d:
            l0 = os.path.join(d, 'l0')
            l1 = os.path.join(d, 'l1')
            makedirs(l0)
            makedirs(l1)

            # Install latest version in l0
            EggInst(l0_egg, l0).install()
            # Install older version in l1
            EggInst(l1_egg, l1).install()

            local_repo = JoinedEggCollection([EggCollection(l1, False, None),
                                              EggCollection(l0, False, None)])
            enpkg = Enpkg(repo, prefixes=[l1, l0], hook=None,
                          evt_mgr=None, verbose=False, config=Configuration())
            enpkg.ec = local_repo

            actions = enpkg.install_actions("nose")
            self.assertListEqual(actions, expected_actions)