Example #1
0
	def testStoreStability(self):
		main_feed = reader.load_feed('Hello.xml', local = True)
		impl = main_feed.implementations['sha1=3ce644dc725f1d21cfcf02562c76f375944b266a']
		impl.user_stability = model.developer
		writer.save_feed(main_feed)

		# Rating now visible
		main_feed = reader.load_feed('Hello.xml', local = True)
		reader.update_user_feed_overrides(main_feed)
		self.assertEqual(1, len(main_feed.implementations))

		impl = main_feed.implementations['sha1=3ce644dc725f1d21cfcf02562c76f375944b266a']
		self.assertEqual(model.developer, impl.user_stability)
Example #2
0
	def testStoreStability(self):
		main_feed = reader.load_feed('Hello.xml', local = True)
		impl = main_feed.implementations['sha1=3ce644dc725f1d21cfcf02562c76f375944b266a']
		impl.user_stability = model.developer
		writer.save_feed(main_feed)

		# Rating now visible
		main_feed = reader.load_feed('Hello.xml', local = True)
		reader.update_user_feed_overrides(main_feed)
		self.assertEqual(1, len(main_feed.implementations))

		impl = main_feed.implementations['sha1=3ce644dc725f1d21cfcf02562c76f375944b266a']
		self.assertEqual(model.developer, impl.user_stability)
Example #3
0
    def testAddFeed(self):
        binary_iface = self.config.iface_cache.get_interface("http://foo/Binary.xml")

        out, err = self.run_0install(["list-feeds", binary_iface.uri])
        assert "(no feeds)" in out, out
        assert not err, err

        out, err = self.run_0install(["add-feed"])
        assert out.lower().startswith("usage:")
        assert "NEW-FEED" in out

        sys.stdin = Reply("1")
        assert binary_iface.extra_feeds == []

        out, err = self.run_0install(["add-feed", "Source.xml"])
        assert not err, err
        assert "Add as feed for 'http://foo/Binary.xml'" in out, out
        assert len(binary_iface.extra_feeds) == 1

        out, err = self.run_0install(["list-feeds", binary_iface.uri])
        assert "Source.xml" in out
        assert not err, err

        out, err = self.run_0install(["remove-feed", "Source.xml"])
        assert not err, err
        assert "Remove as feed for 'http://foo/Binary.xml'" in out, out
        assert len(binary_iface.extra_feeds) == 0

        source_feed = reader.load_feed("Source.xml")
        self.config.fetcher.allow_feed_download("http://foo/Source.xml", source_feed)
        out, err = self.run_0install(["add-feed", "http://foo/Source.xml"])
        assert not err, err
        assert "Downloading feed; please wait" in out, out
        assert len(binary_iface.extra_feeds) == 1
	def testAddFeed(self):
		binary_iface = self.config.iface_cache.get_interface('http://foo/Binary.xml')

		out, err = self.run_0install(['list-feeds', binary_iface.uri])
		assert "(no feeds)" in out, out
		assert not err, err

		out, err = self.run_0install(['add-feed'])
		assert out.lower().startswith("usage:")
		assert 'NEW-FEED' in out

		sys.stdin = Reply('1')
		assert binary_iface.extra_feeds == []

		out, err = self.run_0install(['add-feed', 'Source.xml'])
		assert not err, err
		assert "Add as feed for 'http://foo/Binary.xml'" in out, out
		assert len(binary_iface.extra_feeds) == 1

		out, err = self.run_0install(['list-feeds', binary_iface.uri])
		assert "Source.xml" in out
		assert not err, err

		out, err = self.run_0install(['remove-feed', 'Source.xml'])
		assert not err, err
		assert "Remove as feed for 'http://foo/Binary.xml'" in out, out
		assert len(binary_iface.extra_feeds) == 0

		source_feed = reader.load_feed('Source.xml')
		self.config.fetcher.allow_feed_download('http://foo/Source.xml', source_feed)
		out, err = self.run_0install(['add-feed', 'http://foo/Source.xml'])
		assert not err, err
		assert 'Downloading feed; please wait' in out, out
		assert len(binary_iface.extra_feeds) == 1
