Exemplo n.º 1
0
	def getData(self):
		"""Validation and data post-processing"""
		data = []

		data.append(self._generateGolangProjectInfoFedora())
		# TODO(jchaloup): move validation to unit-tests
		validator = ArtefactSchemaValidator(ARTEFACT_GOLANG_PROJECT_INFO_FEDORA)
		if not validator.validate(data[0]):
			logging.error("%s is not valid" % ARTEFACT_GOLANG_PROJECT_INFO_FEDORA)
			return {}

		data.append(self._generateGolangProjectToPackageName())
		# TODO(jchaloup): move validation to unit-tests
		validator = ArtefactSchemaValidator(ARTEFACT_GOLANG_PROJECT_TO_PACKAGE_NAME)
		if not validator.validate(data[1]):
			logging.error("%s is not valid" % ARTEFACT_GOLANG_PROJECT_TO_PACKAGE_NAME)
			return {}

		data.append(self._generateGolangIPPrefixToPackageName())
		# TODO(jchaloup): move validation to unit-tests
		validator = ArtefactSchemaValidator(ARTEFACT_GOLANG_IPPREFIX_TO_PACKAGE_NAME)
		if not validator.validate(data[2]):
			logging.error("%s is not valid" % ARTEFACT_GOLANG_IPPREFIX_TO_PACKAGE_NAME)
			return {}

		return data
Exemplo n.º 2
0
	def getData(self):
		if not self.input_validated:
			return []
		data = []
		for i, commit in enumerate(self.commits):
			data.append(self._generateGolangProjectRepositoryCommit(commit))
			validator = ArtefactSchemaValidator(ARTEFACT_GOLANG_PROJECT_REPOSITORY_COMMIT)
			if not validator.validate(data[i]):
				logging.error('%s is not valid' % ARTEFACT_GOLANG_PROJECT_REPOSITORY_COMMIT)
				return {}

		data.append(self._generateGolangProjectRepositoryInfo())
		validator = ArtefactSchemaValidator(ARTEFACT_GOLANG_PROJECT_REPOSITORY_INFO)
		if not validator.validate(data[-1]):
			logging.error('%s is not valid' % ARTEFACT_GOLANG_PROJECT_REPOSITORY_INFO)
			return {}
		return data
Exemplo n.º 3
0
 def test_valid_output(self, repository):
     plugin = RepositoryDataExtractor()
     assert plugin.setData(self.input_data)
     assert plugin.execute()
     output_data = plugin.getData()
     assert output_data
     validator = ArtefactSchemaValidator(output_data['artefact'])
     assert validator.validate(output_data)
Exemplo n.º 4
0
	def getData(self):
		if not self.input_validated:
			return []

		data = []
		for i, build in enumerate(self.builds):
			data.append(self._generateGolangProjectDistributionBuild(build))
			validator = ArtefactSchemaValidator(ARTEFACT_GOLANG_PROJECT_DISTRIBUTION_BUILD)
			if not validator.validate(data[i]):
				logging.error('%s is not valid' % ARTEFACT_GOLANG_PROJECT_DISTRIBUTION_BUILD)
				return {}

		data.append(self._generateGolangProjectDistributionInfo())
		validator = ArtefactSchemaValidator(ARTEFACT_GOLANG_PROJECT_DISTRIBUTION_INFO)
		if not validator.validate(data[-1]):
			logging.error('%s is not valid' % ARTEFACT_GOLANG_PROJECT_DISTRIBUTION_INFO)
			return {}
		return data
Exemplo n.º 5
0
 def test_valid_output(self, package):
     plugin = SpecDataExtractor()
     assert plugin.setData(self.input_data)
     assert plugin.execute()
     output_data = plugin.getData()
     assert output_data
     for data in output_data:
         validator = ArtefactSchemaValidator(data['artefact'])
         assert validator.validate(data)
Exemplo n.º 6
0
	def getData(self):
		data = []

		data.append(self._generateGolangProjectDistributionPackagesArtefact())
		# TODO(jchaloup): move validation to unit-tests
		validator = ArtefactSchemaValidator(ARTEFACT_GOLANG_PROJECT_DISTRIBUTION_PACKAGES)
		if not validator.validate(data[0]):
			logging.error("%s is not valid" % ARTEFACT_GOLANG_PROJECT_DISTRIBUTION_PACKAGES)
			return {}

		data.append(self._generateGolangProjectDistributionExportedAPI())
		# TODO(jchaloup): move validation to unit-tests
		validator = ArtefactSchemaValidator(ARTEFACT_GOLANG_PROJECT_DISTRIBUTION_EXPORTED_API)
		if not validator.validate(data[1]):
			logging.error("%s is not valid" % ARTEFACT_GOLANG_PROJECT_DISTRIBUTION_EXPORTED_API)
			return {}

		return data
 def test_valid_output(self, project):
     plugin = DistributionPackageBuildsExtractor()
     assert plugin.setData(self.input_data)
     assert plugin.execute()
     output_data = plugin.getData()
     assert output_data
     for data in output_data:
         validator = ArtefactSchemaValidator(data['artefact'])
         assert validator.validate(data)
Exemplo n.º 8
0
 def test_valid_output(self, project):
     plugin = GoSymbolsExtractor()
     assert plugin.setData(self.input_data)
     assert plugin.execute()
     output_data = plugin.getData()
     assert output_data
     for data in output_data:
         validator = ArtefactSchemaValidator(data["artefact"])
         assert validator.validate(data)
Exemplo n.º 9
0
	def getData(self):
		if not self.input_validated:
			return []

		if self.commit != "":
			return self._generateGolangProjectRepositoryCommit(self.commits[""])

		commits_data = {}
		branches = {}
		# TODO(jchaloup) this is quite redundant, make it better!!!
		for branch in self.commits:
			for commit in self.commits[branch]:
				try:
					branches[branch].append(commit)
				except KeyError:
					branches[branch] = [commit]

				if commit in commits_data:
					continue

				commits_data[commit] = self._generateGolangProjectRepositoryCommit(self.commits[branch][commit])

		# from all branches (up to master) filter out all commits that are already covered in master branch
		if "master" in branches:
			for branch in filter(lambda l: l != "master", branches.keys()):
				branches[branch] = list(set(branches[branch]) - set(branches["master"]))

		# TODO(jchaloup): move validation to unit-tests
		#for commit in commits_data:
		#	validator = ArtefactSchemaValidator(ARTEFACT_GOLANG_PROJECT_REPOSITORY_COMMIT)
		#	if not validator.validate(commits_data[commit]):
		#		logging.error('%s is not valid' % ARTEFACT_GOLANG_PROJECT_REPOSITORY_COMMIT)
		#		return {}

		info = self._generateGolangProjectRepositoryInfo(branches)
		validator = ArtefactSchemaValidator(ARTEFACT_GOLANG_PROJECT_REPOSITORY_INFO)
		if not validator.validate(info):
			logging.error('%s is not valid' % ARTEFACT_GOLANG_PROJECT_REPOSITORY_INFO)
			return {}

		repo_commits = []
		for commit in commits_data:
			repo_commits.append(commits_data[commit])

		return {
			"info": info,
			"commits": repo_commits,
			"branches": branches
		}