def test_weekly_downloads_flagged(self): eq_(self.get_webapp().weekly_downloads, 0) self.add_install() self.add_install(user=UserProfile.objects.get(pk=10482), created=datetime.today() - timedelta(days=2)) flag_reindexing_mkt('new', 'old', 'alias') try: # Should fail. self.assertRaises(CommandError, update_weekly_downloads) eq_(self.get_webapp().weekly_downloads, 0) # Should work with the environ flag. os.environ['FORCE_INDEXING'] = '1' update_weekly_downloads() finally: unflag_reindexing_mkt() del os.environ['FORCE_INDEXING'] eq_(self.get_webapp().weekly_downloads, 2)
def flag_database(new_index, old_index, alias): """Flags the database to indicate that the reindexing has started.""" sys.stdout.write('Flagging the database to start the reindexation') flag_reindexing_mkt(new_index=new_index, old_index=old_index, alias=alias) time.sleep(5) # Give celeryd some time to flag the DB.