def test_init(self):
        maint = self.get_maintainer()
        pack = Package(name='foo',
                       version='0.0.0',
                       maintainers=[maint],
                       licenses=['BSD'])
        self.assertEqual(None, pack.filename)
        self.assertEqual('0.0.0', pack.version)
        self.assertEqual(None, pack.version_compatibility)
        self.assertEqual([], pack.urls)
        self.assertEqual([], pack.authors)
        self.assertEqual([maint], pack.maintainers)
        self.assertEqual(['BSD'], pack.licenses)
        self.assertEqual([], pack.build_depends)
        self.assertEqual([], pack.buildtool_depends)
        self.assertEqual([], pack.test_depends)
        self.assertEqual([], pack.conflicts)
        self.assertEqual([], pack.replaces)
        self.assertEqual([], pack.exports)
        self.assertEqual([], pack.group_depends)
        self.assertEqual([], pack.member_of_groups)
        pack = Package(filename='foo',
                       name='bar',
                       version='0.0.0',
                       licenses=['BSD'],
                       maintainers=[self.get_maintainer()])
        self.assertEqual('foo', pack.filename)

        self.assertRaises(TypeError, Package, unknownattribute=42)
Exemple #2
0
def parse_package(path):
    if not package_exists_at(path):
        return None
    cmakelists = os.path.join(path, 'CMakeLists.txt')
    data = extract_data(cmakelists)
    pkg = Package(filename=cmakelists, **data)
    pkg.exports = [Export('build_type', content='cmake')]
    return pkg
Exemple #3
0
def parse_package(path):
    if not package_exists_at(path):
        return None
    cmakelists = os.path.join(path, 'CMakeLists.txt')
    data = extract_data(cmakelists)
    pkg = Package(filename=cmakelists, **data)
    pkg.exports = [Export('build_type', content='cmake')]
    return pkg
Exemple #4
0
def parse_package(path):
    if not package_exists_at(path):
        return None
    setuppy = os.path.join(path, 'setup.py')
    kwargs = get_setup_arguments(setuppy)
    data = extract_data(**kwargs)
    pkg = Package(filename=setuppy, **data)
    pkg.exports = [Export('build_type', content='ament_python')]
    return pkg
 def test_init_kwargs_string(self):
     pack = Package(filename='foo',
                    name='bar',
                    package_format='1',
                    version='1.0.1',
                    version_compatibility='1.0.0',
                    description='pdesc',
                    licenses=['BSD'],
                    maintainers=[self.get_maintainer()])
     self.assertEqual('foo', pack.filename)
     self.assertEqual('bar', pack.name)
     self.assertEqual('1', pack.package_format)
     self.assertEqual('1.0.1', pack.version)
     self.assertEqual('1.0.0', pack.version_compatibility)
     self.assertEqual('pdesc', pack.description)
 def test_init_kwargs_object(self):
     mmain = [self.get_maintainer(), self.get_maintainer()]
     mlis = ['MIT', 'BSD']
     mauth = [self.get_maintainer(), self.get_maintainer()]
     murl = [Mock(), Mock()]
     mbuilddep = [Mock(), Mock()]
     mbuildtooldep = [Mock(), Mock()]
     mtestdep = [Mock(), Mock()]
     mconf = [Mock(), Mock()]
     mrepl = [Mock(), Mock()]
     mexp = [Mock(), Mock()]
     mgroup = [
         self.get_group_dependency('group1'),
         self.get_group_dependency('group2')
     ]
     mmember = ['member1', 'member2']
     pack = Package(package_format='3',
                    name='bar',
                    version='0.0.0',
                    maintainers=mmain,
                    licenses=mlis,
                    urls=murl,
                    authors=mauth,
                    build_depends=mbuilddep,
                    buildtool_depends=mbuildtooldep,
                    test_depends=mtestdep,
                    conflicts=mconf,
                    replaces=mrepl,
                    group_depends=mgroup,
                    member_of_groups=mmember,
                    exports=mexp)
     self.assertEqual(mmain, pack.maintainers)
     self.assertEqual(mlis, pack.licenses)
     self.assertEqual(murl, pack.urls)
     self.assertEqual(mauth, pack.authors)
     self.assertEqual(mbuilddep, pack.build_depends)
     self.assertEqual(mbuildtooldep, pack.buildtool_depends)
     self.assertEqual(mtestdep, pack.test_depends)
     self.assertEqual(mconf, pack.conflicts)
     self.assertEqual(mrepl, pack.replaces)
     self.assertEqual(mexp, pack.exports)
     self.assertEqual(mgroup, pack.group_depends)
     self.assertEqual(mmember, pack.member_of_groups)
    def test_validate_package(self):
        maint = self.get_maintainer()
        pack = Package(filename='foo',
                       name='bar_2go',
                       package_format='1',
                       version='0.0.0',
                       description='pdesc',
                       licenses=['BSD'],
                       maintainers=[maint])
        pack.validate()
        # check invalid names
        pack.name = '2bar'
        self.assertRaises(InvalidPackage, Package.validate, pack)
        pack.name = 'bar bza'
        self.assertRaises(InvalidPackage, Package.validate, pack)
        pack.name = 'BAR'
        self.assertRaises(InvalidPackage, Package.validate, pack)
        # dashes should be acceptable in packages other than catkin or
        # ament*.
        # no build_type, so catkin is assumed per REP-140.
        pack.name = 'bar-bza'
        self.assertRaises(InvalidPackage, Package.validate, pack)
        # check explicit catkin and ament_* build_types
        build_type = Mock(tagname='build_type',
                          attributes={},
                          content='catkin')
        pack.exports = [build_type]
        self.assertRaises(InvalidPackage, Package.validate, pack)
        build_type.content = 'ament_cmake'
        self.assertRaises(InvalidPackage, Package.validate, pack)
        build_type.content = 'ament_python'
        self.assertRaises(InvalidPackage, Package.validate, pack)
        # check non ament/catkin build type is valid
        build_type.content = 'cmake'
        pack.validate()
        # check authors emails
        pack.name = 'bar'
        auth1 = Mock()
        auth2 = Mock()
        auth2.validate.side_effect = InvalidPackage('foo')
        pack.authors = [auth1, auth2]
        self.assertRaises(InvalidPackage, Package.validate, pack)
        pack.authors = []
        pack.validate()
        # check maintainer required with email
        pack.maintainers = []
        self.assertRaises(InvalidPackage, Package.validate, pack)
        pack.maintainers = [maint]
        maint.email = None
        self.assertRaises(InvalidPackage, Package.validate, pack)
        maint.email = '*****@*****.**'

        for dep_type in [
                pack.build_depends, pack.buildtool_depends,
                pack.build_export_depends, pack.buildtool_export_depends,
                pack.exec_depends, pack.test_depends, pack.doc_depends
        ]:
            pack.validate()
            depend = Dependency(pack.name)
            dep_type.append(depend)
            self.assertRaises(InvalidPackage, Package.validate, pack)
            dep_type.remove(depend)