Example #5
0
    def testLang(self):
        tmp = tempfile.NamedTemporaryFile(mode='wt', prefix='test-')
        tmp.write("""<?xml version="1.0" ?>
<interface xmlns="http://zero-install.sourceforge.net/2004/injector/interface">
  <name>Foo</name>
  <summary>Foo</summary>
  <description>Foo</description>
  <feed langs='fr en_GB' src='http://localhost/feed.xml'/>
  <group>
    <group langs='fr en_GB'>
      <implementation id='sha1=124' version='2' langs='fr'/>
      <implementation id='sha1=234' version='2'/>
    </group>
    <implementation id='sha1=345' version='2'/>
  </group>
</interface>""")
        tmp.flush()

        feed = reader.load_feed(tmp.name, local=True)

        assert len(feed.implementations) == 3
        assert len(feed.feeds) == 1, feed.feeds

        self.assertEqual('fr en-GB', feed.feeds[0].langs)

        self.assertEqual('fr', feed.implementations['sha1=124'].langs)
        self.assertEqual('fr en-GB', feed.implementations['sha1=234'].langs)
        self.assertEqual('', feed.implementations['sha1=345'].langs)
Example #6
0
	def testLang(self):
		tmp = tempfile.NamedTemporaryFile(prefix = 'test-')
		tmp.write(
"""<?xml version="1.0" ?>
<interface xmlns="http://zero-install.sourceforge.net/2004/injector/interface">
  <name>Foo</name>
  <summary>Foo</summary>
  <description>Foo</description>
  <feed langs='fr en_GB' src='http://localhost/feed.xml'/>
  <group>
    <group langs='fr en_GB'>
      <implementation id='sha1=124' version='2' langs='fr'/>
      <implementation id='sha1=234' version='2'/>
    </group>
    <implementation id='sha1=345' version='2'/>
  </group>
</interface>""")
		tmp.flush()

		feed = reader.load_feed(tmp.name, local = True)

		assert len(feed.implementations) == 3
		assert len(feed.feeds) == 1, feed.feeds

		self.assertEquals('fr en_GB', feed.feeds[0].langs)

		self.assertEquals('fr', feed.implementations['sha1=124'].langs)
		self.assertEquals('fr en_GB', feed.implementations['sha1=234'].langs)
		self.assertEquals('', feed.implementations['sha1=345'].langs)
Example #7
0
 def testDownloadSelections(self):
     self.config.stores = TestStores()
     digest = "sha1=3ce644dc725f1d21cfcf02562c76f375944b266a"
     self.config.fetcher.allow_download(digest)
     hello = reader.load_feed("Hello.xml")
     self.config.fetcher.allow_feed_download("http://example.com:8000/Hello.xml", hello)
     out, err = self.run_0install(["download", "selections.xml", "--show"])
     assert not err, err
     assert self.config.stores.lookup_any([digest]).startswith("/fake")
     assert "Version: 1\n" in out
	def testDownloadSelections(self):
		self.config.stores = TestStores()
		digest = 'sha1=3ce644dc725f1d21cfcf02562c76f375944b266a'
		self.config.fetcher.allow_download(digest)
		hello = reader.load_feed('Hello.xml')
		self.config.fetcher.allow_feed_download('http://example.com:8000/Hello.xml', hello)
		out, err = self.run_0install(['download', 'selections.xml', '--show'])
		assert not err, err
		assert self.config.stores.lookup_any([digest]).startswith('/fake')
		assert 'Version: 1\n' in out
Example #9
0
 def testDownloadSelections(self):
     self.config.stores = TestStores()
     digest = 'sha1=3ce644dc725f1d21cfcf02562c76f375944b266a'
     self.config.fetcher.allow_download(digest)
     hello = reader.load_feed('Hello.xml')
     self.config.fetcher.allow_feed_download(
         'http://example.com:8000/Hello.xml', hello)
     out, err = self.run_0install(['download', 'selections.xml', '--show'])
     assert not err, err
     assert self.config.stores.lookup_any([digest]).startswith('/fake')
     assert 'Version: 1\n' in out
