def bounty_killed(self, bounty): message = pipe(bounty, [ get_base_bounty_values, wrapped_partial(pluck, fields=['title', 'bounty_id', 'link']), wrapped_partial(format_message, msg_string=BOUNTY_KILLED_SLACK_STR) ]) notify_slack(sc, channel, 'Bounty Killed', message)
def payout_increased(self, bounty): message = pipe(bounty, [ get_base_bounty_values, wrapped_partial(pluck, fields=['title', 'bounty_id', 'link']), wrapped_partial(format_message, msg_string=templates['PayoutIncreased']) ]) notify_slack(sc, channel, 'Payout Increased', message)
def issuer_transferred(self, bounty): message = pipe(bounty, [ get_base_bounty_values, wrapped_partial(pluck, fields=['title', 'bounty_id', 'link']), wrapped_partial(format_message, msg_string=templates['IssuerTransferred']) ]) notify_slack(sc, channel, 'Issuer Transferred', message)
def contribution_added(self, bounty): message = pipe(bounty, [ get_base_bounty_values, wrapped_partial(pluck, fields=['title', 'bounty_id', 'link']), wrapped_partial(format_message, msg_string=templates['ContributionAdded']) ]) notify_slack(sc, channel, 'Contribution Added', message)
def bounty_killed(self, bounty): message = pipe(bounty, [ get_base_bounty_values, wrapped_partial(pluck, fields=['title', 'id', 'link']), wrapped_partial(format_message, msg_string=templates['BountyKilled']) ]) notify_slack(sc, channel, 'Bounty Killed', message)
def fulfillment_updated(self, bounty, fulfillment_id): message = pipe(bounty, [ get_base_bounty_values, wrapped_partial(pluck, fields=['title', 'bounty_id', 'link']), wrapped_partial(format_message, msg_string=templates['FulfillmentUpdated'], fulfillment_id=fulfillment_id) ]) notify_slack(sc, channel, 'Fulfillment Updated', message)
def deadline_extended(self, bounty): message = pipe(bounty, [ get_base_bounty_values, wrapped_partial(pluck, fields=['title', 'bounty_id', 'deadline', 'link']), wrapped_partial(format_message, msg_string=templates['DeadlineExtended']) ]) notify_slack(sc, channel, 'Deadline Extended', message)
def test_pipe_call_each_function_in_the_order_they_are_specified_in_the_array_argument( self): def sub(x, y): return x - y p1 = partial(sub, -1) p2 = partial(sub, 3) p3 = partial(sub, -8) self.assertEquals(pipe(0, [p1, p2, p3]), -12)
def bounty_activated(self, bounty): message = pipe(bounty, [ get_base_bounty_values, wrapped_partial(pluck, fields=[ 'title', 'id', 'usd_price', 'total_value', 'token_symbol', 'token_price', 'link' ]), wrapped_partial(format_message, msg_string=templates['BountyActivated']) ]) notify_slack(sc, channel, 'Bounty Activated', message)
def bounty_issued_and_activated(self, bounty): message = pipe(bounty, [ get_base_bounty_values, wrapped_partial(pluck, fields=[ 'title', 'bounty_id', 'usd_price', 'total_value', 'tokenSymbol', 'token_price', 'deadline', 'link', 'total_value' ]), wrapped_partial(format_message, msg_string=BOUNTY_ISSUED_SLACK_STR) ]) notify_slack(sc, channel, 'Bounty Issued and Activated', message)
def test_pipe_return_immediately_if_one_function_returns_none(self): def sub(x, y): return x - y side = False p1 = partial(sub, -1) def p3(value): nonlocal side side = value self.assertEquals(pipe(0, [p1, lambda x: None, p3]), None) self.assertEquals(side, False)
def fulfillment_accepted(self, bounty, fulfillment_id): message = pipe(bounty, [ get_base_bounty_values, wrapped_partial(pluck, fields=[ 'title', 'bounty_id', 'usd_price', 'total_value', 'tokenSymbol', 'token_price', 'deadline', 'link', 'token_lock_price' ]), wrapped_partial(format_message, msg_string=templates['FulfillmentAccepted'], fulfillment_id=fulfillment_id) ]) notify_slack(sc, channel, 'Fulfillment Accepted', message)
def test_pipe_return_immediately_if_one_exception_is_raised(self): def sub(x, y): return x - y side = False p1 = partial(sub, -1) def p3(value): nonlocal side assert False side = value self.assertEquals(pipe(0, [p1, p3, lambda x: None]), None) self.assertEquals(side, False)
def apply_and_notify(base_value, event, action, inputs, fields, msg, slack_client, before_narrower=[], before_formatter=[], before_notify=[], after_notify=[]): # hooks partial_action = wrapped_partial(action, **inputs) partial_narrower = wrapped_partial(narrower, fields=fields) partial_formatter = wrapped_partial(formatter, msg) partial_notify = wrapped_partial(notify_slack, slack_client, settings.NOTIFICATIONS_SLACK_CHANNEL, event) actions = flatten([ partial_action, before_narrower, partial_narrower, before_formatter, partial_formatter, before_notify, partial_notify, after_notify ]) return pipe(base_value, actions)
def test_pipe_with_base_value_return_the_same_when_no_functions_are_provided( self): self.assertEquals(pipe(5, []), 5)