Exemple #1
0
def test_to_dict_list_stash_file(stash_file):
    stash_file_, _ = stash_file
    for page in stash_file_.stash:
        items_dict_list = to_dict_list(page['items'])
        assert isinstance(items_dict_list, list)
        assert all(
            isinstance(item_dict, dict) for item_dict in items_dict_list)
Exemple #2
0
 def to_dict(self):
     """See _D2File.to_dict.__doc__."""
     _dict = obj_to_dict(self, exclude=('_reader', ))
     if self.stash:
         _dict['stash'] = [page.copy() for page in self.stash]
         for page in _dict['stash']:
             page['items'] = to_dict_list(page['items'])
     return _dict
Exemple #3
0
    def to_dict(self):
        """See _D2File.to_dict.__doc__."""
        _dict = obj_to_dict(self, exclude=('_reader', '_rbit_reader'))
        _dict['char_class'] = self.char_class
        _dict['is_hardcore'] = self.is_hardcore
        _dict['is_died'] = self.is_died
        _dict['is_expansion'] = self.is_expansion
        _dict['is_ladder'] = self.is_ladder

        if self.items:
            _dict['items'] = to_dict_list(self.items)
        if self.corpse_items:
            _dict['corpse_items'] = to_dict_list(self.corpse_items)
        if self.merc_items:
            _dict['merc_items'] = to_dict_list(self.merc_items)
        if self.golem_item:
            _dict['golem_item'] = self.golem_item.to_dict()

        return _dict
Exemple #4
0
    def to_dict(self):
        """Dumps self to dictionary.

        :return: A dictionary with excluded private attributes such as _reader.
        :rtype: dict
        """
        item_dict = obj_to_dict(self, exclude=('_reader',))
        if self.socketed_items:
            item_dict['socketed_items'] = to_dict_list(self.socketed_items)
        item_dict['name'] = self.name
        return item_dict
Exemple #5
0
def test_to_dict_list_d2s_file(d2s_file):
    d2s, _ = d2s_file
    items_dict_list = to_dict_list(d2s.items)
    assert isinstance(items_dict_list, list)
    assert all(isinstance(item_dict, dict) for item_dict in items_dict_list)