@pytest.mark.cmd
@pytest.mark.django_db
@pytest.mark.skipif((sys.platform == 'win32'), reason='No Elasticsearch in Windows testing')
def test_update_tmserver_files(capfd, settings, tmpdir):
 settings.POOTLE_TM_SERVER = {'external': {'ENGINE': 'pootle.core.search.backends.ElasticSearchBackend', 'HOST': 'localhost', 'PORT': 9200, 'INDEX_NAME': 'translations-external'}}
 p = tmpdir.mkdir('tmserver_files').join('tutorial.po')
 p.write('msgid "rest"\nmsgstr "test"\n           ')
 with pytest.raises(CommandError) as e:
  call_command('update_tmserver', '--tm=external', '--display-name=Test', os.path.join(p.dirname, p.basename))
 assert ('Unable to determine target language' in str(e))
 call_command('update_tmserver', '--tm=external', '--display-name=Test', '--target-language=af', os.path.join(p.dirname, p.basename))
 (out, err) = capfd.readouterr()
 assert ('1 translations to index' in out)

@ pytest . mark . cmd @ pytest . mark . django_db @ pytest . mark . skipif ( ( sys . platform == 'win32' ) , reason = 'No Elasticsearch in Windows testing' ) def test_update_tmserver_files ( capfd , settings , tmpdir ) : settings . POOTLE_TM_SERVER = { 'external' : { 'ENGINE' : 'pootle.core.search.backends.ElasticSearchBackend' , 'HOST' : 'localhost' , 'PORT' : 9200 , 'INDEX_NAME' : 'translations-external' } } p = tmpdir . mkdir ( 'tmserver_files' ) . join ( 'tutorial.po' ) p . write ( 'msgid "rest"\nmsgstr "test"\n           ' ) with pytest . raises ( CommandError ) as e : call_command ( 'update_tmserver' , '--tm=external' , '--display-name=Test' , os . path . join ( p . dirname , p . basename ) ) assert ( 'Unable to determine target language' in str ( e ) ) call_command ( 'update_tmserver' , '--tm=external' , '--display-name=Test' , '--target-language=af' , os . path . join ( p . dirname , p . basename ) ) ( out , err ) = capfd . readouterr ( ) assert ( '1 translations to index' in out )
load tm from files .