Example #1
0
    def test_parse_donate_amount(self):
        self.assertTrue(
            helper.parse_amount("donate ", "donate 1.0 xmr", 0) == "1.0")
        self.assertTrue(
            helper.parse_amount("donate ", "donate 1xmr", 0) == "1")

        self.assertTrue(
            helper.parse_amount("donate ", "donate 1 mxmr", 0) == "0.001")
        self.assertTrue(
            helper.parse_amount("donate ", "donate 1mxmr", 0) == "0.001")

        self.assertTrue(
            helper.parse_amount("donate ", "donate 100% of my balance", 1) ==
            "1.0")
        self.assertTrue(
            helper.parse_amount("donate ", "donate 50% of my balance", 1) ==
            "0.5")
        self.assertTrue(
            helper.parse_amount("donate ", "donate 0% of my balance", 1) ==
            "0.0")

        self.assertTrue(
            helper.parse_amount("donate ", "donate 1.0$", 0) == str(
                get_xmr_val(1)))
        self.assertTrue(
            helper.parse_amount("donate ", "donate $1", 0) == str(
                get_xmr_val(1)))
Example #2
0
    def test_parse_anontip_amount(self):
        self.assertTrue(
            helper.parse_amount(f"anonymous tip {helper.botname} ",
                                f"anonymous tip {helper.botname} 1 xmr") ==
            "1")
        self.assertTrue(
            helper.parse_amount(f"anonymous tip {helper.botname} ",
                                f"anonymous tip {helper.botname} 1xmr") == "1")
        self.assertTrue(
            helper.parse_amount(f"anonymous tip {helper.botname} ",
                                f"anonymous tip {helper.botname} 1 mxmr") ==
            "0.001")
        self.assertTrue(
            helper.parse_amount(f"anonymous tip {helper.botname} ",
                                f"anonymous tip {helper.botname} 1mxmr") ==
            "0.001")

        self.assertTrue(
            helper.parse_amount(f"anonymous tip {helper.botname} ",
                                f"anonymous tip {helper.botname} 1$") == str(
                                    get_xmr_val(1)))
        self.assertTrue(
            helper.parse_amount(f"anonymous tip {helper.botname} ",
                                f"anonymous tip {helper.botname} $1.0") == str(
                                    get_xmr_val(1)))
    def test_parse_withdrawal_amount(self):

        self.assertTrue(
            helper.parse_amount("withdraw ", "withdraw 1xmr") == "1")
        self.assertTrue(
            helper.parse_amount("withdraw ", "withdraw 1.0 xmr") == "1.0")

        self.assertTrue(
            helper.parse_amount("withdraw ", "withdraw 1 mxmr") == "0.001")
        self.assertTrue(
            helper.parse_amount("withdraw ", "withdraw 1mxmr") == "0.001")

        self.assertTrue(
            helper.parse_amount("withdraw ", "withdraw 1.0$") == str(
                helper.get_xmr_val(1)))
        self.assertTrue(
            helper.parse_amount("withdraw ", "withdraw $1") == str(
                helper.get_xmr_val(1)))
Example #4
0
    def test_parse_tip_amount(self):
        prefix = f"/u/{helper.botname} (tip )?"

        self.assertTrue(
            helper.parse_amount(prefix, f"/u/{helper.botname} 1.0 xmr") ==
            "1.0")
        self.assertTrue(
            helper.parse_amount(prefix, f"/u/{helper.botname} 1xmr") == "1")
        self.assertTrue(
            helper.parse_amount(prefix, f"/u/{helper.botname} 5 xmr") == "5")
        self.assertTrue(
            helper.parse_amount(prefix, f"/u/{helper.botname} tip 1 xmr") ==
            "1")
        self.assertTrue(
            helper.parse_amount(prefix, f"/u/{helper.botname} tip 1xmr") ==
            "1")

        self.assertTrue(
            helper.parse_amount(prefix, f"/u/{helper.botname} 1 mxmr") ==
            "0.001")
        self.assertTrue(
            helper.parse_amount(prefix, f"/u/{helper.botname} 1mxmr") ==
            "0.001")
        self.assertTrue(
            helper.parse_amount(prefix, f"/u/{helper.botname} tip 1 mxmr") ==
            "0.001")
        self.assertTrue(
            helper.parse_amount(prefix, f"/u/{helper.botname} tip 1mxmr") ==
            "0.001")

        self.assertTrue(
            helper.parse_amount(prefix, f"/u/{helper.botname} 1.0$") == str(
                get_xmr_val(1)))
        self.assertTrue(
            helper.parse_amount(prefix, f"/u/{helper.botname} $1") == str(
                get_xmr_val(1)))

        self.assertTrue(
            helper.parse_amount(
                prefix,
                f"Here's some stuff to throw the bot off:\n If you want to peer to peer trade Monero instead of using an exchange, check out LocalMonero: http://localmonero.co/\n/u/{helper.botname} 0.001 XMR"
            ) == "0.001")
Example #5
0
def parse_anon_tip_amount(subject):
    """
    Returns amount of XMR to tip

    :param subject: in format "Anonymous tip USER AMOUNT xmr"
    """
    m = re.search('anonymous tip [^ ]+ ([\\d\\.]+)( )?(m)?xmr', subject.lower())
    if m:
        return str(Decimal(m.group(1)) / 1000) if m.group(m.lastindex) == 'm' else m.group(1)

    m = re.search('anonymous tip [^ ]+ (\\$)?(?P<dollar_amt>[\\d\\.]+)(\\$)?', str(subject).lower())
    if m:
        return str(get_xmr_val(m.group("dollar_amt")))
Example #6
0
 def test_parse_amount(self):
     self.assertTrue(helper.parse_amount("donate ", "donate 5 xmr", 2) == "5")
     self.assertTrue(helper.parse_amount("donate ", "donate 5$", 2) == helper.get_xmr_val(5))
     self.assertTrue(float(helper.parse_amount("donate ", "donate 50% of my balance", 2)) == float(1))
     self.assertTrue(float(helper.parse_amount("donate ", "donate 0.1% of my balance", 100)) == float(0.1))
Example #7
0
    def test_get_dollar_val(self):
        self.assertTrue(float(helper.get_dollar_val(1)) > 0)
        self.assertTrue(float(helper.get_dollar_val(1)) < 5000)

        self.assertTrue(helper.get_dollar_val(helper.get_xmr_val(5)) == "5.00")
Example #8
0
 def test_get_xmr_val(self):
     self.assertTrue(float(helper.get_xmr_val(5)) > 0)
     self.assertTrue(float(helper.get_xmr_val(1)) < 5000)