def test_filter_row(self): authority = Authority('cat', 'col') authority.get_suppressed_columns = lambda: ['b', 'd'] row = {'a': 1, 'b': 2, 'c': 3} authority.filter_row(row) self.assertEqual(row, {'a': 1, 'b': None, 'c': 3}) authority.allows_access = lambda: False row = {'a': 1, 'b': 2, 'c': 3} authority.filter_row(row) self.assertEqual(row, {'a': None, 'b': None, 'c': None})
def resolve_row(self, row, result): """ Resolve all values in the row Update the resolved value in the result :param row: :param result: :return: """ catalog_name = row.get(CATALOG_NAME) collection_name = row.get(COLLECTION_NAME) self._init_catalog_collection(catalog_name, collection_name) # Filter row and result for columns that do not match with the roles of the current request authority = Authority(catalog_name, collection_name) authority.filter_row(row, mapping=self._attributes[catalog_name][collection_name]) authority.filter_row(result, mapping=self._attributes[catalog_name][collection_name]) for attr in [name for name in [CATALOG_NAME, COLLECTION_NAME] if name in row]: # Once a row has been resolved, don't resolve it twice del row[attr]