Ejemplo n.º 1
0
def test_gbprepo_to_rosdep_data_on_bad_inputs():
    from rosdep2.gbpdistro_support import gbprepo_to_rosdep_data
    from rosdep2 import InvalidData
    simple_gbpdistro = {
        'release-name': 'foorte',
        'repositories': {},
        'type': 'gbp'
    }
    targets = {'foorte': ['lucid', 'oneiric']}
    # test bad data
    try:
        gbprepo_to_rosdep_data(simple_gbpdistro, [targets])
        assert False, "should have raised"
    except InvalidData:
        pass
    try:
        gbprepo_to_rosdep_data(
            {
                'targets': 1,
                'repositories': [],
                'type': 'gbp'
            }, targets)
        assert False, "should have raised"
    except InvalidData:
        pass
    try:
        gbprepo_to_rosdep_data([], targets)
        assert False, "should have raised"
    except InvalidData:
        pass
    # release-name must be in targets
    try:
        gbprepo_to_rosdep_data(
            {
                'release-name': 'barte',
                'repositories': [],
                'type': 'gbp'
            }, targets)
        assert False, "should have raised"
    except InvalidData:
        pass
    # gbp-distros must be list of dicts
    try:
        gbprepo_to_rosdep_data(
            {
                'release-name': 'foorte',
                'repositories': [1],
                'type': 'gbp'
            }, targets)
        assert False, "should have raised"
    except InvalidData:
        pass
    # gbp-distro target must be 'all' or a list of strings
    try:
        bad_example = {
            'name': 'common',
            'target': [1],
            'url': 'git://github.com/wg-debs/common_msgs.git'
        }
        gbprepo_to_rosdep_data(
            {
                'release-name': 'foorte',
                'repositories': [bad_example],
                'type': 'gbp'
            }, targets)
        assert False, "should have raised"
    except InvalidData:
        pass
Ejemplo n.º 2
0
def test_gbprepo_to_rosdep_data_on_ok_input():
    from rosdep2.gbpdistro_support import gbprepo_to_rosdep_data
    simple_gbpdistro = {
        'release-name': 'foorte',
        'repositories': {},
        'type': 'gbp'
    }
    targets = {'foorte': ['lucid', 'oneiric']}
    # make sure our sample files work for the above checks before
    # proceeding to real data
    rosdep_data = gbprepo_to_rosdep_data(simple_gbpdistro, targets)
    assert rosdep_data is not None
    assert {} == rosdep_data

    gbpdistro_data = {
        'release-name': 'foorte',
        'repositories': {
            'common_msgs':
            dict(target='all',
                 url='git://github.com/wg-debs/common_msgs.git',
                 packages={
                     'foo': 'subdir/foo',
                     'bar': 'subdir/bar'
                 }),
            'gazebo':
            dict(target=['lucid', 'natty'],
                 url='git://github.com/wg-debs/gazebo.git'),
            'foo-bar':
            dict(target=['precise'],
                 url='git://github.com/wg-debs/gazebo.git',
                 packages={'foo-bar': None}),
        },
        'type': 'gbp',
    }

    rosdep_data = gbprepo_to_rosdep_data(gbpdistro_data, targets)
    for k in ['foo', 'bar', 'gazebo', 'foo-bar']:
        assert k in rosdep_data, k

    # all targets and name transform
    # These are from the 'common_msgs' repo above.
    pkgs = ['foo', 'bar']
    v = 'ros-foorte-%s'
    for pkg in pkgs:
        for p in ['lucid', 'oneiric']:
            rule = rosdep_data[pkg]['ubuntu'][p]
            assert rule['apt']['packages'] == [v % pkg
                                               ], rule['apt']['packages']
        for p in ['maverick', 'natty']:
            assert p not in rosdep_data[k]['ubuntu']

    # target overrides
    pkg = 'gazebo'
    v = 'ros-foorte-gazebo'
    for p in ['lucid', 'natty']:
        rule = rosdep_data[pkg]['ubuntu'][p]
        assert rule['apt']['packages'] == [v], rule['apt']['packages']
    for p in ['oneiric', 'precise']:
        assert p not in rosdep_data[pkg]['ubuntu']

    # target overrides
    # These are from the 'foo-bar' repo above.
    v = 'ros-foorte-foo-bar'
    for pkg in ['foo-bar']:
        for p in ['precise']:
            rule = rosdep_data[pkg]['ubuntu'][p]
            assert rule['apt']['packages'] == [v], rule['apt']['packages']
        for p in ['oneiric', 'natty', 'lucid']:
            assert p not in rosdep_data[pkg]['ubuntu']
