|
4 | 4 | import copy |
5 | 5 | import platform |
6 | 6 | from time import sleep |
7 | | -from riak import ConflictError |
| 7 | +from riak import ConflictError, RiakBucket |
8 | 8 | from riak.resolver import default_resolver, last_written_resolver |
9 | 9 | try: |
10 | 10 | import simplejson as json |
@@ -95,6 +95,25 @@ def test_store_unicode_string(self): |
95 | 95 | obj2 = bucket.get(self.key_name) |
96 | 96 | self.assertEqual(data, obj2.encoded_data.decode('utf-8')) |
97 | 97 |
|
| 98 | + def test_string_bucket_name(self): |
| 99 | + # Things that are not strings cannot be bucket names |
| 100 | + for bad in (12345, True, None, {}, []): |
| 101 | + with self.assertRaisesRegexp(TypeError, 'must be a string'): |
| 102 | + self.client.bucket(bad) |
| 103 | + |
| 104 | + with self.assertRaisesRegexp(TypeError, 'must be a string'): |
| 105 | + RiakBucket(self.client, bad) |
| 106 | + |
| 107 | + # Unicode bucket names are not supported, if they can't be |
| 108 | + # encoded to ASCII. This should be changed in a future |
| 109 | + # release. |
| 110 | + with self.assertRaisesRegexp(TypeError, |
| 111 | + 'Unicode bucket names are not supported'): |
| 112 | + self.client.bucket(u'føø') |
| 113 | + |
| 114 | + # This is fine, since it's already ASCII |
| 115 | + self.client.bucket('ASCII') |
| 116 | + |
98 | 117 | def test_generate_key(self): |
99 | 118 | # Ensure that Riak generates a random key when |
100 | 119 | # the key passed to bucket.new() is None. |
|
0 commit comments