tMerge pull request #1376 from romanz/master - electrum - Electrum Bitcoin wallet
 (HTM) git clone https://git.parazyd.org/electrum
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
       ---
 (DIR) commit 70d59bbe06e0610136f82bec837a50d1b9804c92
 (DIR) parent 96c3513cb2cf7f8acddd039057a2800e5398fe5e
 (HTM) Author: ThomasV <electrumdev@gmail.com>
       Date:   Sat, 25 Jul 2015 17:19:28 +0200
       
       Merge pull request #1376 from romanz/master
       
       util: fix small typo at parse_URI() and update its unittests
       Diffstat:
         M lib/tests/test_util.py              |      37 ++++++++++++++++++-------------
         M lib/util.py                         |       2 +-
       
       2 files changed, 22 insertions(+), 17 deletions(-)
       ---
 (DIR) diff --git a/lib/tests/test_util.py b/lib/tests/test_util.py
       t@@ -18,41 +18,46 @@ class TestUtil(unittest.TestCase):
                expected = "-0.00001234"
                self.assertEqual(expected, result)
        
       -    def _do_test_parse_URI(self, uri, expected_address, expected_amount, expected_label, expected_message, expected_request_url):
       -        address, amount, label, message, request_url = parse_URI(uri)
       -        self.assertEqual(expected_address, address)
       -        self.assertEqual(expected_amount, amount)
       -        self.assertEqual(expected_label, label)
       -        self.assertEqual(expected_message, message)
       -        self.assertEqual(expected_request_url, request_url)
       +    def _do_test_parse_URI(self, uri, expected):
       +        result = parse_URI(uri)
       +        self.assertEqual(expected, result)
        
            def test_parse_URI_address(self):
       -        self._do_test_parse_URI('bitcoin:15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma', '15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma', '', '', '', '')
       +        self._do_test_parse_URI('bitcoin:15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma',
       +                                {'address': '15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma'})
        
            def test_parse_URI_only_address(self):
       -        self._do_test_parse_URI('15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma', '15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma', None, None, None, None)
       +        self._do_test_parse_URI('15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma',
       +                                {'address': '15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma'})
        
        
            def test_parse_URI_address_label(self):
       -        self._do_test_parse_URI('bitcoin:15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma?label=electrum%20test', '15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma', '', 'electrum test', '', '')
       +        self._do_test_parse_URI('bitcoin:15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma?label=electrum%20test',
       +                                {'address': '15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma', 'label': 'electrum test'})
        
            def test_parse_URI_address_message(self):
       -        self._do_test_parse_URI('bitcoin:15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma?message=electrum%20test', '15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma', '', '', 'electrum test', '')
       +        self._do_test_parse_URI('bitcoin:15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma?message=electrum%20test',
       +                                {'address': '15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma', 'message': 'electrum test', 'memo': 'electrum test'})
        
            def test_parse_URI_address_amount(self):
       -        self._do_test_parse_URI('bitcoin:15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma?amount=0.0003', '15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma', 30000, '', '', '')
       +        self._do_test_parse_URI('bitcoin:15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma?amount=0.0003',
       +                                {'address': '15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma', 'amount': 30000})
        
            def test_parse_URI_address_request_url(self):
       -        self._do_test_parse_URI('bitcoin:15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma?r=http://domain.tld/page?h%3D2a8628fc2fbe', '15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma', '', '', '', 'http://domain.tld/page?h=2a8628fc2fbe')
       +        self._do_test_parse_URI('bitcoin:15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma?r=http://domain.tld/page?h%3D2a8628fc2fbe',
       +                                {'address': '15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma', 'r': 'http://domain.tld/page?h=2a8628fc2fbe'})
        
            def test_parse_URI_ignore_args(self):
       -        self._do_test_parse_URI('bitcoin:15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma?test=test', '15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma', '', '', '', '')
       +        self._do_test_parse_URI('bitcoin:15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma?test=test',
       +                                {'address': '15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma', 'test': 'test'})
        
            def test_parse_URI_multiple_args(self):
       -        self._do_test_parse_URI('bitcoin:15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma?amount=0.00004&label=electrum-test&message=electrum%20test&test=none&r=http://domain.tld/page', '15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma', 4000, 'electrum-test', 'electrum test', 'http://domain.tld/page')
       +        self._do_test_parse_URI('bitcoin:15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma?amount=0.00004&label=electrum-test&message=electrum%20test&test=none&r=http://domain.tld/page',
       +                                {'address': '15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma', 'amount': 4000, 'label': 'electrum-test', 'message': u'electrum test', 'memo': u'electrum test', 'r': 'http://domain.tld/page', 'test': 'none'})
        
            def test_parse_URI_no_address_request_url(self):
       -        self._do_test_parse_URI('bitcoin:?r=http://domain.tld/page?h%3D2a8628fc2fbe', '', '', '', '', 'http://domain.tld/page?h=2a8628fc2fbe')
       +        self._do_test_parse_URI('bitcoin:?r=http://domain.tld/page?h%3D2a8628fc2fbe',
       +                                {'r': 'http://domain.tld/page?h=2a8628fc2fbe'})
        
            def test_parse_URI_invalid_address(self):
                self.assertRaises(AssertionError, parse_URI, 'bitcoin:invalidaddress')
 (DIR) diff --git a/lib/util.py b/lib/util.py
       t@@ -246,7 +246,7 @@ def parse_URI(uri):
        
            if ':' not in uri:
                assert bitcoin.is_address(uri)
       -        return uri, None, None, None, None
       +        return {'address': uri}
        
            u = urlparse.urlparse(uri)
            assert u.scheme == 'bitcoin'