示例#1
0
	def test_detects_feed_with_all_implementations_added(self):
		self.write_initial_feed(self.proj, add_impl = True)
		modify(SOURCES)['upstream_mock'] = lambda **kw: self.proj

		feed = Feed.from_file(self.buffer)
		feed.add_implementation('0.1')
		self.assertEquals(feed.unpublished_versions(), set([]))
示例#2
0
	def test_feed_creation(self):
		feed = Feed.from_project(self.proj, "http://example.com/dist/0install/my-project.xml")
		feed.save(self.buffer)
		output = self.saved_dom()
		self.assertEqual(output['uri'], 'http://example.com/dist/0install/my-project.xml')
		self.assert_details_match(self.proj)
		self.assertEqual(output.find('name').text, 'my-project')
示例#3
0
def _feed_from_path(path):
	if os.path.exists(path):
		ctx = open(path)
	else:
		assert '://' in path, "file does not exist (and does not look like a URL): %s" % (path,)
		ctx = contextlib.closing(urllib.urlopen(path))
	with ctx as file:
		return Feed.from_file(file)
示例#4
0
def update(opts):
	assert os.path.exists(opts.feed)
	with open(opts.feed, 'r+') as file:
		feed = Feed.from_file(file)
		if not opts.just_info:
			feed.add_implementation(version_string=opts.version)
		file.seek(0)
		feed.save(file)
示例#5
0
	def test_update_details(self):
		self.write_initial_feed(self.proj)
		modify(SOURCES)['upstream_mock'] = lambda **kw: self.proj2
		feed = Feed.from_file(self.buffer)
		self.assertEqual(feed.project, self.proj2)

		feed.update_metadata()
		self.clear_buffer()
		feed.save(self.buffer)
		self.assert_details_match(self.proj2)
示例#6
0
def new(opts):
	project = guess_project(opts.url)
	opts.feed = os.path.expanduser(opts.feed)
	if not opts.force and os.path.exists(opts.feed):
		print "feed %s already exists - use --force to overwrite it"
		return 1
	filename = os.path.basename(opts.feed)
	destination_url = opts.prefix.rstrip('/') + '/' + filename
	feed = Feed.from_project(project, destination_url)
	feed.add_implementation()
	with open(opts.feed, 'w') as outfile:
		feed.save(outfile)
示例#7
0
	def test_add_implementation_without_modifying_details(self):
		self.write_initial_feed(self.proj)
		modify(SOURCES)['upstream_mock'] = lambda **kw: self.proj

		feed = Feed.from_file(self.buffer)
		self.assertEqual(feed.project, self.proj)

		feed.add_implementation()
		self.clear_buffer()
		feed.save(self.buffer)

		output = self.saved_dom()
		implementations = output.findAll('implementation')
		self.assertEqual(len(implementations), 1, repr(implementations))
		impl = implementations[0]
		self.assertEqual(impl["version"], str(self.proj.latest_version.derived))
		self.assert_impl_matches(impl, self.proj, size=1234, manifests={'sha256':'abcd', 'sha1new':'deff'}, type='text/awesome')
示例#8
0
def list(opts):
	if not os.path.exists(opts.feed):
		if opts.feed.startswith('http'):
			project = guess_project(opts.feed)
			print "Versions for project %s:" % (opts.feed,)
			for version in sorted(project.versions):
				print version.pretty()
			return
		else:
			assert os.path.exists(opts.feed)
	with open(opts.feed, 'r') as file:
		feed = Feed.from_file(file)

	print ""
	print " Version information for %s" % (opts.feed,)
	print " %s\n" % (feed.project.url,)
	_list_versions(feed)
示例#9
0
	def write_initial_feed(self, proj, add_impl = False):
		feed = Feed.from_project(proj, 'http://example.com/')
		if add_impl:
			feed.add_implementation()
		feed.save(self.buffer)
		self.buffer.seek(0)
示例#10
0
	def test_detects_up_to_date_feed(self):
		self.write_initial_feed(self.proj, add_impl = True)
		modify(SOURCES)['upstream_mock'] = lambda **kw: self.proj

		feed = Feed.from_file(self.buffer)
		self.assertEquals(feed.unpublished_versions(newest_only=True), set([]))
示例#11
0
	def test_detects_all_unpublished_versions(self):
		self.write_initial_feed(self.proj, add_impl = True)
		modify(SOURCES)['upstream_mock'] = lambda **kw: self.proj2
		feed = Feed.from_file(self.buffer)
		self.assertEquals(feed.unpublished_versions(newest_only=False), set(['0.1', '2.5.12']))