<commit_before>require 'helper'

class TestStoreMetaData < Test::Pwl::TestCase
  # when comparing timestamps, allow not more than this difference in seconds
  TIMESTAMP_PRECISION = 1

  def test_created
    assert_equal(nil, store.last_accessed)
    assert_in_delta(DateTime.now.to_time.to_i, store.created.to_time.to_i, TIMESTAMP_PRECISION)
  end

  def test_last_accessed
    assert_equal(nil, store.last_accessed)
    store.put('foobar', 'barfoot')
    assert_equal(nil, store.last_accessed)
    store.get('foobar')
    assert_in_delta(DateTime.now.to_time.to_i, store.last_accessed.to_time.to_i, TIMESTAMP_PRECISION)
  end

  def test_last_accessed_nonexisting
    assert_equal(nil, store.last_accessed)
    assert_raise Pwl::Store::KeyNotFoundError do
      store.get('foobar')
    end

    # Make sure a failed read is not counted as last_accessed
    assert_equal(nil, store.last_accessed)
  end

  def test_last_modified
    assert_equal(nil, store.last_modified)
    store.put('foobar', 'barfoot')
    assert_in_delta(DateTime.now.to_time.to_i, store.last_modified.to_time.to_i, TIMESTAMP_PRECISION)
  end
end<commit_msg>Compare whole date instead of int timestamps<commit_after>require 'helper'

class TestStoreMetaData < Test::Pwl::TestCase
  # when comparing timestamps, allow not more than this difference in seconds
  TIMESTAMP_PRECISION = 0.001

  def test_created
    assert_equal(nil, store.last_accessed)
    assert_in_delta(DateTime.now, store.created, TIMESTAMP_PRECISION)
  end

  def test_last_accessed
    assert_equal(nil, store.last_accessed)
    store.put('foobar', 'barfoot')
    assert_equal(nil, store.last_accessed)
    store.get('foobar')
    assert_in_delta(DateTime.now, store.last_accessed, TIMESTAMP_PRECISION)
  end

  def test_last_accessed_nonexisting
    assert_equal(nil, store.last_accessed)
    assert_raise Pwl::Store::KeyNotFoundError do
      store.get('foobar')
    end

    # Make sure a failed read is not counted as last_accessed
    assert_equal(nil, store.last_accessed)
  end

  def test_last_modified
    assert_equal(nil, store.last_modified)
    store.put('foobar', 'barfoot')
    assert_in_delta(DateTime.now, store.last_modified, TIMESTAMP_PRECISION)
  end
end
{'fraction_non_alphanumeric': 0.08344609833107804, 'fraction_numerical': 0.0022552999548940008, 'mean_word_length': 4.746113989637306, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6323274', 'n_tokens_mistral': 781, 'n_tokens_neox': 752, 'n_words': 149}