Exemplo n.º 1
0
    def test_feed_on_protected_site_no_access(self):
        from mydashboard.tests.factories import SeoSiteFactory
        site_id = settings.PROTECTED_SITES.keys()[0]
        site = SeoSiteFactory(pk=site_id, id=site_id)

        url = "http://%s?q=query" % site.domain
        result = update_url_if_protected(url, self.user)
        self.assertEqual(result, url)
Exemplo n.º 2
0
    def test_feed_on_protected_site_no_access(self):
        from seo.tests.factories import SeoSiteFactory
        site_id = settings.PROTECTED_SITES.keys()[0]
        site = SeoSiteFactory(pk=site_id, id=site_id)

        url = "http://%s?q=query" % site.domain
        result = update_url_if_protected(url, self.user)
        self.assertEqual(result, url)
Exemplo n.º 3
0
    def test_feed_on_protected_site_with_access(self):
        from mydashboard.tests.factories import SeoSiteFactory
        site_id = settings.PROTECTED_SITES.keys()[0]
        site = SeoSiteFactory(pk=site_id, id=site_id)
        group_id = settings.PROTECTED_SITES.values()[0][0]
        Group.objects.create(pk=group_id, name='Test Group')

        self.user.groups.add(group_id)
        self.user.save()

        url = "http://%s?q=query" % site.domain
        expected_result = "%s&key=%s" % (url, settings.SEARCH_API_KEY)
        result = update_url_if_protected(url, self.user)
        self.assertEqual(result, expected_result)
Exemplo n.º 4
0
    def test_feed_on_protected_site_with_access(self):
        from seo.tests.factories import SeoSiteFactory
        site_id = settings.PROTECTED_SITES.keys()[0]
        site = SeoSiteFactory(pk=site_id, id=site_id)
        group_id = settings.PROTECTED_SITES.values()[0][0]
        Group.objects.create(pk=group_id, name='Test Group')

        self.user.groups.add(group_id)
        self.user.save()

        url = "http://%s?q=query" % site.domain
        expected_result = "%s&key=%s" % (url, settings.SEARCH_API_KEY)
        result = update_url_if_protected(url, self.user)
        self.assertEqual(result, expected_result)
Exemplo n.º 5
0
 def get_feed_items(self, num_items=None):
     num_items = num_items or self.jobs_per_email
     url_of_feed = url_sort_options(self.feed, self.sort_by, self.frequency,
                                    hasattr(self, 'partnersavedsearch'))
     url_of_feed = update_url_if_protected(url_of_feed, self.user)
     parse_feed_args = {
         'feed_url': url_of_feed,
         'frequency': self.frequency,
         'num_items': num_items,
         'return_items': num_items,
         'last_sent': self.last_sent
     }
     if hasattr(self, 'partnersavedsearch'):
         parse_feed_args['ignore_dates'] = True
     items = parse_feed(**parse_feed_args)
     return items
Exemplo n.º 6
0
 def get_feed_items(self, num_items=None):
     num_items = num_items or self.jobs_per_email
     url_of_feed = url_sort_options(self.feed, self.sort_by, self.frequency,
                                    hasattr(self, 'partnersavedsearch'))
     url_of_feed = update_url_if_protected(url_of_feed, self.user)
     parse_feed_args = {
         'feed_url': url_of_feed,
         'frequency': self.frequency,
         'num_items': num_items,
         'return_items': num_items,
         'last_sent': self.last_sent
     }
     if hasattr(self, 'partnersavedsearch'):
         parse_feed_args['ignore_dates'] = True
     items = parse_feed(**parse_feed_args)
     return items