def test_gbprepo_to_rosdep_data_on_bad_inputs():
    from rosdep2.gbpdistro_support import gbprepo_to_rosdep_data
    from rosdep2 import InvalidData
    simple_gbpdistro = {'release-name': 'foorte',
                        'repositories': {},
                        'type': 'gbp'}
    targets = {'foorte': ['lucid', 'oneiric']}
    # test bad data
    try:
        gbprepo_to_rosdep_data(simple_gbpdistro, [targets])
        assert False, 'should have raised'
    except InvalidData:
        pass
    try:
        gbprepo_to_rosdep_data({
            'targets': 1,
            'repositories': [],
            'type': 'gbp'}, targets)
        assert False, 'should have raised'
    except InvalidData:
        pass
    try:
        gbprepo_to_rosdep_data([], targets)
        assert False, 'should have raised'
    except InvalidData:
        pass
    # release-name must be in targets
    try:
        gbprepo_to_rosdep_data({
            'release-name': 'barte',
            'repositories': [],
            'type': 'gbp'}, targets)
        assert False, 'should have raised'
    except InvalidData:
        pass
    # gbp-distros must be list of dicts
    try:
        gbprepo_to_rosdep_data({
            'release-name': 'foorte',
            'repositories': [1],
            'type': 'gbp'}, targets)
        assert False, 'should have raised'
    except InvalidData:
        pass
    # gbp-distro target must be 'all' or a list of strings
    try:
        bad_example = {'name': 'common',
                       'target': [1],
                       'url': 'git://github.com/wg-debs/common_msgs.git'}
        gbprepo_to_rosdep_data({
            'release-name': 'foorte',
            'repositories': [bad_example],
            'type': 'gbp'}, targets)
        assert False, 'should have raised'
    except InvalidData:
        pass
def test_gbprepo_to_rosdep_data():
    from rosdep2.gbpdistro_support import gbprepo_to_rosdep_data
    from rosdep2 import InvalidData
    simple_gbpdistro = {'release-name': 'foorte', 'gbp-repos': []}
    targets = {'foorte': ['lucid', 'oneiric']}
    # test bad data
    try:
        gbprepo_to_rosdep_data(simple_gbpdistro, [targets])
        assert False, "should have raised"
    except InvalidData:
        pass
    try:
        gbprepo_to_rosdep_data({'targets': 1, 'gbp-repos': []}, targets)
        assert False, "should have raised"
    except InvalidData:
        pass
    try:
        gbprepo_to_rosdep_data([], targets)
        assert False, "should have raised"
    except InvalidData:
        pass
    # release-name must be in targets
    try:
        gbprepo_to_rosdep_data({'release-name': 'barte', 'gbp-repos': []}, targets)
        assert False, "should have raised"
    except InvalidData:
        pass
    # gbp-distros must be list of dicts
    try:
        gbprepo_to_rosdep_data({'release-name': 'foorte', 'gbp-repos': [1]}, targets)
        assert False, "should have raised"
    except InvalidData:
        pass
    # gbp-distro target must be 'all' or a list of strings
    try:
        bad_example = {'name': 'common',
                       'target': [1],
                       'url': 'git://github.com/wg-debs/common_msgs.git'}
        gbprepo_to_rosdep_data({'release-name': 'foorte', 'gbp-repos': [bad_example]}, targets)
        assert False, "should have raised"
    except InvalidData:
        pass
    
    # make sure our sample files work for the above checks before proceeding to real data
    rosdep_data = gbprepo_to_rosdep_data(simple_gbpdistro, targets)
    assert rosdep_data is not None
    assert {} == rosdep_data

    gbpdistro_data = {'release-name': 'foorte',
                      'gbp-repos': [
                          dict(name='common_msgs', target='all', url='git://github.com/wg-debs/common_msgs.git'),
                          dict(name='gazebo', target=['lucid', 'natty'], url='git://github.com/wg-debs/gazebo.git'),
                          dict(name='foo-bar', target=['precise'], url='git://github.com/wg-debs/gazebo.git'),
                          ]
                      }
    
    rosdep_data = gbprepo_to_rosdep_data(gbpdistro_data, targets)
    for k in ['common_msgs', 'gazebo', 'foo-bar']:
        assert k in rosdep_data

    # all targets and name transform
    k = 'common_msgs'
    v = 'ros-foorte-common-msgs'
    for p in ['lucid', 'oneiric']:
        rule = rosdep_data[k]['ubuntu'][p]
        assert rule['apt']['packages'] == [v], rule['apt']['packages']
    for p in ['maverick', 'natty']:
        assert p not in rosdep_data[k]['ubuntu']
    
    # target overrides
    k = 'gazebo'
    v = 'ros-foorte-gazebo'
    for p in ['lucid', 'natty']:
        rule = rosdep_data[k]['ubuntu'][p]
        assert rule['apt']['packages'] == [v], rule['apt']['packages']
    for p in ['oneiric', 'precise']:
        assert p not in rosdep_data[k]['ubuntu']
    
    # target overrides
    k = 'foo-bar'
    v = 'ros-foorte-foo-bar'
    for p in ['precise']:
        rule = rosdep_data[k]['ubuntu'][p]
        assert rule['apt']['packages'] == [v], rule['apt']['packages']
    for p in ['oneiric', 'natty', 'lucid']:
        assert p not in rosdep_data[k]['ubuntu']
