old_contents: import app
  from datetime import datetime
  import pytest
  
  
  def log_generator():
      yield '2017/01/01 15:13:06 Seclab listener started\n'
      yield '2017/01/01 15:13:07 Received request: close\n'
      yield '2017/01/01 15:13:08 Received request: open\n'
      yield '2017/01/01 15:13:09 Received request: open\n'
      yield '2017/01/01 15:13:10 Received request: close\n'
      yield '2017/01/01 15:13:11 Received request: open\n'
      yield '2017/01/01 15:13:12 Received request: close\n'
      yield '2017/01/01 15:13:13 Received request: close\n'
      yield '2017/01/01 15:13:14 Received request: open\n'
  
  
  @pytest.fixture
  def logfile():
      return log_generator()
  
  
  def test_iter_ranges(logfile):
      ranges = list(app.iter_ranges(logfile))
      assert ranges == [
          (datetime(2017, 1, 1, 15, 13, 8), datetime(2017, 1, 1, 15, 13, 10)),
          (datetime(2017, 1, 1, 15, 13, 11), datetime(2017, 1, 1, 15, 13, 12)),
      ]
  
  
  def test_count_total_hours():
      totals = app.count_total_hours(datetime(2017, 1, 1), datetime(2017, 1, 1))
      assert totals == [0] * (6 * 24) + [1] + [0] * 23
  
new_contents: import app
  from datetime import datetime
  import pytest
  
  
  def log_generator():
      yield '2017/01/01 15:13:06 Seclab listener started\n'
      yield '2017/01/01 15:13:07 Received request: close\n'
      yield '2017/01/01 15:13:08 Received request: open\n'
      yield '2017/01/01 15:13:09 Received request: open\n'
      yield '2017/01/01 15:13:10 Received request: close\n'
      yield '2017/01/01 15:13:11 Received request: open\n'
      yield '2017/01/01 15:13:12 Received request: close\n'
      yield '2017/01/01 15:13:13 Received request: close\n'
      yield '2017/01/01 15:13:14 Received request: open\n'
  
  
  @pytest.fixture
  def logfile():
      return log_generator()
  
  
  def test_iter_ranges(logfile):
      ranges = list(app.iter_ranges(logfile))
      assert ranges == [
          (datetime(2017, 1, 1, 15, 13, 8), datetime(2017, 1, 1, 15, 13, 10)),
          (datetime(2017, 1, 1, 15, 13, 11), datetime(2017, 1, 1, 15, 13, 12)),
      ]
  
  
  def test_count_total_hours_empty():
      assert app.count_total_hours(None, None) == [0] * (24 * 7)
  
  
  def test_count_total_hours():
      totals = app.count_total_hours(datetime(2017, 1, 1), datetime(2017, 1, 1))
      assert totals == [0] * (6 * 24) + [1] + [0] * 23
  
subject: Add a test for empty count_total_hours