1import os 2 3from rosdistro import get_index, get_source_file 4from rosdistro.loader import load_url 5from rosdistro.source_file import SourceFile 6 7import yaml 8 9FILES_DIR = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files')) 10 11 12def test_source_file(): 13 url = 'file://' + FILES_DIR + '/foo/distribution.yaml' 14 yaml_str = load_url(url) 15 data = yaml.load(yaml_str) 16 src_file = SourceFile('foo', data) 17 _validate_src_file(src_file) 18 19 20def test_get_source_file(): 21 url = 'file://' + FILES_DIR + '/index_v2.yaml' 22 i = get_index(url) 23 src_file = get_source_file(i, 'foo') 24 _validate_src_file(src_file) 25 26 27def _validate_src_file(src_file): 28 assert(set(['bar_repo', 'baz-repo']) == set(src_file.repositories.keys())) 29 30 repo = src_file.repositories['bar_repo'] 31 assert(repo.type == 'git') 32 assert(repo.url == 'https://github.com/example-test/bar_repo.git') 33 assert(repo.version == 'master') 34 35 repo = src_file.repositories['baz-repo'] 36 assert(repo.type == 'hg') 37 assert(repo.url == 'https://bitbucket.org/baz-test/baz-repo') 38 assert(repo.version == 'default') 39