Example #10
0
	def import_feed(self, url, contents):
		"""contents can be a path or an Element."""
		iface_cache = self.config.iface_cache
		iface_cache.get_interface(url)

		if isinstance(contents, qdom.Element):
			feed = model.ZeroInstallFeed(contents)
		else:
			feed = reader.load_feed(contents)

		iface_cache._feeds[url] = feed
		return feed
Example #11
0
    def import_feed(self, url, contents):
        """contents can be a path or an Element."""
        iface_cache = self.config.iface_cache
        iface_cache.get_interface(url)

        if isinstance(contents, qdom.Element):
            feed = model.ZeroInstallFeed(contents)
        else:
            feed = reader.load_feed(contents)

        iface_cache._feeds[url] = feed
        return feed
	def testArchiveGenerateMissingSize(self):
                old_out = sys.stdout
		try:
			sys.stdout = StringIO()
			self.child = server.handle_requests(('HelloWorld.tgz'))

                        from zeroinstall.injector.reader import load_feed
			feed = load_feed(os.path.abspath('MissingSize.xml'), True, False, True, None, self.config)

                        expected_id = 'sha1=3ce644dc725f1d21cfcf02562c76f375944b266a'
                        assert feed.implementations[expected_id].download_sources[0].size == 176
		finally:
			sys.stdout = old_out
    def testArchiveGenerateMissingSize(self):
        old_out = sys.stdout
        try:
            sys.stdout = StringIO()
            self.child = server.handle_requests(('HelloWorld.tgz'))

            from zeroinstall.injector.reader import load_feed
            feed = load_feed(os.path.abspath('MissingSize.xml'), True, False,
                             True, None, self.config)

            expected_id = 'sha1=3ce644dc725f1d21cfcf02562c76f375944b266a'
            assert feed.implementations[expected_id].download_sources[
                0].size == 176
        finally:
            sys.stdout = old_out
	def testImplementationGenerateMissingId(self):
                old_out = sys.stdout
		try:
			sys.stdout = StringIO()
			self.child = server.handle_requests(('HelloWorld.tgz'))

                        from zeroinstall.zerostore import manifest
                        alg = manifest.get_algorithm('sha1')
                        assert alg

                        from zeroinstall.injector.reader import load_feed
			feed = load_feed(os.path.abspath('ImplementationNoId.xml'), True, False, False, alg, self.config)

                        expected_id = 'sha1=3ce644dc725f1d21cfcf02562c76f375944b266a'
                        assert feed.implementations[expected_id]
                        assert feed.implementations[expected_id].id == expected_id
		finally:
			sys.stdout = old_out
Example #15
0
    def import_feed(self, url, contents):
        """contents can be a path or an Element."""
        iface_cache = self.config.iface_cache
        iface_cache.get_interface(url)

        if isinstance(contents, qdom.Element):
            feed = model.ZeroInstallFeed(contents)
        else:
            feed = reader.load_feed(contents)

        iface_cache._feeds[url] = feed

        xml = qdom.to_UTF8(feed.feed_element)
        upstream_dir = basedir.save_cache_path(namespaces.config_site, "interfaces")
        cached = os.path.join(upstream_dir, model.escape(url))
        with open(cached, "wb") as stream:
            stream.write(xml)

        return feed
    def testImplementationGenerateMissingId(self):
        old_out = sys.stdout
        try:
            sys.stdout = StringIO()
            self.child = server.handle_requests(('HelloWorld.tgz'))

            from zeroinstall.zerostore import manifest
            alg = manifest.get_algorithm('sha1')
            assert alg

            from zeroinstall.injector.reader import load_feed
            feed = load_feed(os.path.abspath('ImplementationNoId.xml'), True,
                             False, False, alg, self.config)

            expected_id = 'sha1=3ce644dc725f1d21cfcf02562c76f375944b266a'
            assert feed.implementations[expected_id]
            assert feed.implementations[expected_id].id == expected_id
        finally:
            sys.stdout = old_out
