Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
 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)
Esempio n. 4
0
 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)
Esempio n. 5
0
 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)
Esempio n. 6
0
 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)
Esempio n. 7
0
 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)
Esempio n. 8
0
    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)
Esempio n. 9
0
 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)
Esempio n. 10
0
 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)
Esempio n. 11
0
    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)
Esempio n. 12
0
 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)
Esempio n. 13
0
    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)
Esempio n. 14
0
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)
Esempio n. 15
0
 def test_pipe_with_base_value_return_the_same_when_no_functions_are_provided(
         self):
     self.assertEquals(pipe(5, []), 5)