From dcb6241ad2214140d1aac2ff8533d5bf6f1af592 Mon Sep 17 00:00:00 2001 From: Benjamin Andre Date: Tue, 14 Nov 2017 17:49:00 -0700 Subject: [PATCH] Rename model description to externals description. Testing: unit tests - pass cesm - manual testing of checkout and status - ok. clm - manual testing of checkout and status - ok. --- checkout_externals.py | 22 ++++---- manic/__init__.py | 6 +-- ...escription.py => externals_description.py} | 54 +++++++++---------- manic/externalstatus.py | 4 +- manic/repository.py | 12 ++--- manic/repository_factory.py | 4 +- manic/repository_svn.py | 2 +- manic/sourcetree.py | 26 ++++----- ....py => test_unit_externals_description.py} | 46 ++++++++-------- test/test_unit_repository.py | 52 +++++++++--------- test/test_unit_repository_git.py | 48 ++++++++--------- test/test_unit_repository_svn.py | 48 ++++++++--------- 12 files changed, 162 insertions(+), 162 deletions(-) rename manic/{model_description.py => externals_description.py} (87%) rename test/{test_unit_model_description.py => test_unit_externals_description.py} (79%) diff --git a/checkout_externals.py b/checkout_externals.py index 543fd0a..5df76d1 100755 --- a/checkout_externals.py +++ b/checkout_externals.py @@ -27,7 +27,7 @@ print(70 * '*') sys.exit(1) -from manic import read_model_description_file, create_model_description +from manic import read_externals_description_file, create_externals_description from manic import SourceTree from manic import check_safe_to_update_repos from manic import printlog, PPRINTER @@ -43,13 +43,13 @@ def commandline_arguments(): """ description = ''' %(prog)s manages checking out CESM externals from revision control -based on a model description file. By default only the required +based on a externals description file. By default only the required components of the model are checkout out. NOTE: %(prog)s *MUST* be run from the root of the source tree. Running %(prog)s without the '--status' option will always attempt to -synchronize the working copy with the model description. +synchronize the working copy with the externals description. ''' epilog = ''' @@ -76,7 +76,7 @@ def commandline_arguments(): $ ./checkout_cesm/%(prog)s * To update all required components to the current values in the - model description file, re-run %(prog)s: + externals description file, re-run %(prog)s: $ cd ${SRC_ROOT} $ ./checkout_cesm/%(prog)s @@ -107,12 +107,12 @@ def commandline_arguments(): where: * column one indicates the status of the repository in relation - to the model description file. + to the externals description file. * column two indicates whether the working copy has modified files. * column three shows how the repository is managed, optional or required Colunm one will be one of these values: - * m : modified : repository is modefied compared to the model description + * m : modified : repository is modefied compared to the externals description * e : empty : directory does not exist - %(prog)s has not been run * ? : unknown : directory exists but .git or .svn directories are missing @@ -132,7 +132,7 @@ def commandline_arguments(): # Model description file: - The model description contains a list of the model components that + The externals description contains a list of the model components that are used and their version control locations. Each component has: * name (string) : component name, e.g. cime, cism, clm, cam, etc. @@ -162,7 +162,7 @@ def commandline_arguments(): * externals (string) : relative path to the external model description file that should also be used. It is *relative* to the - component local_path. For example, the CESM model description will + component local_path. For example, the CESM externals description will load clm. CLM has additional externals that must be downloaded to be complete. Those additional externals are managed from the clm source root by the file pointed to by 'externals'. @@ -177,7 +177,7 @@ def commandline_arguments(): # user options # parser.add_argument('-m', '--model', nargs='?', default='CESM.cfg', - help='The model description filename. ' + help='The externals description filename. ' 'Default: %(default)s.') parser.add_argument('-o', '--optional', action='store_true', default=False, @@ -232,8 +232,8 @@ def _main(args): load_all = True root_dir = os.path.abspath('.') - model_data = read_model_description_file(root_dir, args.model) - model = create_model_description(model_data) + model_data = read_externals_description_file(root_dir, args.model) + model = create_externals_description(model_data) if args.debug: PPRINTER.pprint(model) diff --git a/manic/__init__.py b/manic/__init__.py index 5e8e92e..c273ede 100644 --- a/manic/__init__.py +++ b/manic/__init__.py @@ -3,13 +3,13 @@ from manic.utils import printlog, log_process_output, fatal_error from manic.globals import PPRINTER -from manic.model_description import read_model_description_file -from manic.model_description import create_model_description +from manic.externals_description import read_externals_description_file +from manic.externals_description import create_externals_description from manic.sourcetree import SourceTree from manic.externalstatus import check_safe_to_update_repos __all__ = ['PPRINTER', 'printlog', 'log_process_output', 'fatal_error', - 'read_model_description_file', 'create_model_description', + 'read_externals_description_file', 'create_externals_description', 'SourceTree', ] diff --git a/manic/model_description.py b/manic/externals_description.py similarity index 87% rename from manic/model_description.py rename to manic/externals_description.py index bc97f44..39b8dd9 100644 --- a/manic/model_description.py +++ b/manic/externals_description.py @@ -7,7 +7,7 @@ converts it into a standard interface that is used by the rest of the system. -To maintain backward compatibility, model description files should +To maintain backward compatibility, externals description files should follow semantic versioning rules, http://semver.org/ @@ -49,15 +49,15 @@ def config_string_cleaner(text): VERSION_ITEM = 'version' -def read_model_description_file(root_dir, file_name): - """Given a file name containing a model description, determine the +def read_externals_description_file(root_dir, file_name): + """Given a file name containing a externals description, determine the format and read it into it's internal representation. """ root_dir = os.path.abspath(root_dir) msg = 'In directory : {0}'.format(root_dir) logging.info(msg) - printlog('Processing model description file : {0}'.format(file_name)) + printlog('Processing externals description file : {0}'.format(file_name)) file_path = os.path.join(root_dir, file_name) if not os.path.exists(file_name): @@ -65,32 +65,32 @@ def read_model_description_file(root_dir, file_name): 'exist at {1}'.format(file_name, file_path)) fatal_error(msg) - model_description = None + externals_description = None try: config = config_parser() config.read(file_path) - model_description = config + externals_description = config except ConfigParser.MissingSectionHeaderError: # not a cfg file pass - if model_description is None: + if externals_description is None: msg = 'Unknown file format!' fatal_error(msg) - return model_description + return externals_description -def create_model_description(model_data, model_format='cfg'): - """Create the a model description object from the provided data +def create_externals_description(model_data, model_format='cfg'): + """Create the a externals description object from the provided data """ - model_description = None + externals_description = None if model_format == 'dict': - model_description = ModelDescriptionDict(model_data, ) + externals_description = ExternalsDescriptionDict(model_data, ) elif model_format == 'cfg': major, _, _ = get_cfg_schema_version(model_data) if major == 1: - model_description = ModelDescriptionConfigV1(model_data) + externals_description = ExternalsDescriptionConfigV1(model_data) else: msg = ('Externals description file has unsupported schema ' 'version "{0}".'.format(major)) @@ -98,7 +98,7 @@ def create_model_description(model_data, model_format='cfg'): else: msg = 'Unknown model data format "{0}"'.format(model_format) fatal_error(msg) - return model_description + return externals_description def get_cfg_schema_version(model_cfg): @@ -132,14 +132,14 @@ def get_cfg_schema_version(model_cfg): return major, minor, patch -class ModelDescription(dict): - """Base model description class that is independent of the user input +class ExternalsDescription(dict): + """Base externals description class that is independent of the user input format. Different input formats can all be converted to this representation to provide a consistent represtentation for the rest of the objects in the system. """ - # keywords defining the interface into the model description data + # keywords defining the interface into the externals description data EXTERNALS = 'externals' BRANCH = 'branch' REPO = 'repo' @@ -222,7 +222,7 @@ def _check_data(self): def _check_optional(self): """Some fields like externals, repo:tag repo:branch are (conditionally) optional. We don't want the user to be - required to enter them in every model description file, but + required to enter them in every externals description file, but still want to validate the input. Check conditions and add default values if appropriate. @@ -241,7 +241,7 @@ def _check_optional(self): self[field][self.REPO][self.REPO_URL] = EMPTY_STR def _validate(self): - """Validate that the parsed model description contains all necessary + """Validate that the parsed externals description contains all necessary fields. """ @@ -285,22 +285,22 @@ def validate_data_struct(schema, data): fatal_error(msg) -class ModelDescriptionDict(ModelDescription): - """Create a model description object from a dictionary using the API +class ExternalsDescriptionDict(ExternalsDescription): + """Create a externals description object from a dictionary using the API representations. Primarily used to simplify creating model description files for unit testing. """ def __init__(self, model_data): - """Parse a native dictionary into a model description. + """Parse a native dictionary into a externals description. """ - ModelDescription.__init__(self) + ExternalsDescription.__init__(self) self.update(model_data) self._check_user_input() -class ModelDescriptionConfigV1(ModelDescription): - """Create a model description object from a config_parser object, +class ExternalsDescriptionConfigV1(ExternalsDescription): + """Create a externals description object from a config_parser object, schema version 1. """ @@ -309,7 +309,7 @@ def __init__(self, model_data): construct the source objects """ - ModelDescription.__init__(self) + ExternalsDescription.__init__(self) self._remove_metadata(model_data) self._parse_cfg(model_data) self._check_user_input() @@ -324,7 +324,7 @@ def _remove_metadata(model_data): model_data.remove_section(DESCRIPTION_SECTION) def _parse_cfg(self, cfg_data): - """Parse a config_parser object into a model description. + """Parse a config_parser object into a externals description. """ def list_to_dict(input_list, convert_to_lower_case=True): """Convert a list of key-value pairs into a dictionary. diff --git a/manic/externalstatus.py b/manic/externalstatus.py index 941ff23..d004b03 100644 --- a/manic/externalstatus.py +++ b/manic/externalstatus.py @@ -12,7 +12,7 @@ class ExternalStatus(object): There are two states of concern: - * If the repository is in-sync with the model description file. + * If the repository is in-sync with the externals description file. * If the repostiory working copy is clean and there are no pending transactions (e.g. add, remove, rename, untracked files). @@ -105,7 +105,7 @@ def check_safe_to_update_repos(tree_status, debug): the model in an inconsistent state. Note: if there is an update to do, the repositories will by - definiation be out of synce with the model description, so we + definiation be out of synce with the externals description, so we can't use that as criteria for updating. """ diff --git a/manic/repository.py b/manic/repository.py index 29f6b55..558db1e 100644 --- a/manic/repository.py +++ b/manic/repository.py @@ -1,7 +1,7 @@ """Base class representation of a repository """ -from .model_description import ModelDescription +from .externals_description import ExternalsDescription from .utils import fatal_error from .globals import EMPTY_STR @@ -13,13 +13,13 @@ class Repository(object): def __init__(self, component_name, repo): """ - Parse repo model description + Parse repo externals description """ self._name = component_name - self._protocol = repo[ModelDescription.PROTOCOL] - self._tag = repo[ModelDescription.TAG] - self._branch = repo[ModelDescription.BRANCH] - self._url = repo[ModelDescription.REPO_URL] + self._protocol = repo[ExternalsDescription.PROTOCOL] + self._tag = repo[ExternalsDescription.TAG] + self._branch = repo[ExternalsDescription.BRANCH] + self._url = repo[ExternalsDescription.REPO_URL] if self._url is EMPTY_STR: fatal_error('repo must have a URL') diff --git a/manic/repository_factory.py b/manic/repository_factory.py index fb2cc9c..992ade7 100644 --- a/manic/repository_factory.py +++ b/manic/repository_factory.py @@ -1,6 +1,6 @@ from .repository_git import GitRepository from .repository_svn import SvnRepository -from .model_description import ModelDescription +from .externals_description import ExternalsDescription from .utils import fatal_error @@ -9,7 +9,7 @@ def create_repository(component_name, repo_info): create the appropriate object. """ - protocol = repo_info[ModelDescription.PROTOCOL].lower() + protocol = repo_info[ExternalsDescription.PROTOCOL].lower() if protocol == 'git': repo = GitRepository(component_name, repo_info) elif protocol == 'svn': diff --git a/manic/repository_svn.py b/manic/repository_svn.py index 8e2ef00..5b8d657 100644 --- a/manic/repository_svn.py +++ b/manic/repository_svn.py @@ -49,7 +49,7 @@ def checkout(self, base_dir_path, repo_dir_name): """Checkout or update the working copy If the repo destination directory exists, switch the sandbox to - match the model description. + match the externals description. If the repo destination directory does not exist, checkout the correct branch or tag. diff --git a/manic/sourcetree.py b/manic/sourcetree.py index f2f382f..6c716b0 100644 --- a/manic/sourcetree.py +++ b/manic/sourcetree.py @@ -8,9 +8,9 @@ import os from .globals import EMPTY_STR -from .model_description import ModelDescription -from .model_description import read_model_description_file -from .model_description import create_model_description +from .externals_description import ExternalsDescription +from .externals_description import read_externals_description_file +from .externals_description import create_externals_description from .repository_factory import create_repository from .externalstatus import ExternalStatus from .utils import fatal_error, printlog @@ -32,7 +32,7 @@ def __init__(self, root_dir, name, source): name : string - name of the source object. may or may not correspond to something in the path. - source : dict - source ModelDescription object + source : dict - source ExternalsDescription object """ self._name = name @@ -42,7 +42,7 @@ def __init__(self, root_dir, name, source): # Parse the sub-elements # _path : local path relative to the containing source tree - self._local_path = source[ModelDescription.PATH] + self._local_path = source[ExternalsDescription.PATH] # _repo_dir : full repository directory repo_dir = os.path.join(root_dir, self._local_path) self._repo_dir_path = os.path.abspath(repo_dir) @@ -53,11 +53,11 @@ def __init__(self, root_dir, name, source): assert(os.path.join(self._base_dir_path, self._repo_dir_name) == self._repo_dir_path) - self._required = source[ModelDescription.REQUIRED] - self._externals = source[ModelDescription.EXTERNALS] + self._required = source[ExternalsDescription.REQUIRED] + self._externals = source[ExternalsDescription.EXTERNALS] if self._externals: self._create_externals_sourcetree() - repo = create_repository(name, source[ModelDescription.REPO]) + repo = create_repository(name, source[ExternalsDescription.REPO]) if repo: self._repo = repo @@ -188,16 +188,16 @@ def _create_externals_sourcetree(self): os.chdir(self._repo_dir_path) if not os.path.exists(self._externals): # NOTE(bja, 2017-10) this check is redundent with the one - # in read_model_description_file! - msg = ('External model description file "{0}" ' + # in read_externals_description_file! + msg = ('External externals description file "{0}" ' 'does not exist! In directory: {1}'.format( self._externals, self._repo_dir_path)) fatal_error(msg) externals_root = self._repo_dir_path - model_data = read_model_description_file(externals_root, + model_data = read_externals_description_file(externals_root, self._externals) - externals = create_model_description(model_data) + externals = create_externals_description(model_data) self._externals_sourcetree = SourceTree(externals_root, externals) os.chdir(cwd) @@ -217,7 +217,7 @@ def __init__(self, root_dir, model): for comp in model: src = _Source(self._root_dir, comp, model[comp]) self._all_components[comp] = src - if model[comp][ModelDescription.REQUIRED]: + if model[comp][ExternalsDescription.REQUIRED]: self._required_compnames.append(comp) def status(self, relative_path_base='.'): diff --git a/test/test_unit_model_description.py b/test/test_unit_externals_description.py similarity index 79% rename from test/test_unit_model_description.py rename to test/test_unit_externals_description.py index 36c191d..263d7ab 100644 --- a/test/test_unit_model_description.py +++ b/test/test_unit_externals_description.py @@ -28,10 +28,10 @@ def config_string_cleaner(text): def config_string_cleaner(text): return text -from manic.model_description import DESCRIPTION_SECTION, VERSION_ITEM -from manic.model_description import ModelDescription -from manic.model_description import ModelDescriptionConfigV1 -from manic.model_description import get_cfg_schema_version +from manic.externals_description import DESCRIPTION_SECTION, VERSION_ITEM +from manic.externals_description import ExternalsDescription +from manic.externals_description import ExternalsDescriptionConfigV1 +from manic.externals_description import get_cfg_schema_version from manic.globals import EMPTY_STR @@ -76,7 +76,7 @@ def test_schema_section_missing(self): get_cfg_schema_version(self._config) def test_schema_version_missing(self): - """Test that a model description file without a version raises a + """Test that a externals description file without a version raises a runtime error. """ @@ -89,7 +89,7 @@ def test_schema_version_missing(self): class TestModelDescritionConfigV1(unittest.TestCase): """Test that parsing config/ini fileproduces a correct dictionary - for the model description. + for the externals description. """ @@ -140,36 +140,36 @@ def _check_comp1(self, model): """ self.assertTrue(self._comp1_name in model) comp1 = model[self._comp1_name] - self.assertEqual(comp1[ModelDescription.PATH], self._comp1_path) - self.assertTrue(comp1[ModelDescription.REQUIRED]) - repo = comp1[ModelDescription.REPO] - self.assertEqual(repo[ModelDescription.PROTOCOL], + self.assertEqual(comp1[ExternalsDescription.PATH], self._comp1_path) + self.assertTrue(comp1[ExternalsDescription.REQUIRED]) + repo = comp1[ExternalsDescription.REPO] + self.assertEqual(repo[ExternalsDescription.PROTOCOL], self._comp1_protocol) - self.assertEqual(repo[ModelDescription.REPO_URL], self._comp1_url) - self.assertEqual(repo[ModelDescription.TAG], self._comp1_tag) - self.assertEqual(EMPTY_STR, comp1[ModelDescription.EXTERNALS]) + self.assertEqual(repo[ExternalsDescription.REPO_URL], self._comp1_url) + self.assertEqual(repo[ExternalsDescription.TAG], self._comp1_tag) + self.assertEqual(EMPTY_STR, comp1[ExternalsDescription.EXTERNALS]) def _check_comp2(self, model): """Test that component two was constucted correctly. """ self.assertTrue(self._comp2_name in model) comp2 = model[self._comp2_name] - self.assertEqual(comp2[ModelDescription.PATH], self._comp2_path) - self.assertFalse(comp2[ModelDescription.REQUIRED]) - repo = comp2[ModelDescription.REPO] - self.assertEqual(repo[ModelDescription.PROTOCOL], + self.assertEqual(comp2[ExternalsDescription.PATH], self._comp2_path) + self.assertFalse(comp2[ExternalsDescription.REQUIRED]) + repo = comp2[ExternalsDescription.REPO] + self.assertEqual(repo[ExternalsDescription.PROTOCOL], self._comp2_protocol) - self.assertEqual(repo[ModelDescription.REPO_URL], self._comp2_url) - self.assertEqual(repo[ModelDescription.BRANCH], self._comp2_branch) + self.assertEqual(repo[ExternalsDescription.REPO_URL], self._comp2_url) + self.assertEqual(repo[ExternalsDescription.BRANCH], self._comp2_branch) self.assertEqual(self._comp2_externals, - comp2[ModelDescription.EXTERNALS]) + comp2[ExternalsDescription.EXTERNALS]) def test_one_tag_required(self): """Test that a component source with a tag is correctly parsed. """ config = config_parser() self._setup_comp1(config) - model = ModelDescriptionConfigV1(config) + model = ExternalsDescriptionConfigV1(config) print(model) self._check_comp1(model) @@ -178,7 +178,7 @@ def test_one_branch_externals(self): """ config = config_parser() self._setup_comp2(config) - model = ModelDescriptionConfigV1(config) + model = ExternalsDescriptionConfigV1(config) print(model) self._check_comp2(model) @@ -188,7 +188,7 @@ def test_two_sources(self): config = config_parser() self._setup_comp1(config) self._setup_comp2(config) - model = ModelDescriptionConfigV1(config) + model = ExternalsDescriptionConfigV1(config) print(model) self._check_comp1(model) self._check_comp2(model) diff --git a/test/test_unit_repository.py b/test/test_unit_repository.py index 120a55f..dd734b9 100644 --- a/test/test_unit_repository.py +++ b/test/test_unit_repository.py @@ -17,7 +17,7 @@ from manic.repository_git import GitRepository from manic.repository_svn import SvnRepository from manic.repository import Repository -from manic.model_description import ModelDescription +from manic.externals_description import ExternalsDescription from manic.globals import EMPTY_STR @@ -32,10 +32,10 @@ def setUp(self): """Common data needed for all tests in this class """ self._name = 'test_name' - self._repo = {ModelDescription.PROTOCOL: None, - ModelDescription.REPO_URL: 'junk_root', - ModelDescription.TAG: 'junk_tag', - ModelDescription.BRANCH: EMPTY_STR, } + self._repo = {ExternalsDescription.PROTOCOL: None, + ExternalsDescription.REPO_URL: 'junk_root', + ExternalsDescription.TAG: 'junk_tag', + ExternalsDescription.BRANCH: EMPTY_STR, } def test_create_repo_git(self): """Verify that several possible names for the 'git' protocol @@ -44,7 +44,7 @@ def test_create_repo_git(self): """ protocols = ['git', 'GIT', 'Git', ] for protocol in protocols: - self._repo[ModelDescription.PROTOCOL] = protocol + self._repo[ExternalsDescription.PROTOCOL] = protocol repo = create_repository(self._name, self._repo) self.assertIsInstance(repo, GitRepository) @@ -54,7 +54,7 @@ def test_create_repo_svn(self): """ protocols = ['svn', 'SVN', 'Svn', ] for protocol in protocols: - self._repo[ModelDescription.PROTOCOL] = protocol + self._repo[ExternalsDescription.PROTOCOL] = protocol repo = create_repository(self._name, self._repo) self.assertIsInstance(repo, SvnRepository) @@ -63,7 +63,7 @@ def test_create_repo_externals_only(self): """ protocols = ['externals_only', ] for protocol in protocols: - self._repo[ModelDescription.PROTOCOL] = protocol + self._repo[ExternalsDescription.PROTOCOL] = protocol repo = create_repository(self._name, self._repo) self.assertEqual(None, repo) @@ -72,13 +72,13 @@ def test_create_repo_unsupported(self): """ protocols = ['not_a_supported_protocol', ] for protocol in protocols: - self._repo[ModelDescription.PROTOCOL] = protocol + self._repo[ExternalsDescription.PROTOCOL] = protocol with self.assertRaises(RuntimeError): create_repository(self._name, self._repo) class TestRepository(unittest.TestCase): - """Test the model description processing used to create the Repository + """Test the externals description processing used to create the Repository base class shared by protocol specific repository classes. """ @@ -90,10 +90,10 @@ def test_tag(self): protocol = 'test_protocol' url = 'test_url' tag = 'test_tag' - repo_info = {ModelDescription.PROTOCOL: protocol, - ModelDescription.REPO_URL: url, - ModelDescription.TAG: tag, - ModelDescription.BRANCH: EMPTY_STR, } + repo_info = {ExternalsDescription.PROTOCOL: protocol, + ExternalsDescription.REPO_URL: url, + ExternalsDescription.TAG: tag, + ExternalsDescription.BRANCH: EMPTY_STR, } repo = Repository(name, repo_info) print(repo.__dict__) self.assertEqual(repo.tag(), tag) @@ -106,10 +106,10 @@ def test_branch(self): protocol = 'test_protocol' url = 'test_url' branch = 'test_branch' - repo_info = {ModelDescription.PROTOCOL: protocol, - ModelDescription.REPO_URL: url, - ModelDescription.BRANCH: branch, - ModelDescription.TAG: EMPTY_STR, } + repo_info = {ExternalsDescription.PROTOCOL: protocol, + ExternalsDescription.REPO_URL: url, + ExternalsDescription.BRANCH: branch, + ExternalsDescription.TAG: EMPTY_STR, } repo = Repository(name, repo_info) print(repo.__dict__) self.assertEqual(repo.branch(), branch) @@ -125,10 +125,10 @@ def test_tag_branch(self): url = 'test_url' branch = 'test_branch' tag = 'test_tag' - repo_info = {ModelDescription.PROTOCOL: protocol, - ModelDescription.REPO_URL: url, - ModelDescription.BRANCH: branch, - ModelDescription.TAG: tag, } + repo_info = {ExternalsDescription.PROTOCOL: protocol, + ExternalsDescription.REPO_URL: url, + ExternalsDescription.BRANCH: branch, + ExternalsDescription.TAG: tag, } with self.assertRaises(RuntimeError): Repository(name, repo_info) @@ -142,10 +142,10 @@ def test_no_tag_no_branch(self): url = 'test_url' branch = EMPTY_STR tag = EMPTY_STR - repo_info = {ModelDescription.PROTOCOL: protocol, - ModelDescription.REPO_URL: url, - ModelDescription.BRANCH: branch, - ModelDescription.TAG: tag, } + repo_info = {ExternalsDescription.PROTOCOL: protocol, + ExternalsDescription.REPO_URL: url, + ExternalsDescription.BRANCH: branch, + ExternalsDescription.TAG: tag, } with self.assertRaises(RuntimeError): Repository(name, repo_info) diff --git a/test/test_unit_repository_git.py b/test/test_unit_repository_git.py index 369d51f..e74c203 100644 --- a/test/test_unit_repository_git.py +++ b/test/test_unit_repository_git.py @@ -17,8 +17,8 @@ from manic.repository_git import GitRepository from manic.externalstatus import ExternalStatus -from manic.model_description import ModelDescription -from manic.model_description import ModelDescriptionDict +from manic.externals_description import ExternalsDescription +from manic.externals_description import ExternalsDescriptionDict from manic.globals import EMPTY_STR @@ -43,25 +43,25 @@ class TestGitRepositoryCurrentRefBranch(unittest.TestCase): def setUp(self): self._name = 'component' - rdata = {ModelDescription.PROTOCOL: 'git', - ModelDescription.REPO_URL: + rdata = {ExternalsDescription.PROTOCOL: 'git', + ExternalsDescription.REPO_URL: 'git@git.github.com:ncar/rtm', - ModelDescription.TAG: + ExternalsDescription.TAG: 'rtm1_0_26', - ModelDescription.BRANCH: EMPTY_STR + ExternalsDescription.BRANCH: EMPTY_STR } data = {self._name: { - ModelDescription.REQUIRED: False, - ModelDescription.PATH: 'junk', - ModelDescription.EXTERNALS: EMPTY_STR, - ModelDescription.REPO: rdata, + ExternalsDescription.REQUIRED: False, + ExternalsDescription.PATH: 'junk', + ExternalsDescription.EXTERNALS: EMPTY_STR, + ExternalsDescription.REPO: rdata, }, } - model = ModelDescriptionDict(data) - repo = model[self._name][ModelDescription.REPO] + model = ExternalsDescriptionDict(data) + repo = model[self._name][ExternalsDescription.REPO] self._repo = GitRepository('test', repo) def test_ref_detached_from_tag(self): @@ -116,25 +116,25 @@ def setUp(self): """Setup reusable git repository object """ self._name = 'component' - rdata = {ModelDescription.PROTOCOL: 'git', - ModelDescription.REPO_URL: + rdata = {ExternalsDescription.PROTOCOL: 'git', + ExternalsDescription.REPO_URL: 'git@git.github.com:ncar/rtm', - ModelDescription.TAG: + ExternalsDescription.TAG: 'rtm1_0_26', - ModelDescription.BRANCH: EMPTY_STR + ExternalsDescription.BRANCH: EMPTY_STR } data = {self._name: { - ModelDescription.REQUIRED: False, - ModelDescription.PATH: 'fake', - ModelDescription.EXTERNALS: '', - ModelDescription.REPO: rdata, + ExternalsDescription.REQUIRED: False, + ExternalsDescription.PATH: 'fake', + ExternalsDescription.EXTERNALS: '', + ExternalsDescription.REPO: rdata, }, } - model = ModelDescriptionDict(data) - repo = model[self._name][ModelDescription.REPO] + model = ExternalsDescriptionDict(data) + repo = model[self._name][ExternalsDescription.REPO] self._repo = GitRepository('test', repo) self.create_tmp_git_dir() @@ -210,7 +210,7 @@ def test_repo_dir_exist_no_git_info(self): def test_repo_dir_synced(self): """Test that a valid info string that is synced to the repo in the - model description returns an ok status. + externals description returns an ok status. """ stat = ExternalStatus() @@ -224,7 +224,7 @@ def test_repo_dir_synced(self): def test_repo_dir_modified(self): """Test that a valid svn info string that is out of sync with the - model description returns a modified status. + externals description returns a modified status. """ stat = ExternalStatus() diff --git a/test/test_unit_repository_svn.py b/test/test_unit_repository_svn.py index ac0e280..fb8aafc 100644 --- a/test/test_unit_repository_svn.py +++ b/test/test_unit_repository_svn.py @@ -19,8 +19,8 @@ from manic.repository_svn import SvnRepository from manic.externalstatus import ExternalStatus -from manic.model_description import ModelDescription -from manic.model_description import ModelDescriptionDict +from manic.externals_description import ExternalsDescription +from manic.externals_description import ExternalsDescriptionDict from manic.globals import EMPTY_STR SVN_INFO_MOSART = """Path: components/mosart @@ -60,25 +60,25 @@ def setUp(self): """Setup reusable svn repository object """ self._name = 'component' - rdata = {ModelDescription.PROTOCOL: 'svn', - ModelDescription.REPO_URL: + rdata = {ExternalsDescription.PROTOCOL: 'svn', + ExternalsDescription.REPO_URL: 'https://svn-ccsm-models.cgd.ucar.edu/', - ModelDescription.TAG: + ExternalsDescription.TAG: 'mosart/trunk_tags/mosart1_0_26', - ModelDescription.BRANCH: '' + ExternalsDescription.BRANCH: '' } data = {self._name: { - ModelDescription.REQUIRED: False, - ModelDescription.PATH: 'junk', - ModelDescription.EXTERNALS: '', - ModelDescription.REPO: rdata, + ExternalsDescription.REQUIRED: False, + ExternalsDescription.PATH: 'junk', + ExternalsDescription.EXTERNALS: '', + ExternalsDescription.REPO: rdata, }, } - model = ModelDescriptionDict(data) - repo = model[self._name][ModelDescription.REPO] + model = ExternalsDescriptionDict(data) + repo = model[self._name][ExternalsDescription.REPO] self._repo = SvnRepository('test', repo) def test_check_url_same(self): @@ -118,25 +118,25 @@ def setUp(self): """Setup reusable svn repository object """ self._name = "component" - rdata = {ModelDescription.PROTOCOL: 'svn', - ModelDescription.REPO_URL: + rdata = {ExternalsDescription.PROTOCOL: 'svn', + ExternalsDescription.REPO_URL: 'https://svn-ccsm-models.cgd.ucar.edu/', - ModelDescription.TAG: + ExternalsDescription.TAG: 'mosart/trunk_tags/mosart1_0_26', - ModelDescription.BRANCH: EMPTY_STR + ExternalsDescription.BRANCH: EMPTY_STR } data = {self._name: { - ModelDescription.REQUIRED: False, - ModelDescription.PATH: 'junk', - ModelDescription.EXTERNALS: EMPTY_STR, - ModelDescription.REPO: rdata, + ExternalsDescription.REQUIRED: False, + ExternalsDescription.PATH: 'junk', + ExternalsDescription.EXTERNALS: EMPTY_STR, + ExternalsDescription.REPO: rdata, }, } - model = ModelDescriptionDict(data) - repo = model[self._name][ModelDescription.REPO] + model = ExternalsDescriptionDict(data) + repo = model[self._name][ExternalsDescription.REPO] self._repo = SvnRepository('test', repo) @staticmethod @@ -184,7 +184,7 @@ def test_repo_dir_exist_no_svn_info(self): def test_repo_dir_synced(self): """Test that a valid info string that is synced to the repo in the - model description returns an ok status. + externals description returns an ok status. """ stat = ExternalStatus() @@ -198,7 +198,7 @@ def test_repo_dir_synced(self): def test_repo_dir_modified(self): """Test that a valid svn info string that is out of sync with the - model description returns a modified status. + externals description returns a modified status. """ stat = ExternalStatus()