Example #17
0
    def testAddFeed(self):
        binary_iface = self.config.iface_cache.get_interface(
            'http://foo/Binary.xml')

        out, err = self.run_0install(['list-feeds', binary_iface.uri])
        assert "(no feeds)" in out, out
        assert not err, err

        out, err = self.run_0install(['add-feed'])
        assert out.lower().startswith("usage:")
        assert 'NEW-FEED' in out

        sys.stdin = Reply('1')
        assert binary_iface.extra_feeds == []

        out, err = self.run_0install(['add-feed', 'Source.xml'])
        assert not err, err
        assert "Add as feed for 'http://foo/Binary.xml'" in out, out
        assert len(binary_iface.extra_feeds) == 1

        out, err = self.run_0install(['list-feeds', binary_iface.uri])
        assert "Source.xml" in out
        assert not err, err

        out, err = self.run_0install(['remove-feed', 'Source.xml'])
        assert not err, err
        assert "Remove as feed for 'http://foo/Binary.xml'" in out, out
        assert len(binary_iface.extra_feeds) == 0

        source_feed = reader.load_feed('Source.xml')
        self.config.fetcher.allow_feed_download('http://foo/Source.xml',
                                                source_feed)
        out, err = self.run_0install(['add-feed', 'http://foo/Source.xml'])
        assert not err, err
        assert 'Downloading feed; please wait' in out, out
        assert len(binary_iface.extra_feeds) == 1
Example #18
0
	def import_feed(self, url, path):
		iface_cache = self.config.iface_cache
		iface_cache.get_interface(url)
		feed = iface_cache._feeds[url] = reader.load_feed(path)
		return feed
	def testUpdate(self):
		out, err = self.run_0install(['update'])
		assert out.lower().startswith("usage:")
		assert '--message' in out, out

		# Updating a local feed with no dependencies
		out, err = self.run_0install(['update', 'Local.xml'])
		assert not err, err
		assert 'No updates found' in out, out

		# Using a remote feed for the first time
		self.config.stores = TestStores()
		binary_feed = reader.load_feed('Binary.xml')
		self.config.fetcher.allow_download('sha1=123')
		self.config.fetcher.allow_feed_download('http://foo/Binary.xml', binary_feed)
		out, err = self.run_0install(['update', 'http://foo/Binary.xml'])
		assert not err, err
		assert 'Binary.xml: new -> 1.0' in out, out

		# No updates.
		self.config.fetcher.allow_feed_download('http://foo/Binary.xml', binary_feed)
		out, err = self.run_0install(['update', 'http://foo/Binary.xml'])
		assert not err, err
		assert 'No updates found' in out, out

		# New binary release available.
		new_binary_feed = reader.load_feed('Binary.xml')
		new_binary_feed.implementations['sha1=123'].version = model.parse_version('1.1')
		self.config.fetcher.allow_feed_download('http://foo/Binary.xml', new_binary_feed)
		out, err = self.run_0install(['update', 'http://foo/Binary.xml'])
		assert not err, err
		assert 'Binary.xml: 1.0 -> 1.1' in out, out

		# Compiling from source for the first time.
		source_feed = reader.load_feed('Source.xml')
		compiler_feed = reader.load_feed('Compiler.xml')
		self.config.fetcher.allow_download('sha1=234')
		self.config.fetcher.allow_download('sha1=345')
		self.config.fetcher.allow_feed_download('http://foo/Compiler.xml', compiler_feed)
		self.config.fetcher.allow_feed_download('http://foo/Binary.xml', binary_feed)
		self.config.fetcher.allow_feed_download('http://foo/Source.xml', source_feed)
		out, err = self.run_0install(['update', 'http://foo/Binary.xml', '--source'])
		assert not err, err
		assert 'Binary.xml: new -> 1.0' in out, out
		assert 'Compiler.xml: new -> 1.0' in out, out

		# New compiler released.
		new_compiler_feed = reader.load_feed('Compiler.xml')
		new_compiler_feed.implementations['sha1=345'].version = model.parse_version('1.1')
		self.config.fetcher.allow_feed_download('http://foo/Compiler.xml', new_compiler_feed)
		self.config.fetcher.allow_feed_download('http://foo/Binary.xml', binary_feed)
		self.config.fetcher.allow_feed_download('http://foo/Source.xml', source_feed)
		out, err = self.run_0install(['update', 'http://foo/Binary.xml', '--source'])
		assert not err, err
		assert 'Compiler.xml: 1.0 -> 1.1' in out, out

		# A dependency disappears.
		new_source_feed = reader.load_feed('Source.xml')
		new_source_feed.implementations['sha1=234'].requires = []
		self.config.fetcher.allow_feed_download('http://foo/Compiler.xml', new_compiler_feed)
		self.config.fetcher.allow_feed_download('http://foo/Binary.xml', binary_feed)
		self.config.fetcher.allow_feed_download('http://foo/Source.xml', new_source_feed)
		out, err = self.run_0install(['update', 'http://foo/Binary.xml', '--source'])
		assert not err, err
		assert 'No longer used: http://foo/Compiler.xml' in out, out
