From 053c76d16cc73c9e1eb58f64acef231acdd9aa82 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Mon, 30 Sep 2024 15:36:55 +0200 Subject: [PATCH 1/4] trim usage of olf Sure testing framework in favor of regular Pytest --- tests/integration/cqlengine/test_timestamp.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/integration/cqlengine/test_timestamp.py b/tests/integration/cqlengine/test_timestamp.py index 6ddce91099..83bd67265c 100644 --- a/tests/integration/cqlengine/test_timestamp.py +++ b/tests/integration/cqlengine/test_timestamp.py @@ -68,15 +68,15 @@ def test_timestamp_not_included_on_normal_create(self): def test_timestamp_is_set_on_model_queryset(self): delta = timedelta(seconds=30) tmp = TestTimestampModel.timestamp(delta) - tmp._timestamp.should.equal(delta) + assert tmp._timestamp == delta def test_non_batch_syntax_integration(self): tmp = TestTimestampModel.timestamp(timedelta(seconds=30)).create(count=1) - tmp.should.be.ok + assert tmp def test_non_batch_syntax_with_tll_integration(self): tmp = TestTimestampModel.timestamp(timedelta(seconds=30)).ttl(30).create(count=1) - tmp.should.be.ok + assert tmp def test_non_batch_syntax_unit(self): @@ -129,7 +129,7 @@ def test_non_batch(self): uid = uuid4() tmp = TestTimestampModel.create(id=uid, count=1) - TestTimestampModel.get(id=uid).should.be.ok + assert TestTimestampModel.get(id=uid) tmp.timestamp(timedelta(seconds=5)).delete() @@ -143,15 +143,15 @@ def test_non_batch(self): # calling .timestamp sets the TS on the model tmp.timestamp(timedelta(seconds=5)) - tmp._timestamp.should.be.ok + assert tmp._timestamp # calling save clears the set timestamp tmp.save() - tmp._timestamp.shouldnt.be.ok + assert not tmp._timestamp tmp.timestamp(timedelta(seconds=5)) tmp.update() - tmp._timestamp.shouldnt.be.ok + assert not tmp._timestamp def test_blind_delete(self): """ @@ -160,7 +160,7 @@ def test_blind_delete(self): uid = uuid4() tmp = TestTimestampModel.create(id=uid, count=1) - TestTimestampModel.get(id=uid).should.be.ok + assert TestTimestampModel.get(id=uid) TestTimestampModel.objects(id=uid).timestamp(timedelta(seconds=5)).delete() @@ -179,7 +179,7 @@ def test_blind_delete_with_datetime(self): uid = uuid4() tmp = TestTimestampModel.create(id=uid, count=1) - TestTimestampModel.get(id=uid).should.be.ok + assert TestTimestampModel.get(id=uid) plus_five_seconds = datetime.now() + timedelta(seconds=5) @@ -197,7 +197,7 @@ def test_delete_in_the_past(self): uid = uuid4() tmp = TestTimestampModel.create(id=uid, count=1) - TestTimestampModel.get(id=uid).should.be.ok + assert TestTimestampModel.get(id=uid) # delete in the past, should not affect the object created above TestTimestampModel.objects(id=uid).timestamp(timedelta(seconds=-60)).delete() From 36818436374e02ce1a73f119e243ae72816ffbd3 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Mon, 23 Jun 2025 22:00:08 +0200 Subject: [PATCH 2/4] WIP --- tests/integration/cqlengine/test_timestamp.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/integration/cqlengine/test_timestamp.py b/tests/integration/cqlengine/test_timestamp.py index 83bd67265c..b5ff8927a3 100644 --- a/tests/integration/cqlengine/test_timestamp.py +++ b/tests/integration/cqlengine/test_timestamp.py @@ -68,15 +68,15 @@ def test_timestamp_not_included_on_normal_create(self): def test_timestamp_is_set_on_model_queryset(self): delta = timedelta(seconds=30) tmp = TestTimestampModel.timestamp(delta) - assert tmp._timestamp == delta + self.assertEqual(tmp._timestamp, delta) def test_non_batch_syntax_integration(self): tmp = TestTimestampModel.timestamp(timedelta(seconds=30)).create(count=1) - assert tmp + self.assertIsNotNone(tmp) def test_non_batch_syntax_with_tll_integration(self): tmp = TestTimestampModel.timestamp(timedelta(seconds=30)).ttl(30).create(count=1) - assert tmp + self.assertIsNotNone(tmp) def test_non_batch_syntax_unit(self): @@ -129,7 +129,7 @@ def test_non_batch(self): uid = uuid4() tmp = TestTimestampModel.create(id=uid, count=1) - assert TestTimestampModel.get(id=uid) + self.assertIsNotNone(TestTimestampModel.get(id=uid)) tmp.timestamp(timedelta(seconds=5)).delete() @@ -143,15 +143,15 @@ def test_non_batch(self): # calling .timestamp sets the TS on the model tmp.timestamp(timedelta(seconds=5)) - assert tmp._timestamp + self.assertIsNotNone(tmp._timestamp) # calling save clears the set timestamp tmp.save() - assert not tmp._timestamp + self.assertIsNone(tmp._timestamp) tmp.timestamp(timedelta(seconds=5)) tmp.update() - assert not tmp._timestamp + self.assertIsNone(tmp._timestamp) def test_blind_delete(self): """ @@ -160,7 +160,7 @@ def test_blind_delete(self): uid = uuid4() tmp = TestTimestampModel.create(id=uid, count=1) - assert TestTimestampModel.get(id=uid) + self.assertIsNotNone(TestTimestampModel.get(id=uid)) TestTimestampModel.objects(id=uid).timestamp(timedelta(seconds=5)).delete() @@ -179,7 +179,7 @@ def test_blind_delete_with_datetime(self): uid = uuid4() tmp = TestTimestampModel.create(id=uid, count=1) - assert TestTimestampModel.get(id=uid) + self.assertIsNotNone(TestTimestampModel.get(id=uid)) plus_five_seconds = datetime.now() + timedelta(seconds=5) @@ -197,7 +197,7 @@ def test_delete_in_the_past(self): uid = uuid4() tmp = TestTimestampModel.create(id=uid, count=1) - assert TestTimestampModel.get(id=uid) + self.assertIsNotNone(TestTimestampModel.get(id=uid)) # delete in the past, should not affect the object created above TestTimestampModel.objects(id=uid).timestamp(timedelta(seconds=-60)).delete() From 1ba0fbee2f342cf59875b845fcd2d2ba676fdfd8 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Thu, 3 Jul 2025 23:58:48 +0200 Subject: [PATCH 3/4] finish --- tests/integration/cqlengine/test_timestamp.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/integration/cqlengine/test_timestamp.py b/tests/integration/cqlengine/test_timestamp.py index b5ff8927a3..4a193f4888 100644 --- a/tests/integration/cqlengine/test_timestamp.py +++ b/tests/integration/cqlengine/test_timestamp.py @@ -44,7 +44,7 @@ def test_batch_is_included(self): with BatchQuery(timestamp=timedelta(seconds=30)) as b: TestTimestampModel.batch(b).create(count=1) - "USING TIMESTAMP".should.be.within(m.call_args[0][0].query_string) + self.assertIn("USING TIMESTAMP", m.call_args[0][0].query_string) class CreateWithTimestampTest(BaseTimestampTest): @@ -56,14 +56,14 @@ def test_batch(self): query = m.call_args[0][0].query_string - query.should.match(r"INSERT.*USING TIMESTAMP") - query.should_not.match(r"TIMESTAMP.*INSERT") + self.assertRegex(query, r"INSERT.*USING TIMESTAMP") + self.assertNotRegex(query, r"TIMESTAMP.*INSERT") def test_timestamp_not_included_on_normal_create(self): with mock.patch.object(self.session, "execute") as m: TestTimestampModel.create(count=2) - "USING TIMESTAMP".shouldnt.be.within(m.call_args[0][0].query_string) + self.assertNotIn("USING TIMESTAMP", m.call_args[0][0].query_string) def test_timestamp_is_set_on_model_queryset(self): delta = timedelta(seconds=30) @@ -85,7 +85,7 @@ def test_non_batch_syntax_unit(self): query = m.call_args[0][0].query_string - "USING TIMESTAMP".should.be.within(query) + self.assertIn("USING TIMESTAMP", query) def test_non_batch_syntax_with_ttl_unit(self): @@ -95,7 +95,7 @@ def test_non_batch_syntax_with_ttl_unit(self): query = m.call_args[0][0].query_string - query.should.match(r"USING TTL \d* AND TIMESTAMP") + self.assertRegex(query, r"USING TTL \d* AND TIMESTAMP") class UpdateWithTimestampTest(BaseTimestampTest): @@ -109,7 +109,7 @@ def test_instance_update_includes_timestamp_in_query(self): with mock.patch.object(self.session, "execute") as m: self.instance.timestamp(timedelta(seconds=30)).update(count=2) - "USING TIMESTAMP".should.be.within(m.call_args[0][0].query_string) + self.assertIn("USING TIMESTAMP", m.call_args[0][0].query_string) def test_instance_update_in_batch(self): with mock.patch.object(self.session, "execute") as m: @@ -117,7 +117,7 @@ def test_instance_update_in_batch(self): self.instance.batch(b).timestamp(timedelta(seconds=30)).update(count=2) query = m.call_args[0][0].query_string - "USING TIMESTAMP".should.be.within(query) + self.assertIn("USING TIMESTAMP", query) class DeleteWithTimestampTest(BaseTimestampTest): From a0d3b0e2ae59dddc6fdfc42e1b19afd247f2ad64 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Fri, 4 Jul 2025 00:04:47 +0200 Subject: [PATCH 4/4] remove loose dependency --- setup.py | 2 +- test-requirements.txt | 1 - tests/integration/cqlengine/test_timestamp.py | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 79fda90eac..03aa7b35ee 100644 --- a/setup.py +++ b/setup.py @@ -413,7 +413,7 @@ def run_setup(extensions): include_package_data=True, install_requires=dependencies, extras_require=_EXTRAS_REQUIRE, - tests_require=['pytest', 'PyYAML', 'pytz', 'sure'], + tests_require=['pytest', 'PyYAML', 'pytz'], classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', diff --git a/test-requirements.txt b/test-requirements.txt index 6499e20841..9788ea65cc 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,7 +3,6 @@ scales pytest ccm>=2.1.2 pytz -sure pure-sasl twisted[tls] gevent diff --git a/tests/integration/cqlengine/test_timestamp.py b/tests/integration/cqlengine/test_timestamp.py index 4a193f4888..a1a711fc67 100644 --- a/tests/integration/cqlengine/test_timestamp.py +++ b/tests/integration/cqlengine/test_timestamp.py @@ -14,7 +14,6 @@ from datetime import timedelta, datetime from unittest import mock -import sure from uuid import uuid4 from cassandra.cqlengine import columns