Skip to content

remove stale dependency on "sure" #1227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 0 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ scales
pytest
ccm>=2.1.2
pytz
sure
pure-sasl
twisted[tls]
gevent
Expand Down
37 changes: 18 additions & 19 deletions tests/integration/cqlengine/test_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from datetime import timedelta, datetime
from unittest import mock
import sure
from uuid import uuid4

from cassandra.cqlengine import columns
Expand Down Expand Up @@ -44,7 +43,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):
Expand All @@ -56,27 +55,27 @@ 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)
tmp = TestTimestampModel.timestamp(delta)
tmp._timestamp.should.equal(delta)
self.assertEqual(tmp._timestamp, delta)

def test_non_batch_syntax_integration(self):
tmp = TestTimestampModel.timestamp(timedelta(seconds=30)).create(count=1)
tmp.should.be.ok
self.assertIsNotNone(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
self.assertIsNotNone(tmp)

def test_non_batch_syntax_unit(self):

Expand All @@ -85,7 +84,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):

Expand All @@ -95,7 +94,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):
Expand All @@ -109,15 +108,15 @@ 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:
with BatchQuery() as b:
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):
Expand All @@ -129,7 +128,7 @@ def test_non_batch(self):
uid = uuid4()
tmp = TestTimestampModel.create(id=uid, count=1)

TestTimestampModel.get(id=uid).should.be.ok
self.assertIsNotNone(TestTimestampModel.get(id=uid))

tmp.timestamp(timedelta(seconds=5)).delete()

Expand All @@ -143,15 +142,15 @@ def test_non_batch(self):

# calling .timestamp sets the TS on the model
tmp.timestamp(timedelta(seconds=5))
tmp._timestamp.should.be.ok
self.assertIsNotNone(tmp._timestamp)

# calling save clears the set timestamp
tmp.save()
tmp._timestamp.shouldnt.be.ok
self.assertIsNone(tmp._timestamp)

tmp.timestamp(timedelta(seconds=5))
tmp.update()
tmp._timestamp.shouldnt.be.ok
self.assertIsNone(tmp._timestamp)

def test_blind_delete(self):
"""
Expand All @@ -160,7 +159,7 @@ def test_blind_delete(self):
uid = uuid4()
tmp = TestTimestampModel.create(id=uid, count=1)

TestTimestampModel.get(id=uid).should.be.ok
self.assertIsNotNone(TestTimestampModel.get(id=uid))

TestTimestampModel.objects(id=uid).timestamp(timedelta(seconds=5)).delete()

Expand All @@ -179,7 +178,7 @@ def test_blind_delete_with_datetime(self):
uid = uuid4()
tmp = TestTimestampModel.create(id=uid, count=1)

TestTimestampModel.get(id=uid).should.be.ok
self.assertIsNotNone(TestTimestampModel.get(id=uid))

plus_five_seconds = datetime.now() + timedelta(seconds=5)

Expand All @@ -197,7 +196,7 @@ def test_delete_in_the_past(self):
uid = uuid4()
tmp = TestTimestampModel.create(id=uid, count=1)

TestTimestampModel.get(id=uid).should.be.ok
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()
Expand Down