<commit_before>require_relative "test_helper"

describe PhotoList do
  describe "creating a photolist from an array of photos" do
    it "order the passed photos by the added_at time and sets them to the photos attribute" do
      sorted_fixtures = Fixtures.photos.values.sort_by { |photo| photo.added_at }
      assert_equal sorted_fixtures, PhotoList.new(Fixtures.photos.values).photos
    end
  end

  describe "filtering" do
    it "returns a new PhotoList containing only the photos with the passed tag, sorted by added_at date" do
      sorted_fixtures = Fixtures.juggling_photos.values.sort_by { |photo| photo.added_at }
      assert_equal sorted_fixtures, PhotoList.new(Fixtures.photos.values).with_tag("juggling").photos
    end
  end

  it "returns the associated photo when given a UUID" do
    photo = Fixtures.photos[:kayak]
    assert_equal photo, PhotoList.new(Fixtures.photos.values).find(photo.uuid)
  end
end<commit_msg>Refactor the PhotoList test<commit_after>require_relative "test_helper"

describe PhotoList do
  let(:photolist) { PhotoList.new(Fixtures.photos.values) }
  let(:sorted_fixtures) do
    photolist.photos.sort_by { |photo| photo.added_at }
  end

  describe "creating a photolist from an array of photos" do
    it "order the passed photos by the added_at time and sets them to the photos attribute" do
      assert_equal sorted_fixtures, photolist.photos
    end
  end

  describe "#with_tag" do
    let(:tag) { "juggling" }
    let(:sorted_fixtures) do
      Fixtures.juggling_photos.values.sort_by { |photo| photo.added_at }
    end

    it "returns a new PhotoList containing only photos with the passed tag" do
      photolist.with_tag(tag).photos.each do |photo|
        assert photo.tags.include?(tag), "#{photo} doesn't include tag '#{tag}'"
      end
    end

    it "sortes the photolist by added_at date" do
      assert_equal sorted_fixtures, photolist.with_tag(tag).photos
    end
  end

  describe "#find" do
    let(:photo) { Fixtures.photos[:kayak] }

    it "returns the associated photo when given a UUID" do
      assert_equal photo, photolist.find(photo.uuid)
    end
  end
end
{'fraction_non_alphanumeric': 0.0806375996249414, 'fraction_numerical': 0.0, 'mean_word_length': 3.7422222222222223, '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': '1843200', 'n_tokens_mistral': 688, 'n_tokens_neox': 657, 'n_words': 205}