def refresh(cls, doctype='webapp', timesleep=0): post_request_task._send_tasks() index = settings.ES_INDEXES[doctype] try: cls.es.indices.refresh(index=index) except elasticsearch.NotFoundError as e: print "Could not refresh index '%s': %s" % (index, e)
def setUp(self): super(TestDownload, self).setUp() super(TestDownload, self).setup_files() self.url = reverse("downloads.file", args=[self.file.pk]) # Don't count things left over from setup, so assertNumQueries will be # accurate. _send_tasks()
def setUp(self): super(TestDownload, self).setUp() super(TestDownload, self).setup_files() self.url = reverse('downloads.file', args=[self.file.pk]) # Don't count things left over from setup, so assertNumQueries will be # accurate. _send_tasks()
def test_preview_size(self): name = 'non-animated.gif' form = forms.PreviewForm({'upload_hash': name, 'position': 1}) with private_storage.open(os.path.join(self.dest, name), 'wb') as f: copyfileobj(open(get_image_path(name)), f) assert form.is_valid(), form.errors form.save(self.addon) # Since the task is a post-request-task and we are outside the normal # request-response cycle, manually send the tasks. post_request_task._send_tasks() eq_(self.addon.previews.all()[0].sizes, {u'image': [250, 297], u'thumbnail': [100, 119]})
def test_preview_size(self): name = 'non-animated.gif' form = forms.PreviewForm({'upload_hash': name, 'position': 1}) copy_stored_file( get_image_path(name), os.path.join(self.dest, name), src_storage=local_storage, dst_storage=private_storage) assert form.is_valid(), form.errors form.save(self.webapp) # Since the task is a post-request-task and we are outside the normal # request-response cycle, manually send the tasks. post_request_task._send_tasks() eq_(self.webapp.previews.all()[0].sizes, {u'image': [250, 297], u'thumbnail': [100, 119]})
def setUp(self): self.app = Webapp.objects.get(pk=337141) self.app.update(is_packaged=True) # Create a fake package to go along with the app. self.latest_file = self.app.get_latest_file() with private_storage.open(self.latest_file.file_path, mode='w') as package: test_package = zipfile.ZipFile(package, 'w') test_package.writestr('manifest.webapp', 'foobar') test_package.close() self.latest_file.update(hash=self.latest_file.generate_hash()) self.url = self.app.get_manifest_url() # Don't count things left over from setup, so assertNumQueries will be # accurate. _send_tasks()
def refresh(cls, doctypes=None): """ Force an immediate refresh for the index(es) holding the given doctype(s) in ES. Both a string corresponding to a single doctypes or a list of multiple doctypes are accepted. If there are tasks in the post_request_task queue, they are processed first. """ post_request_task._send_tasks() if doctypes: if not isinstance(doctypes, (list, tuple)): doctypes = [doctypes] indexes = [settings.ES_INDEXES[doctype] for doctype in doctypes] try: cls.es.indices.refresh(index=indexes) except elasticsearch.NotFoundError as e: print "Could not refresh indexes '%s': %s" % (indexes, e)
def tearDown(self): post_request_task._send_tasks() super(ESTestCase, self).tearDown()
def tearDown(self): post_request_task._send_tasks()
def refresh(cls, index="webapp", timesleep=0): post_request_task._send_tasks() cls.es.refresh(settings.ES_INDEXES[index])
def refresh(cls, index='default', timesleep=0): post_request_task._send_tasks() cls.es.refresh(settings.ES_INDEXES[index], timesleep=timesleep)