def test_gbprepo_to_rosdep_data_on_ok_input():
    from rosdep2.gbpdistro_support import gbprepo_to_rosdep_data
    simple_gbpdistro = {'release-name': 'foorte',
                        'repositories': {},
                        'type': 'gbp'}
    targets = {'foorte': ['lucid', 'oneiric']}
    # make sure our sample files work for the above checks before
    # proceeding to real data
    rosdep_data = gbprepo_to_rosdep_data(simple_gbpdistro, targets)
    assert rosdep_data is not None
    assert {} == rosdep_data

    gbpdistro_data = {
        'release-name': 'foorte',
        'repositories': {
            'common_msgs': dict(
                target='all',
                url='git://github.com/wg-debs/common_msgs.git',
                packages={'foo': 'subdir/foo', 'bar': 'subdir/bar'}),
            'gazebo': dict(
                target=['lucid', 'natty'],
                url='git://github.com/wg-debs/gazebo.git'),
            'foo-bar': dict(
                target=['precise'],
                url='git://github.com/wg-debs/gazebo.git',
                packages={'foo-bar': None}),
        },
        'type': 'gbp',
    }

    rosdep_data = gbprepo_to_rosdep_data(gbpdistro_data, targets)
    for k in ['foo', 'bar', 'gazebo', 'foo-bar']:
        assert k in rosdep_data, k

    # all targets and name transform
    # These are from the 'common_msgs' repo above.
    pkgs = ['foo', 'bar']
    v = 'ros-foorte-%s'
    for pkg in pkgs:
        for p in ['lucid', 'oneiric']:
            rule = rosdep_data[pkg]['ubuntu'][p]
            assert rule['apt']['packages'] == [v % pkg], rule['apt']['packages']
        for p in ['maverick', 'natty']:
            assert p not in rosdep_data[k]['ubuntu']

    # target overrides
    pkg = 'gazebo'
    v = 'ros-foorte-gazebo'
    for p in ['lucid', 'natty']:
        rule = rosdep_data[pkg]['ubuntu'][p]
        assert rule['apt']['packages'] == [v], rule['apt']['packages']
    for p in ['oneiric', 'precise']:
        assert p not in rosdep_data[pkg]['ubuntu']

    # target overrides
    # These are from the 'foo-bar' repo above.
    v = 'ros-foorte-foo-bar'
    for pkg in ['foo-bar']:
        for p in ['precise']:
            rule = rosdep_data[pkg]['ubuntu'][p]
            assert rule['apt']['packages'] == [v], rule['apt']['packages']
        for p in ['oneiric', 'natty', 'lucid']:
            assert p not in rosdep_data[pkg]['ubuntu']