Example #1
0
 def as_dict(self):
     """
     Returns dictionary with changeset's attributes and their values.
     """
     data = get_dict_for_attrs(self, ["id", "raw_id", "short_id", "revision", "date", "message"])
     data["author"] = {"name": self.author_name, "email": self.author_email}
     data["added"] = [node.path for node in self.added]
     data["changed"] = [node.path for node in self.changed]
     data["removed"] = [node.path for node in self.removed]
     return data
Example #2
0
 def as_dict(self):
     """
     Returns dictionary with changeset's attributes and their values.
     """
     data = get_dict_for_attrs(self, ['id', 'raw_id', 'short_id',
         'revision', 'date', 'message'])
     data['author'] = {'name': self.author_name, 'email': self.author_email}
     data['added'] = [node.path for node in self.added]
     data['changed'] = [node.path for node in self.changed]
     data['removed'] = [node.path for node in self.removed]
     return data
Example #3
0
 def as_dict(self):
     """
     Returns dictionary with changeset's attributes and their values.
     """
     data = get_dict_for_attrs(self, ['id', 'raw_id', 'short_id',
         'revision', 'date', 'message'])
     data['author'] = {'name': self.author_name, 'email': self.author_email}
     data['added'] = [node.path for node in self.added]
     data['changed'] = [node.path for node in self.changed]
     data['removed'] = [node.path for node in self.removed]
     return data
Example #4
0
    def test_returned_dict_has_expected_attrs(self):
        obj = mock.Mock()
        obj.NOT_INCLUDED = 'this key/value should not be included'
        obj.CONST = True
        obj.foo = 'aaa'
        obj.attrs = {'foo': 'bar'}
        obj.date = datetime.datetime(2010, 12, 31)
        obj.count = 1001

        self.assertEqual(get_dict_for_attrs(obj, ['CONST', 'foo', 'attrs',
            'date', 'count']), {
            'CONST': True,
            'foo': 'aaa',
            'attrs': {'foo': 'bar'},
            'date': datetime.datetime(2010, 12, 31),
            'count': 1001,
        })
Example #5
0
    def test_returned_dict_has_expected_attrs(self):
        obj = mock.Mock()
        obj.NOT_INCLUDED = 'this key/value should not be included'
        obj.CONST = True
        obj.foo = 'aaa'
        obj.attrs = {'foo': 'bar'}
        obj.date = datetime.datetime(2010, 12, 31)
        obj.count = 1001

        self.assertEqual(
            get_dict_for_attrs(obj,
                               ['CONST', 'foo', 'attrs', 'date', 'count']), {
                                   'CONST': True,
                                   'foo': 'aaa',
                                   'attrs': {
                                       'foo': 'bar'
                                   },
                                   'date': datetime.datetime(2010, 12, 31),
                                   'count': 1001,
                               })