Example #20
0
    def testUpdate(self):
        out, err = self.run_0install(["update"])
        assert out.lower().startswith("usage:")
        assert "--message" in out, out

        # Updating a local feed with no dependencies
        out, err = self.run_0install(["update", "Local.xml"])
        assert not err, err
        assert "No updates found" in out, out

        # Using a remote feed for the first time
        self.config.stores = TestStores()
        binary_feed = reader.load_feed("Binary.xml")
        self.config.fetcher.allow_download("sha1=123")
        self.config.fetcher.allow_feed_download("http://foo/Binary.xml", binary_feed)
        out, err = self.run_0install(["update", "http://foo/Binary.xml"])
        assert not err, err
        assert "Binary.xml: new -> 1.0" in out, out

        # No updates.
        self.config.fetcher.allow_feed_download("http://foo/Binary.xml", binary_feed)
        out, err = self.run_0install(["update", "http://foo/Binary.xml"])
        assert not err, err
        assert "No updates found" in out, out

        # New binary release available.
        new_binary_feed = reader.load_feed("Binary.xml")
        new_binary_feed.implementations["sha1=123"].version = model.parse_version("1.1")
        self.config.fetcher.allow_feed_download("http://foo/Binary.xml", new_binary_feed)
        out, err = self.run_0install(["update", "http://foo/Binary.xml"])
        assert not err, err
        assert "Binary.xml: 1.0 -> 1.1" in out, out

        # Compiling from source for the first time.
        source_feed = reader.load_feed("Source.xml")
        compiler_feed = reader.load_feed("Compiler.xml")
        self.config.fetcher.allow_download("sha1=234")
        self.config.fetcher.allow_download("sha1=345")
        self.config.fetcher.allow_feed_download("http://foo/Compiler.xml", compiler_feed)
        self.config.fetcher.allow_feed_download("http://foo/Binary.xml", binary_feed)
        self.config.fetcher.allow_feed_download("http://foo/Source.xml", source_feed)
        out, err = self.run_0install(["update", "http://foo/Binary.xml", "--source"])
        assert not err, err
        assert "Binary.xml: new -> 1.0" in out, out
        assert "Compiler.xml: new -> 1.0" in out, out

        # New compiler released.
        new_compiler_feed = reader.load_feed("Compiler.xml")
        new_compiler_feed.implementations["sha1=345"].version = model.parse_version("1.1")
        self.config.fetcher.allow_feed_download("http://foo/Compiler.xml", new_compiler_feed)
        self.config.fetcher.allow_feed_download("http://foo/Binary.xml", binary_feed)
        self.config.fetcher.allow_feed_download("http://foo/Source.xml", source_feed)
        out, err = self.run_0install(["update", "http://foo/Binary.xml", "--source"])
        assert not err, err
        assert "Compiler.xml: 1.0 -> 1.1" in out, out

        # A dependency disappears.
        new_source_feed = reader.load_feed("Source.xml")
        new_source_feed.implementations["sha1=234"].requires = []
        self.config.fetcher.allow_feed_download("http://foo/Compiler.xml", new_compiler_feed)
        self.config.fetcher.allow_feed_download("http://foo/Binary.xml", binary_feed)
        self.config.fetcher.allow_feed_download("http://foo/Source.xml", new_source_feed)
        out, err = self.run_0install(["update", "http://foo/Binary.xml", "--source"])
        assert not err, err
        assert "No longer used: http://foo/Compiler.xml" in out, out
