def test_Rule_init(self): with self.assertRaises(exceptions.RuleDoesNotExistException): Rule("1.{}.99999999999".format(Rule.type_id)) def get_object(self, *args, **kwargs): return {"id": "1.{}.0".format(Rule.type_id)} with mock.patch("peerplaysapi.node.PeerPlaysNodeRPC.get_object", new=get_object): Rule("1.{}.0".format(Rule.type_id))
def getBettingMarketGroupRule(self, bmgrId): try: return Rule(bmgrId, peerplays_instance=self.get_node()) except Exception as ex: raise NodeException( "BettingMarkets could not be loaded: {}".format( self._get_exception_message(ex)))
def is_synced(self): """ Test if data on chain matches lookup """ if "id" in self and self["id"]: rule = Rule(self["id"]) if self.test_operation_equal(rule): return True return False
def fixture_data(): peerplays.clear() BettingMarkets.clear_cache() Rules.clear_cache() BettingMarketGroups.clear_cache() Proposals.clear_cache() Witnesses.clear_cache() Events.clear_cache() EventGroups.clear_cache() Sports.clear_cache() with open(os.path.join(os.path.dirname(__file__), "fixtures.yaml")) as fid: data = yaml.safe_load(fid) [Account(x) for x in data.get("accounts", [])] [Account(x).store(x, "name") for x in data.get("accounts", [])] Witnesses.cache_objects([Witness(x) for x in data.get("witnesses", [])]) Sports.cache_objects([Sport(x) for x in data.get("sports", [])]) EventGroups.cache_objects( [EventGroup(x) for x in data.get("eventgroups", [])]) Events.cache_objects([Event(x) for x in data.get("events", [])]) BettingMarketGroups.cache_objects( [BettingMarketGroup(x) for x in data.get("bettingmarketgroups", [])]) BettingMarkets.cache_objects( [BettingMarket(x) for x in data.get("bettingmarkets", [])]) Rules.cache_objects([Rule(x) for x in data.get("rules", [])]) [Bet(x) for x in data.get("bets", [])] proposals = [] for proposal in data.get("proposals", []): ops = list() for _op in proposal["operations"]: for opName, op in _op.items(): ops.append([operations[opName], op]) # Proposal! proposal_id = proposal["proposal_id"] proposal_data = { "available_active_approvals": [], "available_key_approvals": [], "available_owner_approvals": [], "expiration_time": "2018-05-29T10:23:13", "id": proposal_id, "proposed_transaction": { "expiration": "2018-05-29T10:23:13", "extensions": [], "operations": ops, "ref_block_num": 0, "ref_block_prefix": 0, }, "proposer": "1.2.7", "required_active_approvals": ["1.2.1"], "required_owner_approvals": [], } proposals.append(Proposal(proposal_data)) Proposals.cache_objects(proposals, "1.2.1") Proposals.cache_objects(proposals, "witness-account")
def rule(ctx, rule): """ [bookie] Show a specific rule :param str bmg: Betting market id """ rule = Rule(rule, peerplays_instance=ctx.peerplays) t = PrettyTable([ "id", "name", ]) t.align = "l" t.add_row([ rule["id"], "\n".join(["{}: {}".format(v[0], v[1]) for v in rule["name"]]), ]) click.echo(str(t)) click.echo( "\n".join(["{}: {}".format(v[0], v[1]) for v in rule["description"]]) )
def grading(self): # We take the actual grading from the blockchain and not from # the lookup!! rule = Rule(self.rules.id, peerplays_instance=self.peerplays) return rule.grading
def getRules(rules_id): # TODO add pagination return Rule(rules_id, peerplays_instance=ppy)