Skip to content

Commit

Permalink
Added tests for ExternalsDescriptionDict
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Goldhaber committed May 19, 2020
1 parent afab352 commit 418173f
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ components/

# generated python files
*.pyc

# test tmp file
test/tmp
76 changes: 76 additions & 0 deletions test/test_unit_externals_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,39 @@ def setup_config(self):
# NOTE(goldy, 2019-03) Should test other possible keywords such as
# fetchRecurseSubmodules, ignore, and shallow

def setup_dict_config(self):
"""Create the full container dictionary with simple and mixed use
externals
"""
rdatat = {ExternalsDescription.PROTOCOL: 'git',
ExternalsDescription.REPO_URL: 'simple-ext.git',
ExternalsDescription.TAG: 'tag1'}
rdatab = {ExternalsDescription.PROTOCOL: 'git',
ExternalsDescription.REPO_URL: 'simple-ext.git',
ExternalsDescription.BRANCH: 'feature2'}
rdatam = {ExternalsDescription.PROTOCOL: 'git',
ExternalsDescription.REPO_URL: 'mixed-cont-ext.git',
ExternalsDescription.BRANCH: 'master'}
desc = {'simp_tag': {ExternalsDescription.REQUIRED: True,
ExternalsDescription.PATH: 'simp_tag',
ExternalsDescription.EXTERNALS: EMPTY_STR,
ExternalsDescription.REPO: rdatat},
'simp_branch' : {ExternalsDescription.REQUIRED: True,
ExternalsDescription.PATH: 'simp_branch',
ExternalsDescription.EXTERNALS: EMPTY_STR,
ExternalsDescription.REPO: rdatab},
'simp_opt': {ExternalsDescription.REQUIRED: False,
ExternalsDescription.PATH: 'simp_opt',
ExternalsDescription.EXTERNALS: EMPTY_STR,
ExternalsDescription.REPO: rdatat},
'mixed_req': {ExternalsDescription.REQUIRED: True,
ExternalsDescription.PATH: 'mixed_req',
ExternalsDescription.EXTERNALS: 'sub-ext.cfg',
ExternalsDescription.REPO: rdatam}}

return desc

def test_cfg_v1_ok(self):
"""Test that a correct cfg v1 object is created by create_externals_description
Expand Down Expand Up @@ -379,6 +412,49 @@ def test_dict(self):
ext = create_externals_description(desc, model_format='dict')
self.assertIsInstance(ext, ExternalsDescriptionDict)

def test_container_component_dict(self):
"""Verify that create_externals_description works with a dictionary
"""
# create the top level externals file
desc = self.setup_dict_config()
# Check external with all repos
external = create_externals_description(desc, model_format='dict')
self.assertIsInstance(external, ExternalsDescriptionDict)
self.assertTrue('simp_tag' in external)
self.assertTrue('simp_branch' in external)
self.assertTrue('simp_opt' in external)
self.assertTrue('mixed_req' in external)

def test_container_exclude_component_dict(self):
"""Verify that exclude component checkout works with a dictionary
"""
# create the top level externals file
desc = self.setup_dict_config()
# Test an excluded repo
external = create_externals_description(desc, model_format='dict',
exclude=['simp_tag',
'simp_opt'])
self.assertIsInstance(external, ExternalsDescriptionDict)
self.assertFalse('simp_tag' in external)
self.assertTrue('simp_branch' in external)
self.assertFalse('simp_opt' in external)
self.assertTrue('mixed_req' in external)

def test_container_opt_component_dict(self):
"""Verify that exclude component checkout works with a dictionary
"""
# create the top level externals file
desc = self.setup_dict_config()
# Test an excluded repo
external = create_externals_description(desc, model_format='dict',
components=['simp_tag',
'simp_opt'])
self.assertIsInstance(external, ExternalsDescriptionDict)
self.assertTrue('simp_tag' in external)
self.assertFalse('simp_branch' in external)
self.assertTrue('simp_opt' in external)
self.assertFalse('mixed_req' in external)

def test_cfg_unknown_version(self):
"""Test that a runtime error is raised when an unknown file version is
received
Expand Down

0 comments on commit 418173f

Please sign in to comment.