Projet

Général

Profil

0001-commands-set-locales-in-tenant-commands-51734.patch

Thomas Noël, 05 mars 2021 23:45

Télécharger (2,1 ko)

Voir les différences:

Subject: [PATCH] commands: set locales in tenant commands (#51734)

 tests/test_ctl.py                       | 11 +++++++++++
 wcs/ctl/management/commands/__init__.py |  5 +++++
 2 files changed, 16 insertions(+)
tests/test_ctl.py
427 427
class TestAfterJob(AfterJob):
428 428
    def execute(self):
429 429
        self.foo = WorkflowStatusItem().compute('{{ global_title|default:"FAIL" }}')
430
        self.l10n_month = WorkflowStatusItem().compute('{{ "10/10/2010"|date:"F" }}')
430 431

  
431 432

  
432 433
def test_runjob(pub):
......
448 449
    call_command('runjob', '--domain=example.net', '--job-id=%s' % job.id)
449 450
    assert AfterJob.get(job.id).status == 'completed'
450 451
    assert AfterJob.get(job.id).foo == 'HELLO'
452
    assert AfterJob.get(job.id).l10n_month == 'October'
453

  
454
    pub.cfg['language'] = {'language': 'fr'}
455
    pub.write_cfg()
456
    job = TestAfterJob(label='test2')
457
    job.store()
458
    assert AfterJob.get(job.id).status == 'registered'
459
    call_command('runjob', '--domain=example.net', '--job-id=%s' % job.id)
460
    assert AfterJob.get(job.id).status == 'completed'
461
    assert AfterJob.get(job.id).l10n_month == 'octobre'
451 462

  
452 463

  
453 464
def test_ctl_print_help(capsys):
wcs/ctl/management/commands/__init__.py
28 28
            raise CommandError('unknown tenant')
29 29
        publisher.app_dir = os.path.join(publisher.APP_DIR, domain)
30 30
        publisher.set_config()
31

  
32
        class FakeRequest(object):
33
            language = publisher.get_site_language()
34

  
35
        publisher.install_lang(FakeRequest())
31 36
        publisher.substitutions.feed(publisher)
32 37
        return publisher
33
-