<commit_before>defmodule PhxOembed.SiteTest do
  use PhxOembed.ModelCase
  import PhxOembed.Factory

  alias PhxOembed.Site

  @valid_attrs %{domain: "example.com", protocol: "https"}
  @invalid_attrs %{}

  test "changeset with valid attributes" do
    changeset = Site.changeset %Site{}, @valid_attrs
    assert changeset.valid?
  end

  test "changeset with invalid attributes" do
    changeset = Site.changeset %Site{}, @invalid_attrs
    refute changeset.valid?
  end

  test "protocol default values" do
    site = Repo.insert! %Site{domain: "example.com"}
    site = Repo.get Site, site.id
    assert site.protocol == "http"
  end

  test "cards relationship" do
    site = create(:site)
    create(:card, site: site)
    create(:card, site: site)
    create(:card)

    site = Site
    |> Repo.get(site.id)
    |> Repo.preload(:cards)

    assert Enum.count(site.cards) == 2
  end
end<commit_msg>improve site model test<commit_after>defmodule PhxOembed.SiteTest do
  use PhxOembed.ModelCase
  import PhxOembed.Factory

  alias PhxOembed.Site

  @valid_attrs %{domain: "example.com", protocol: "https"}
  @invalid_attrs %{}

  test "changeset with valid attributes" do
    changeset = Site.changeset %Site{}, @valid_attrs
    assert changeset.valid?
  end

  test "changeset with invalid attributes" do
    changeset = Site.changeset %Site{}, @invalid_attrs
    refute changeset.valid?
  end

  test "default protocol" do
    site = create(:site)
    assert site.protocol == "http"
  end

  test "cards relationship" do
    site = create(:site)
    create(:card, site: site)
    create(:card, site: site)
    create(:card)

    site = Site
    |> Repo.get(site.id)
    |> Repo.preload(:cards)

    assert Enum.count(site.cards) == 2
  end
end
{'fraction_non_alphanumeric': 0.11320754716981132, 'fraction_numerical': 0.0011435105774728416, 'mean_word_length': 3.4416243654822334, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '891997', 'n_tokens_mistral': 589, 'n_tokens_neox': 562, 'n_words': 155}