def get_object_json(self, obj): """Returns object json""" with benchmark("Get object JSON"): return as_json({ self.model._inflector.table_singular: filter_resource( ggrc.builder.json.publish_representation( ggrc.builder.json.publish(obj, (), inclusion_filter))) })
"""Generated test number of simple objects (extra obj from dirty pool)""" expected_results = self.build_expected_action_list( created_count, modified_count, deleted_count) new = self.populate_object_list(created_count) deleted = self.populate_object_list(deleted_count) dirty = self.populate_object_list(modified_count) with self.mock_get_cache(new, deleted, dirty): self.assertEqual( expected_results, [r.action for r in self.get_log_revisions(dirty[0])]) class TestFilterResource(TestCase): """Tests for common.filter_resource""" @mock.patch("ggrc.services.common._is_creator", return_value=True) def test_filter_revision(self, _): """Test old revision filtering""" resource = { 'description': u'document1', 'resource_id': 1L, 'resource_type': u'ObjectDocument', 'type': 'Revision', 'context': None, } res = common.filter_resource(resource=resource, depth=1, user_permissions=object()) self.assertIsNone(res)