Exemple #8
0
    def test_validate_package(self):
        maint = self.get_maintainer()
        pack = Package(filename='foo',
                       name='bar_2go',
                       package_format='1',
                       version='0.0.0',
                       description='pdesc',
                       licenses=['BSD'],
                       maintainers=[maint])
        pack.validate()
        # check invalid names
        pack.name = '2bar'
        self.assertRaises(InvalidPackage, Package.validate, pack)
        pack.name = 'bar bza'
        self.assertRaises(InvalidPackage, Package.validate, pack)
        pack.name = 'BAR'
        self.assertRaises(InvalidPackage, Package.validate, pack)
        # dashes should be acceptable in packages other than catkin or
        # ament*.
        # no build_type, so catkin is assumed per REP-140.
        pack.name = 'bar-bza'
        self.assertRaises(InvalidPackage, Package.validate, pack)
        # check explicit catkin and ament_* build_types
        build_type = Mock(tagname='build_type', attributes={}, content='catkin')
        pack.exports = [build_type]
        self.assertRaises(InvalidPackage, Package.validate, pack)
        build_type.content = 'ament_cmake'
        self.assertRaises(InvalidPackage, Package.validate, pack)
        build_type.content = 'ament_python'
        self.assertRaises(InvalidPackage, Package.validate, pack)
        # check non ament/catkin build type is valid
        build_type.content = 'cmake'
        pack.validate()
        # check authors emails
        pack.name = 'bar'
        auth1 = Mock()
        auth2 = Mock()
        auth2.validate.side_effect = InvalidPackage('foo')
        pack.authors = [auth1, auth2]
        self.assertRaises(InvalidPackage, Package.validate, pack)
        pack.authors = []
        pack.validate()
        # check maintainer required with email
        pack.maintainers = []
        self.assertRaises(InvalidPackage, Package.validate, pack)
        pack.maintainers = [maint]
        maint.email = None
        self.assertRaises(InvalidPackage, Package.validate, pack)
        maint.email = '*****@*****.**'

        for dep_type in [
                pack.build_depends, pack.buildtool_depends,
                pack.build_export_depends, pack.buildtool_export_depends,
                pack.exec_depends, pack.test_depends, pack.doc_depends]:
            pack.validate()
            depend = Dependency(pack.name)
            dep_type.append(depend)
            self.assertRaises(InvalidPackage, Package.validate, pack)
            dep_type.remove(depend)