def loadcontent(self, identification, *props): """ Fetch the current content of a Wikibase item. This is called loadcontent since wbgetentities does not support fetching old revisions. Eventually this will get replaced by an actual loadrevisions. @param identification: Parameters used to identify the page(s) @type identification: dict @param props: the optional properties to fetch. """ params = merge_unique_dicts( identification, action='wbgetentities', # TODO: When props is empty it results in # an empty string ('&props=') but it should # result in a missing entry. props=props if props else False) req = self._simple_request(**params) data = req.submit() if 'success' not in data: raise api.APIError(data['errors'], '') return data['entities']
def test_conflict(self): """Test that it detects conflicts.""" with self.assertRaisesRegex(ValueError, '42'): tools.merge_unique_dicts(self.dct1, **{'42': 'bad'}) with self.assertRaisesRegex(ValueError, '42'): tools.merge_unique_dicts(self.dct1, self.dct1) with self.assertRaisesRegex(ValueError, '42'): tools.merge_unique_dicts(self.dct1, **self.dct1)
def notifications_mark_read(self, **kwargs): """Mark selected notifications as read. @return: whether the action was successful @rtype: bool """ # TODO: ensure that the 'echomarkread' action # is supported by the site kwargs = merge_unique_dicts(kwargs, action='echomarkread', token=self.tokens['edit']) req = self._simple_request(**kwargs) data = req.submit() try: return data['query']['echomarkread']['result'] == 'success' except KeyError: return False
def test_different_type(self): """Test that the keys can be different types.""" self.assertEqual(tools.merge_unique_dicts({'1': 'str'}, {1: 'int'}), { '1': 'str', 1: 'int' })
def test_multiple(self): """Test that it actually merges dicts.""" self.assertEqual(tools.merge_unique_dicts(self.dct1, self.dct2), self.dct_both) self.assertEqual(tools.merge_unique_dicts(self.dct2, **self.dct1), self.dct_both)
def test_single(self): """Test that it returns the dict itself when there is only one.""" self.assertEqual(tools.merge_unique_dicts(self.dct1), self.dct1) self.assertEqual(tools.merge_unique_dicts(**self.dct1), self.dct1)
def test_different_type(self): """Test that the keys can be different types.""" self.assertEqual(tools.merge_unique_dicts({"1": "str"}, {1: "int"}), {"1": "str", 1: "int"})
def test_different_type(self): """Test that the keys can be different types.""" self.assertEqual(tools.merge_unique_dicts({'1': 'str'}, {1: 'int'}), {'1': 'str', 1: 'int'})