def test_incompatibile_options(self):
     opts = self._defaultOpts(url="thing", ccg="thing")
     with self.assertRaises(CommandError):
         Command().validate_options(**opts)
     opts = self._defaultOpts(url="thing", practice="thing")
     with self.assertRaises(CommandError):
         Command().validate_options(**opts)
    def test_options_depended_on_by_recipient_email(self):
        opts = self._defaultOpts(url="thing")
        with self.assertRaises(CommandError):
            Command().validate_options(**opts)
        opts = self._defaultOpts(ccg="thing")
        with self.assertRaises(CommandError):
            Command().validate_options(**opts)
        opts = self._defaultOpts(practice="thing")
        with self.assertRaises(CommandError):
            Command().validate_options(**opts)

        opts = self._defaultOpts(practice="thing", recipient_email="thing")
        Command().validate_options(**opts)
 def test_get_search_bookmarks_without_options(self):
     bookmarks = Command().get_search_bookmarks(self.now_month,
                                                recipient_email=None)
     active = all([x.user.is_active for x in bookmarks])
     self.assertEqual(len(bookmarks), 1)
     self.assertEqual(bookmarks[0].url, "foo")
     self.assertTrue(active)
 def test_get_org_bookmarks_with_skip_file(self):
     skip_file = ('frontend/tests/fixtures/commands/'
                  'skip_alerts_recipients.txt')
     bookmarks = Command().get_org_bookmarks(self.now_month,
                                             skip_email_file=skip_file,
                                             recipient_email=None,
                                             recipient_email_file=None)
     self.assertEqual(len(bookmarks), 0)
 def test_get_org_bookmarks_without_options(self):
     bookmarks = Command().get_org_bookmarks(self.now_month,
                                             recipient_email=None,
                                             recipient_email_file=None,
                                             skip_email_file=None)
     active = all([x.user.is_active for x in bookmarks])
     self.assertEqual(len(bookmarks), 2)
     self.assertTrue(active)
 def test_get_search_bookmarks_with_options(self):
     bookmarks = Command().get_search_bookmarks(
         recipient_email='*****@*****.**',
         url='frob', search_name='baz')
     self.assertEqual(len(bookmarks), 1)
     self.assertEqual(bookmarks[0].user.email, '*****@*****.**')
     self.assertTrue(bookmarks[0].user.profile.key)
     self.assertTrue(bookmarks[0].user.id)
     self.assertEqual(bookmarks[0].url, 'frob')
 def test_get_search_bookmarks_with_options(self):
     bookmarks = Command().get_search_bookmarks(
         self.now_month, recipient_email="*****@*****.**", url="frob", search_name="baz"
     )
     self.assertEqual(len(bookmarks), 1)
     self.assertEqual(bookmarks[0].user.email, "*****@*****.**")
     self.assertTrue(bookmarks[0].user.profile.key)
     self.assertTrue(bookmarks[0].user.id)
     self.assertEqual(bookmarks[0].url, "frob")
 def test_get_org_bookmarks_with_options(self):
     bookmarks = Command().get_org_bookmarks(recipient_email='*****@*****.**',
                                             ccg='03V',
                                             practice='P87629')
     self.assertEqual(len(bookmarks), 1)
     self.assertEqual(bookmarks[0].user.email, '*****@*****.**')
     self.assertTrue(bookmarks[0].user.profile.key)
     self.assertTrue(bookmarks[0].user.id)
     self.assertEqual(bookmarks[0].pct.code, '03V')
     self.assertEqual(bookmarks[0].practice.code, 'P87629')
 def test_get_org_bookmarks_with_test_options(self):
     bookmarks = Command().get_org_bookmarks(
         self.now_month,
         recipient_email="*****@*****.**",
         ccg="03V",
         practice="P87629",
         recipient_email_file=None,
         skip_email_file=None,
     )
     self.assertEqual(len(bookmarks), 1)
     self.assertEqual(bookmarks[0].user.email, "*****@*****.**")
     self.assertTrue(bookmarks[0].user.profile.key)
     self.assertTrue(bookmarks[0].user.id)
     self.assertEqual(bookmarks[0].pct.code, "03V")
     self.assertEqual(bookmarks[0].practice.code, "P87629")