def test_CachedDataSource(): from rosdep2.sources_list import CachedDataSource, DataSource, TYPE_GBPDISTRO, TYPE_YAML type_ = TYPE_GBPDISTRO url = 'http://fake.willowgarage.com/foo' tags = ['tag1'] rosdep_data = {'key': {}} origin = '/tmp/bar' cds = CachedDataSource(type_, url, tags, rosdep_data, origin=origin) assert cds == CachedDataSource(type_, url, tags, rosdep_data, origin=origin) assert cds != CachedDataSource(type_, url, tags, rosdep_data, origin=None) assert cds != CachedDataSource(type_, url, tags, {}, origin=origin) assert cds != CachedDataSource( TYPE_YAML, url, tags, rosdep_data, origin=origin) assert cds != CachedDataSource( type_, 'http://ros.org/foo.yaml', tags, rosdep_data, origin=origin) assert cds != DataSource(type_, url, tags, origin=origin) assert DataSource(type_, url, tags, origin=origin) != cds assert cds.type == type_ assert cds.url == url assert cds.origin == origin assert cds.rosdep_data == rosdep_data assert type_ in str(cds) assert type_ in repr(cds) assert url in str(cds) assert url in repr(cds) assert tags[0] in str(cds) assert tags[0] in repr(cds) assert 'key' in str(cds) assert 'key' in repr(cds)
def test_DataSource(): from rosdep2.sources_list import DataSource data_source = DataSource('yaml', 'http://fake/url', ['tag1', 'tag2']) assert data_source == rosdep2.sources_list.DataSource( 'yaml', 'http://fake/url', ['tag1', 'tag2']) assert 'yaml' == data_source.type assert 'http://fake/url' == data_source.url assert ['tag1', 'tag2'] == data_source.tags assert 'yaml http://fake/url tag1 tag2' == str(data_source) data_source_foo = DataSource('yaml', 'http://fake/url', ['tag1', 'tag2'], origin='foo') assert data_source_foo != data_source assert data_source_foo.origin == 'foo' assert '[foo]:\nyaml http://fake/url tag1 tag2' == str( data_source_foo), str(data_source_foo) assert repr(data_source) try: rosdep2.sources_list.DataSource('yaml', 'http://fake/url', 'tag1', origin='foo') assert False, "should have raised" except ValueError: pass try: rosdep2.sources_list.DataSource('yaml', 'non url', ['tag1'], origin='foo') assert False, "should have raised" except ValueError: pass try: rosdep2.sources_list.DataSource('bad', 'http://fake/url', ['tag1'], origin='foo') assert False, "should have raised" except ValueError: pass try: rosdep2.sources_list.DataSource('yaml', 'http://host.no.path/', ['tag1'], origin='foo') assert False, "should have raised" except ValueError: pass