mirror of
https://github.com/wallabag/wallabag.git
synced 2025-07-22 17:18:37 +00:00
Add more tests
And ability to define how many messages can be hanle by the redis worker before stopping (usefull for tests)
This commit is contained in:
parent
7d862f83b9
commit
015c7a8359
9 changed files with 133 additions and 3 deletions
|
@ -5,6 +5,7 @@ namespace Wallabag\ImportBundle\Command;
|
|||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Config\Definition\Exception\Exception;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Simpleue\Worker\QueueWorker;
|
||||
|
@ -17,6 +18,7 @@ class RedisWorkerCommand extends ContainerAwareCommand
|
|||
->setName('wallabag:import:redis-worker')
|
||||
->setDescription('Launch Redis worker')
|
||||
->addArgument('serviceName', InputArgument::REQUIRED, 'Service to use: wallabag_v1, wallabag_v2, pocket or readability')
|
||||
->addOption('maxIterations', '', InputOption::VALUE_OPTIONAL, 'Number of iterations before stoping', false)
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -33,7 +35,8 @@ class RedisWorkerCommand extends ContainerAwareCommand
|
|||
|
||||
$worker = new QueueWorker(
|
||||
$this->getContainer()->get('wallabag_import.queue.redis.'.$serviceName),
|
||||
$this->getContainer()->get('wallabag_import.consumer.redis.'.$serviceName)
|
||||
$this->getContainer()->get('wallabag_import.consumer.redis.'.$serviceName),
|
||||
$input->getOption('maxIterations')
|
||||
);
|
||||
|
||||
$worker->start();
|
||||
|
|
|
@ -31,7 +31,7 @@ class ReadabilityController extends Controller
|
|||
$markAsRead = $form->get('mark_as_read')->getData();
|
||||
$name = 'readability_'.$this->getUser()->getId().'.json';
|
||||
|
||||
if (in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
|
||||
if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
|
||||
$res = $readability
|
||||
->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
|
||||
->setMarkAsRead($markAsRead)
|
||||
|
|
|
@ -45,7 +45,7 @@ abstract class WallabagController extends Controller
|
|||
$markAsRead = $form->get('mark_as_read')->getData();
|
||||
$name = $this->getUser()->getId().'.json';
|
||||
|
||||
if (in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
|
||||
if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
|
||||
$res = $wallabag
|
||||
->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
|
||||
->setMarkAsRead($markAsRead)
|
||||
|
|
|
@ -15,6 +15,7 @@ class UploadImportType extends AbstractType
|
|||
$builder
|
||||
->add('file', FileType::class, [
|
||||
'label' => 'import.form.file_label',
|
||||
'required' => true,
|
||||
])
|
||||
->add('mark_as_read', CheckboxType::class, [
|
||||
'label' => 'import.form.mark_as_read_label',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue