File: test_source.py

package info (click to toggle)
ros-rosdistro 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 724 kB
  • sloc: python: 4,125; makefile: 38; xml: 22
file content (40 lines) | stat: -rw-r--r-- 1,189 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os

from rosdistro import get_index, get_source_file
from rosdistro.loader import load_url
from rosdistro.source_file import SourceFile

import yaml

from . import path_to_url

FILES_DIR = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files'))


def test_source_file():
    url = path_to_url(os.path.join(FILES_DIR, 'foo', 'distribution.yaml'))
    yaml_str = load_url(url)
    data = yaml.safe_load(yaml_str)
    src_file = SourceFile('foo', data)
    _validate_src_file(src_file)


def test_get_source_file():
    url = path_to_url(os.path.join(FILES_DIR, 'index_v2.yaml'))
    i = get_index(url)
    src_file = get_source_file(i, 'foo')
    _validate_src_file(src_file)


def _validate_src_file(src_file):
    assert(set(['bar_repo', 'baz-repo']) == set(src_file.repositories.keys()))

    repo = src_file.repositories['bar_repo']
    assert(repo.type == 'git')
    assert(repo.url == 'https://github.com/example-test/bar_repo.git')
    assert(repo.version == 'master')

    repo = src_file.repositories['baz-repo']
    assert(repo.type == 'hg')
    assert(repo.url == 'https://bitbucket.org/baz-test/baz-repo')
    assert(repo.version == 'default')