<commit_before>from __future__ import absolute_import, division, print_function

import pytest
from i19.command_line.screen import I19Screen

def test_i19screen_command_line_help_does_not_crash():
  I19Screen().run('')

def test_i19screen(regression_data, run_in_tmpdir):
  data_dir = regression_data('X4_wide').strpath

  I19Screen().run([data_dir])

  logfile = run_in_tmpdir.join('i19.screen.log').read()

  assert 'i19.screen successfully completed' in logfile
  assert 'photon incidence rate is outside the linear response region' in logfile
<commit_msg>Add test for template parsing<commit_after>from __future__ import absolute_import, division, print_function

import mock
import pytest
from i19.command_line.screen import I19Screen

def test_i19screen_command_line_help_does_not_crash():
  I19Screen().run('')

def test_i19screen(regression_data, run_in_tmpdir):
  data_dir = regression_data('X4_wide').strpath

  I19Screen().run([data_dir])

  logfile = run_in_tmpdir.join('i19.screen.log').read()

  assert 'i19.screen successfully completed' in logfile
  assert 'photon incidence rate is outside the linear response region' in logfile

@mock.patch('i19.command_line.screen.procrunner')
def test_i19screen_calls(procrunner, run_in_tmpdir):
  procrunner.run.return_value = {'exitcode': 0, 'runtime': 0}
  files = 'dataset.cbf:1:100'

  with pytest.raises(SystemExit):
    I19Screen().run([files])

  procrunner.run.assert_called_once_with([
          'dials.import',
          'input.template=dataset.cbf',
          'geometry.scan.image_range=1,100',
          'geometry.scan.extrapolate_scan=True'
      ],
      debug=False,
      print_stdout=False,
  )

{'fraction_non_alphanumeric': 0.10497900419916016, 'fraction_numerical': 0.029994001199760048, 'mean_word_length': 5.247191011235955, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3480177', 'n_tokens_mistral': 584, 'n_tokens_neox': 546, 'n_words': 109}