Esempio n. 1
0
    def test_read_dictionnary_from_file(self):

        some_dict = {"a": "b", "c": "d"}
        contents = json.dumps(some_dict)
        with open(self.wallet_path, "w") as f:
            contents = f.write(contents)

        storage = WalletStorage(self.wallet_path)
        self.assertEqual("b", storage.get("a"))
        self.assertEqual("d", storage.get("c"))
Esempio n. 2
0
	def read(self, storage: WalletStorage):
		data = storage.get(PersistentTipList.KEY)
		if not data or not "version" in data.keys() or data["version"] != PersistentTipList.STORAGE_VERSION:
			raise StorageVersionMismatchException("tiplist not in wallet storage or tiplist storage version too old")
		tips = data["tips"]
		if len(tips) <= 0:
			raise StorageVersionMismatchException("tiplist empty")
		for id, d in tips.items():
			# klass = globals()[d["_class_name"]]
			# tip = klass(self)
			class_name = d["_class_name"]
			if class_name == "RedditTip":
				tip = RedditTip(self, self.wallet_ui.reddit)
			tip.from_dict(d)
			assert tip.getID() == id
			self.addTip(tip)
			self.updateTip(tip)