def test_fileify_logging_when_wrong_version_pk(self, mock_logger):
     self.assertFalse(Version.objects.filter(pk=345343).exists())
     tasks.fileify(version_pk=345343,
                   commit=None,
                   build=1,
                   search_ranking={})
     mock_logger.warning.assert_called_with(
         "Version not found for given kwargs. {'pk': 345343}")
 def handle(self, *args, **kwargs):
     '''
     Build/index all versions or a single project's version
     '''
     # Delete all existing as a cleanup for any deleted projects.
     #ImportedFile.objects.all().delete()
     if getattr(settings, 'INDEX_ONLY_LATEST', True):
         queryset = Version.objects.filter(slug='latst')
     else:
         queryset = Version.objects.public()
     for v in queryset:
         log.info("Building files for %s" % v)
         try:
             tasks.fileify(v)
         except Exception:
             log.error('Build failed for %s' % v, exc_info=True)