Simplify format_mmd since scm.commit is always set or returns an exception

This commit is contained in:
mprahl
2019-04-30 09:49:02 -04:00
parent f4dd91e9ec
commit 37e4c718d9
4 changed files with 32 additions and 11 deletions

View File

@@ -102,6 +102,8 @@ class FakeSCM(object):
self.mocked_scm.return_value.branch = branch
self.mocked_scm.return_value.sourcedir = self.sourcedir
self.mocked_scm.return_value.get_module_yaml = self.get_module_yaml
self.mocked_scm.return_value.is_full_commit_hash.return_value = commit and len(commit) == 40
self.mocked_scm.return_value.get_full_commit_hash.return_value = self.get_full_commit_hash
def checkout(self, temp_dir):
try:
@@ -124,6 +126,12 @@ class FakeSCM(object):
def get_module_yaml(self):
return path.join(self.sourcedir, self.name + ".yaml")
def get_full_commit_hash(self, commit_hash=None):
if not commit_hash:
commit_hash = self.commit
sha1_hash = hashlib.sha1("random").hexdigest()
return commit_hash + sha1_hash[len(commit_hash):]
class TestViews:
def setup_method(self, test_method):