def parse_commit_message(conduit, corpus, partial=None): d = {"corpus": corpus, "partial": partial} d = phlsys_dictutil.copy_dict_no_nones(d) p = ParseCommitMessageResponse( **conduit.call("differential.parsecommitmessage", d)) phlsys_dictutil.ensure_keys_default( p.fields, "", ["summary", "testPlan", "title"]) phlsys_dictutil.ensure_keys_default( p.fields, [], ["reviewerPHIDs"]) return p
def parse_commit_message(conduit, corpus, partial=None): d = {"corpus": corpus, "partial": partial} d = phlsys_dictutil.copy_dict_no_nones(d) p = ParseCommitMessageResponse( **conduit("differential.parsecommitmessage", d)) if not isinstance(p.fields, dict): raise UnknownParseCommitMessageResponseError( "p.fields is not a dict: {}".format(p.fields)) phlsys_dictutil.ensure_keys_default( p.fields, "", ["summary", "testPlan", "title"]) phlsys_dictutil.ensure_keys_default( p.fields, [], ["reviewerPHIDs"]) return p
def test_D_EnsureKeysDefault(self): d1 = {'b': 1, 'e': 2, 'f': 3} d1copy = copy.deepcopy(d1) default = [[0, 1, 2], 1, 2] # nest a list to prove deep copying phlsys_dictutil.ensure_keys_default( d1, default, ['a', 'b', 'c', 'd', 'e']) self.assertDictContainsSubset(d1copy, d1) default[0][:] = [] # clear the list in place to prove we have copied default[:] = [] # clear the list in place to prove we have copied d2 = {'a': [[0, 1, 2], 1, 2], 'b': 1, 'c': [[0, 1, 2], 1, 2], 'd': [[0, 1, 2], 1, 2], 'e': 2, 'f': 3} self.assertDictEqual(d1, d2)