-
Notifications
You must be signed in to change notification settings - Fork 130
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
fix disabling of distributed lock (#2) #109
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,24 @@ def test_lock_timeout(self): | |
def test_key_prefix_default(self): | ||
self.assertEqual(self.conf.key_prefix, 'redbeat:') | ||
|
||
def test_lock_key_default(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To check my understanding, is this the same test as in https://github.com/sibson/redbeat/pull/109/files#diff-423890b7e3c2aa4791f9e203b7f194cbR45? If so I don't think we need to remove it, being explicit here is great. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this tests the same thing and was added to be explicit. |
||
self.assertTrue("REDBEAT_LOCK_KEY" not in self.app.conf.keys()) | ||
self.assertTrue("redbeat_lock_key" not in self.app.conf.keys()) | ||
self.conf = RedBeatConfig(self.app) | ||
self.assertEqual(self.conf.lock_key, 'redbeat::lock') | ||
|
||
def test_disable_lock_key_4(self): | ||
self.app.conf.redbeat_lock_key = None | ||
self.assertTrue("redbeat_lock_key" in self.app.conf.keys()) | ||
self.conf = RedBeatConfig(self.app) | ||
self.assertEqual(self.conf.lock_key, None) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should there be a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup. Will add the skipif There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've dropped celery 3 support so this maybe simpler to fix. |
||
def test_disable_lock_key_3(self): | ||
self.app.conf.REDBEAT_LOCK_KEY = None | ||
self.assertTrue("REDBEAT_LOCK_KEY" in self.app.conf.keys()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this necessary? It seems to be testing the assignment we did in the previous line or am I missing some behind the scenes magic? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yes. I'll remove this. |
||
self.conf = RedBeatConfig(self.app) | ||
self.assertEqual(self.conf.lock_key, None) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should there be a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup. I'll add a test for a custom lock key. |
||
def test_other_keys(self): | ||
self.assertEqual(self.conf.schedule_key, self.conf.key_prefix + ':schedule') | ||
self.assertEqual(self.conf.statics_key, self.conf.key_prefix + ':statics') | ||
|
@@ -45,14 +63,14 @@ def test_schedule(self): | |
|
||
@pytest.mark.skipif(CELERY_4_OR_GREATER, reason="requires Celery < 4.x") | ||
@mock.patch('warnings.warn') | ||
def test_either_or_3(self, warn_mock): | ||
broker_url = self.conf.either_or('BROKER_URL') | ||
def test_key_has_value_or_3(self, warn_mock): | ||
broker_url = self.conf.key_has_value_or('BROKER_URL') | ||
self.assertFalse(warn_mock.called) | ||
self.assertEqual(broker_url, self.app.conf.BROKER_URL) | ||
|
||
@pytest.mark.skipif(not CELERY_4_OR_GREATER, reason="requires Celery >= 4.x") | ||
@mock.patch('warnings.warn') | ||
def test_either_or_4(self, warn_mock): | ||
broker_url = self.conf.either_or('BROKER_URL') | ||
def test_key_has_value_or_4(self, warn_mock): | ||
broker_url = self.conf.key_has_value_or('BROKER_URL') | ||
self.assertTrue(warn_mock.called) | ||
self.assertEqual(broker_url, self.app.conf.broker_url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be tests for this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely. I'll add one.