def test_requirement(): reqs_spec1 = repository_spec.RepositorySpec(namespace='mynamespace', name='myname', version='3.4.5') provides_spec2 = repository_spec.RepositorySpec(namespace='othernamespace', name='provides_something', version='1.0.0') req = requirement.Requirement(repository_spec=reqs_spec1, requirement_spec=provides_spec2, op=requirement.RequirementOps.EQ) assert isinstance(req, requirement.Requirement) assert req.repository_spec == reqs_spec1 assert req.requirement_spec == provides_spec2
def test_repository_spec_requirement_spec_sortable(): repo_spec1 = repository_spec.RepositorySpec(namespace='ns', name='n', version='3.4.5') req_spec = requirement_spec.RequirementSpec(namespace='ns', name='n', version_spec='==3.4.5') req_spec2 = requirement_spec.RequirementSpec(namespace='ns', name='n', version_spec='*') req1 = requirement.Requirement(repository_spec=repo_spec1, requirement_spec=req_spec, op=requirement.RequirementOps.EQ) req2 = requirement.Requirement(repository_spec=repo_spec1, requirement_spec=req_spec2, op=requirement.RequirementOps.EQ) log.debug('req1: %s', req1) log.debug('req2: %s', req2) log.debug('repo_spec1: %s', repo_spec1) log.debug('req_spec: %s', req_spec) reqs = [req1, req2] res = sorted(reqs) log.debug('res: %s', res)
def test_repository_spec_requirement_spec_cmp(): repo_spec1 = repository_spec.RepositorySpec(namespace='ns', name='n', version='3.4.5') repo_spec2 = repository_spec.RepositorySpec(namespace='ns', name='n', version='3.4.5') req = requirement.Requirement(repository_spec=repo_spec1, requirement_spec=repo_spec2, op=requirement.RequirementOps.EQ) log.debug('req: %s', req) log.debug('repo_spec1: %s', repo_spec1) log.debug('repo_spec2: %s', repo_spec2) assert req.repository_spec == repo_spec1 assert req.requirement_spec == repo_spec2
def test_frozen(csf): cr = repository.Repository(repository_spec=csf) new_cr = repository_spec.RepositorySpec(namespace='somenamespace', name='somename', version='1.2.3') with pytest.raises(attr.exceptions.FrozenInstanceError): cr.repository_spec = new_cr with pytest.raises(attr.exceptions.FrozenInstanceError): cr.path = '/dev/null/somepath' with pytest.raises(attr.exceptions.FrozenInstanceError): cr.installed = True
def csf(request): _cs = repository_spec.RepositorySpec(namespace='somenamespace', name='somename', version='1.2.3') yield _cs
cr = repository.Repository(repository_spec=csf, path=path) assert isinstance(cr, repository.Repository) assert path in repr(cr) assert cr.path == path def CR(repository_spec=None, path=None): if path: return repository.Repository(repository_spec=repository_spec, path=path) return repository.Repository(repository_spec=repository_spec) ns_n = repository_spec.RepositorySpec(namespace='ns', name='n', version='1.0.0') diffns_n = repository_spec.RepositorySpec(namespace='diffns', name='n', version='1.0.0') ns_n_1_0_0 = ns_n diffns_n_1_0_0 = diffns_n ns_n_1_0_1 = repository_spec.RepositorySpec(namespace='ns', name='n', version='1.0.1') path1 = '/dev/null/1' path2 = '/dev/null/2' @pytest.mark.parametrize(