Created
June 10, 2013 22:43
-
-
Save michelp/5753094 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| index 077eefb..fe325e0 100644 | |
| --- a/mom/model/user.py | |
| +++ b/mom/model/user.py | |
| @@ -354,6 +354,13 @@ class User(Base): | |
| quality, images_only) | |
| return docs | |
| + def discover_from_terms(self, url, start_datetime=None, end_datetime=None, | |
| + num_docs=None, quality=None, images_only=False): | |
| + docs = env.zrpc_discover.discover_url( | |
| + url, self.primary_org_id, start_datetime, end_datetime, num_docs, | |
| + quality, images_only) | |
| + return docs | |
| + | |
| Index( | |
| 'ix_users_email_primary_org_id', User.email, User.primary_org_id, | |
| diff --git a/tests/functional/test_model_user.py b/tests/functional/test_model_user.py | |
| index 62b27b8..ba88d75 100644 | |
| --- a/tests/functional/test_model_user.py | |
| +++ b/tests/functional/test_model_user.py | |
| @@ -754,6 +754,31 @@ class TestUser(DBTestCase): | |
| num_docs=num_docs, quality=quality, images_only=images_only), | |
| ['doc1', 'doc2']) | |
| + def test_discover_from_terms(self): | |
| + org = Org() | |
| + user1 = User() | |
| + user1.primary_org = org | |
| + self.session.add(org) | |
| + self.session.add(user1) | |
| + self.session.commit() | |
| + terms = 'monkey chicken popsickle' | |
| + start_datetime = datetime(1066, 12, 31) | |
| + end_datetime = datetime(2010, 01, 01) | |
| + num_docs = 13 | |
| + quality = 99 | |
| + images_only = True | |
| + env.zrpc_discover = flexmock(discover_url=None) | |
| + (flexmock(env.zrpc_discover).should_receive('discover_from_terms').once | |
| + .with_args( | |
| + terms, org.id, start_datetime, end_datetime, num_docs, quality, | |
| + images_only) | |
| + .and_return(['doc1', 'doc2'])) | |
| + self.assertEquals( | |
| + user1.discover_from_terms( | |
| + terms, start_datetime=start_datetime, end_datetime=end_datetime, | |
| + num_docs=num_docs, quality=quality, images_only=images_only), | |
| + ['doc1', 'doc2']) | |
| + | |
| def test_subscribe_to_tag_bundles_no_changes(self): | |
| org = Org() | |
| org.uses_security_tags = True | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment