def test_get_source_arches_without_matches(self, mock): dsc_arch = ['amd64', 'sparc'] ret = get_source_arches(dsc_arch, self.arches) self.assertEquals(ret[0].name, 'amd64') self.assertEquals(ret[1].name, 'sparc')
def test_hurd_arches(): assert set([ 'hurd-i386', 'hurd-amd64', 'armel' ]) == set([ x.name for x in get_source_arches([ 'hurd-i386', 'hurd-amd64', 'armel' ], valid_arches) ])
def test_kfreebsd_arches(): assert set([ 'kfreebsd-i386', 'kfreebsd-amd64', 'armhf' ]) == set([ x.name for x in get_source_arches([ 'kfreebsd-i386', 'kfreebsd-amd64', 'armhf' ], valid_arches) ])
def create_source(dsc, group_suite, component, uploader, affinity_preference, valid_affinities): source = Source( name=dsc['Source'], version=dsc['Version'], group_suite=group_suite, component=component, uploader=uploader, uploaded_at=datetime.utcnow() ) source.arches = get_source_arches(dsc['Architecture'].split(), group_suite.arches) # Sources building arch-dependent packages should build any # arch-independent packages on an architecture it is building # arch-dependent packages on. source.affinity = get_preferred_affinity( affinity_preference, valid_affinities.split(), [x for x in source.arches if x.name not in ["source", "all"]] or [x for x in source.group_suite.arches if x.name not in ["source", "all"]] ) MAINTAINER = re.compile("(?P<name>.*) \<(?P<email>.*)\>") source.maintainers.append(Maintainer( comaintainer=False, original_maintainer=False, **MAINTAINER.match(dsc.get('Maintainer')).groupdict() )) if dsc.get('XSBC-Original-Maintainer', None): source.maintainers.append(Maintainer( comaintainer=False, original_maintainer=True, **MAINTAINER.match(dsc.get('XSBC-Original-Maintainer')).groupdict() )) whos = re.findall(r'(?:[^,"]|"(?:\\.|[^"])*")+', dsc.get("Uploaders", "")) for who in [x.strip() for x in whos if x.strip() != ""]: source.maintainers.append(Maintainer( comaintainer=True, original_maintainer=False, **MAINTAINER.match(who).groupdict() )) return source
def create_source(dsc, group_suite, component, uploader, affinity_preference, valid_affinities): source = Source(name=dsc['Source'], version=dsc['Version'], group_suite=group_suite, component=component, uploader=uploader, uploaded_at=datetime.utcnow()) source.arches = get_source_arches(dsc['Architecture'].split(), group_suite.arches) # Sources building arch-dependent packages should build any # arch-independent packages on an architecture it is building # arch-dependent packages on. source.affinity = get_preferred_affinity( affinity_preference, valid_affinities.split(), [x for x in source.arches if x.name not in ["source", "all"]] or [ x for x in source.group_suite.arches if x.name not in ["source", "all"] ]) MAINTAINER = re.compile("(?P<name>.*) \<(?P<email>.*)\>") source.maintainers.append( Maintainer(comaintainer=False, original_maintainer=False, **MAINTAINER.match(dsc.get('Maintainer')).groupdict())) if dsc.get('XSBC-Original-Maintainer', None): source.maintainers.append( Maintainer(comaintainer=False, original_maintainer=True, **MAINTAINER.match( dsc.get('XSBC-Original-Maintainer')).groupdict())) whos = re.findall(r'(?:[^,"]|"(?:\\.|[^"])*")+', dsc.get("Uploaders", "")) for who in [x.strip() for x in whos if x.strip() != ""]: source.maintainers.append( Maintainer(comaintainer=True, original_maintainer=False, **MAINTAINER.match(who).groupdict())) return source
def create_source(dsc, group_suite, component, uploader): source = Source( name=dsc['Source'], version=dsc['Version'], group_suite=group_suite, component=component, uploader=uploader, uploaded_at=datetime.utcnow() ) source.arches = get_source_arches(dsc['Architecture'].split(), group_suite.arches) MAINTAINER = re.compile("(?P<name>.*) \<(?P<email>.*)\>") source.maintainers.append(Maintainer( comaintainer=False, original_maintainer=False, **MAINTAINER.match(dsc.get('Maintainer')).groupdict() )) if dsc.get('XSBC-Original-Maintainer', None): source.maintainers.append(Maintainer( comaintainer=False, original_maintainer=True, **MAINTAINER.match(dsc.get('XSBC-Original-Maintainer')).groupdict() )) whos = re.findall(r'(?:[^,"]|"(?:\\.|[^"])*")+', dsc.get("Uploaders", "")) for who in [x.strip() for x in whos if x.strip() != ""]: source.maintainers.append(Maintainer( comaintainer=True, original_maintainer=False, **MAINTAINER.match(who).groupdict() )) return source
def test_simple_arches(): assert set(['amd64', 'armhf']) == set([ x.name for x in get_source_arches(['amd64', 'armhf'], valid_arches) ])
def test_any_arches(): assert valid_arches == get_source_arches(['any'], valid_arches)
def test_get_source_arches_without_matches(self, mock): dsc_arch = ['linux-i386'] ret = get_source_arches(dsc_arch, self.arches) self.assertEquals(ret, [])