Beispiel #1
0
 def test_backfill_daily_with_site_domain(self):
     """Test that proper site id gets passed to task func when passing integer."""
     SiteFactory.reset_sequence(0)
     site2 = SiteFactory()  # site-0.example.com
     with mock.patch(self.PLAIN_PATH) as mock_populate:
         call_command('backfill_figures_daily_metrics',
                      site="site-0.example.com",
                      no_delay=True)
         assert mock_populate.called_with(site_id=2)
Beispiel #2
0
 def test_get_side_ids(self, site, expected_result):
     """Test that get_site_ids will return the correct Site id if passed that id
     or the corresponding Site's domain, will return all Site ids if none passed, 
     and will return an empty list if a non-existing Site id or domain passed
     """
     # Site table will have an existing example.com Site as well as whatever we
     # create w/ SiteFactory, due to data migration
     example_site = Site.objects.get(domain='example.com')
     SiteFactory.reset_sequence(0)
     site1 = SiteFactory()  # site-0.example.com
     site2 = SiteFactory()  # site-1.example.com
     with mock.patch('figures.management.base.get_sites') as mock_get_sites:
         mock_get_sites.return_value = [example_site, site1, site2]
         site_ids = BaseBackfillCommand().get_site_ids(site)
         assert site_ids == expected_result