From 33027caa41cdfb798225b5c5d703c0c94a649e44 Mon Sep 17 00:00:00 2001 From: Zapata Date: Mon, 14 May 2018 13:48:53 +0200 Subject: [PATCH] Test Graphene source and fix issue when multiple quotes are provided. --- bitshares_pricefeed/sources/graphene.py | 2 +- tests/sources/test_graphene.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/sources/test_graphene.py diff --git a/bitshares_pricefeed/sources/graphene.py b/bitshares_pricefeed/sources/graphene.py index d54a175..e47aa78 100644 --- a/bitshares_pricefeed/sources/graphene.py +++ b/bitshares_pricefeed/sources/graphene.py @@ -10,13 +10,13 @@ def _fetch(self): feed = {} try: for base in self.bases: + feed[base] = {} for quote in self.quotes: if quote == base: continue ticker = Market("%s:%s" % (quote, base)).ticker() if hasattr(self, "quoteNames") and quote in self.quoteNames: quote = self.quoteNames[quote] - feed[base] = {} if (float(ticker["latest"])) > 0 and float(ticker["quoteVolume"]) > 0: feed[base][quote] = {"price": (float(ticker["latest"])), "volume": (float(ticker["quoteVolume"]) * self.scaleVolumeBy)} diff --git a/tests/sources/test_graphene.py b/tests/sources/test_graphene.py new file mode 100644 index 0000000..ebdbb51 --- /dev/null +++ b/tests/sources/test_graphene.py @@ -0,0 +1,8 @@ +from bitshares_pricefeed.sources.graphene import Graphene + +def test_graphene_fetch(checkers): + source = Graphene(quotes=['USD', 'CNY'], bases=['BTS']) + feed = source.fetch() + checkers.check_feed(feed, ['USD:BTS', 'CNY:BTS']) + +