Skip to content

Commit a1ab6ce

Browse files
authored
Merge pull request #199 from zhenlineo/1.5-uuid-type
Added some tests to ensure unsupported types will error properly
2 parents ad928c5 + 6d8f97e commit a1ab6ce

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

test/integration/test_session.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1818
# See the License for the specific language governing permissions and
1919
# limitations under the License.
20-
2120
from unittest import SkipTest
2221
from uuid import uuid4
2322

@@ -434,7 +433,21 @@ def test_should_sync_after_rollback(self):
434433
assert len(buffer) == 1
435434
assert buffer[0][0] == 1
436435

437-
def test_errors_on_run(self):
436+
def test_errors_on_write_transaction(self):
437+
session = self.driver.session()
438+
with self.assertRaises(TypeError):
439+
session.write_transaction(lambda tx, uuid : tx.run("CREATE (a:Thing {uuid:$uuid})", uuid=uuid), uuid4())
440+
session.close()
441+
442+
def test_errors_on_run_transaction(self):
443+
session = self.driver.session()
444+
tx = session.begin_transaction()
445+
with self.assertRaises(TypeError):
446+
tx.run("CREATE (a:Thing {uuid:$uuid})", uuid=uuid4())
447+
tx.rollback()
448+
session.close()
449+
450+
def test_errors_on_run_session(self):
438451
session = self.driver.session()
439452
session.close()
440453
with self.assertRaises(SessionError):

test/unit/test_packstream.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from io import BytesIO
2525
from math import pi
2626
from unittest import TestCase
27+
from uuid import uuid4
2728

2829
from neo4j.bolt.io import MessageFrame as PyMessageFrame
2930
from neo4j.packstream.packer import Packer as PyPacker
@@ -273,19 +274,18 @@ def test_map_stream(self):
273274
(unpacked, unpacked_value))
274275

275276
def test_illegal_signature(self):
276-
try:
277+
with self.assertRaises(ValueError):
277278
self.assert_packable((b"XXX", ()), b"\xB0XXX")
278-
except ValueError:
279-
assert True
280-
else:
281-
assert False
282279

283280
def test_empty_struct(self):
284281
self.assert_packable((b"X", ()), b"\xB0X")
285282

286283
def test_tiny_struct(self):
287284
self.assert_packable((b"Z", (u"A", 1)), b"\xB2Z\x81A\x01")
288285

286+
def test_illegal_uuid(self):
287+
with self.assertRaises(ValueError):
288+
self.assert_packable(uuid4(), b"\xB0XXX")
289289

290290
try:
291291
from neo4j.bolt._io import MessageFrame as CMessageFrame

0 commit comments

Comments
 (0)