Example #21
0
    def testUpdate(self):
        out, err = self.run_0install(['update'])
        assert out.lower().startswith("usage:")
        assert '--message' in out, out

        # Updating a local feed with no dependencies
        out, err = self.run_0install(['update', 'Local.xml'])
        assert not err, err
        assert 'No updates found' in out, out

        # Using a remote feed for the first time
        self.config.stores = TestStores()
        binary_feed = reader.load_feed('Binary.xml')
        self.config.fetcher.allow_download('sha1=123')
        self.config.fetcher.allow_feed_download('http://foo/Binary.xml',
                                                binary_feed)
        out, err = self.run_0install(['update', 'http://foo/Binary.xml'])
        assert not err, err
        assert 'Binary.xml: new -> 1.0' in out, out

        # No updates.
        self.config.fetcher.allow_feed_download('http://foo/Binary.xml',
                                                binary_feed)
        out, err = self.run_0install(['update', 'http://foo/Binary.xml'])
        assert not err, err
        assert 'No updates found' in out, out

        # New binary release available.
        new_binary_feed = reader.load_feed('Binary.xml')
        new_binary_feed.implementations[
            'sha1=123'].version = model.parse_version('1.1')
        self.config.fetcher.allow_feed_download('http://foo/Binary.xml',
                                                new_binary_feed)
        out, err = self.run_0install(['update', 'http://foo/Binary.xml'])
        assert not err, err
        assert 'Binary.xml: 1.0 -> 1.1' in out, out

        # Compiling from source for the first time.
        source_feed = reader.load_feed('Source.xml')
        compiler_feed = reader.load_feed('Compiler.xml')
        self.config.fetcher.allow_download('sha1=234')
        self.config.fetcher.allow_download('sha1=345')
        self.config.fetcher.allow_feed_download('http://foo/Compiler.xml',
                                                compiler_feed)
        self.config.fetcher.allow_feed_download('http://foo/Binary.xml',
                                                binary_feed)
        self.config.fetcher.allow_feed_download('http://foo/Source.xml',
                                                source_feed)
        out, err = self.run_0install(
            ['update', 'http://foo/Binary.xml', '--source'])
        assert not err, err
        assert 'Binary.xml: new -> 1.0' in out, out
        assert 'Compiler.xml: new -> 1.0' in out, out

        # New compiler released.
        new_compiler_feed = reader.load_feed('Compiler.xml')
        new_compiler_feed.implementations[
            'sha1=345'].version = model.parse_version('1.1')
        self.config.fetcher.allow_feed_download('http://foo/Compiler.xml',
                                                new_compiler_feed)
        self.config.fetcher.allow_feed_download('http://foo/Binary.xml',
                                                binary_feed)
        self.config.fetcher.allow_feed_download('http://foo/Source.xml',
                                                source_feed)
        out, err = self.run_0install(
            ['update', 'http://foo/Binary.xml', '--source'])
        assert not err, err
        assert 'Compiler.xml: 1.0 -> 1.1' in out, out

        # A dependency disappears.
        new_source_feed = reader.load_feed('Source.xml')
        new_source_feed.implementations['sha1=234'].requires = []
        self.config.fetcher.allow_feed_download('http://foo/Compiler.xml',
                                                new_compiler_feed)
        self.config.fetcher.allow_feed_download('http://foo/Binary.xml',
                                                binary_feed)
        self.config.fetcher.allow_feed_download('http://foo/Source.xml',
                                                new_source_feed)
        out, err = self.run_0install(
            ['update', 'http://foo/Binary.xml', '--source'])
        assert not err, err
        assert 'No longer used: http://foo/Compiler.xml' in out, out
Example #22
0
	def import_feed(self, url, path):
		iface_cache = self.config.iface_cache
		iface_cache.get_interface(url)
		feed = iface_cache._feeds[url] = reader.load_feed(path)
		return feed