Skip to content

Commit

Permalink
tests: Add manifest test for submodules
Browse files Browse the repository at this point in the history
Add a testcase to parse a manifest and validate the as_dict output.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
  • Loading branch information
pdgendt committed Sep 23, 2024
1 parent 7308890 commit 965e3a2
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions tests/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3176,6 +3176,68 @@ def setup_project(name, group_filter):
assert hasattr(m, '_legacy_group_filter_warned')


def test_submodule_manifest():
m = M('''\
projects:
- name: project1
url: url
- name: project2
url: url
submodules: true
- name: project3
url: url
submodules:
- path: path
- name: project4
url: url
submodules:
- path: path
name: subproject1
- name: project5
url: url
submodules:
- path: path
name: subproject1
- path: path
name: subproject2
''').as_dict()['manifest']

mp = m['projects'][0]
assert 'submodules' not in mp

mp = m['projects'][1]
assert 'submodules' in mp
assert isinstance(mp['submodules'], bool)
assert mp['submodules']

mp = m['projects'][2]
assert isinstance(mp['submodules'], list)
assert len(mp['submodules']) == 1
assert 'path' in mp['submodules'][0]
assert mp['submodules'][0]['path'] == 'path'
assert 'name' not in mp['submodules'][0]

mp = m['projects'][3]
assert isinstance(mp['submodules'], list)
assert len(mp['submodules']) == 1
assert 'path' in mp['submodules'][0]
assert mp['submodules'][0]['path'] == 'path'
assert 'name' in mp['submodules'][0]
assert mp['submodules'][0]['name'] == 'subproject1'

mp = m['projects'][4]
assert isinstance(mp['submodules'], list)
assert len(mp['submodules']) == 2
assert 'path' in mp['submodules'][0]
assert mp['submodules'][0]['path'] == 'path'
assert 'name' in mp['submodules'][0]
assert mp['submodules'][0]['name'] == 'subproject1'
assert 'path' in mp['submodules'][1]
assert mp['submodules'][1]['path'] == 'path'
assert 'name' in mp['submodules'][1]
assert mp['submodules'][1]['name'] == 'subproject2'


#########################################
# Various invalid manifests

Expand Down

0 comments on commit 965e3a2

Please sign in to comment.