<commit_before>require 'test_helper'

class GroupTest < MiniTest::Test

  def setup
    super
    Huey::Group.stubs(:all).returns([])

    @bulb1 = init_bulb('1', 'Living Room - TV')
    @bulb2 = init_bulb('2', 'Living Room - Fireplace')
    @bulb3 = init_bulb('3', 'Foyer')
    @bulb4 = init_bulb('4', 'Bedroom')

    Huey::Bulb.stubs(:all).returns([@bulb1, @bulb2, @bulb3, @bulb4])
  end

  def test_initializes_group_from_bulbs
    @group = Huey::Group.new(@bulb1, @bulb2, @bulb3)

    assert_equal [@bulb1, @bulb2, @bulb3], @group.bulbs
  end

  def test_initializes_group_from_name
    @group = Huey::Group.new('Living Room')

    assert_equal [@bulb1, @bulb2], @group.bulbs
  end

  def test_initialzes_group_from_names
    @group = Huey::Group.new('Living Room', 'Foyer')

    assert_equal [@bulb1, @bulb2, @bulb3], @group.bulbs
  end

  def test_delegates_save_to_bulbs
    @group = Huey::Group.new(@bulb1, @bulb2, @bulb3)

    [@bulb1, @bulb2, @bulb3].each do |bulb|
      Huey::Request.expects(:put).with("lights/#{bulb.id}/state", body: MultiJson.dump({on: true, bri: 100})).once.returns(true)
    end

    @group.on = true<commit_msg>Added test for creating bulb group from bulb array<commit_after>require 'test_helper'

class GroupTest < MiniTest::Test

  def setup
    super
    Huey::Group.stubs(:all).returns([])

    @bulb1 = init_bulb('1', 'Living Room - TV')
    @bulb2 = init_bulb('2', 'Living Room - Fireplace')
    @bulb3 = init_bulb('3', 'Foyer')
    @bulb4 = init_bulb('4', 'Bedroom')

    Huey::Bulb.stubs(:all).returns([@bulb1, @bulb2, @bulb3, @bulb4])
  end

  def test_initializes_group_from_bulbs
    @group = Huey::Group.new(@bulb1, @bulb2, @bulb3)

    assert_equal [@bulb1, @bulb2, @bulb3], @group.bulbs
  end

  def test_initializes_group_from_name
    @group = Huey::Group.new('Living Room')

    assert_equal [@bulb1, @bulb2], @group.bulbs
  end

  def test_initialzes_group_from_names
    @group = Huey::Group.new('Living Room', 'Foyer')

    assert_equal [@bulb1, @bulb2, @bulb3], @group.bulbs
  end

  def test_initializes_group_from_bulb_array
    @group = Huey::Group.new(Huey::Bulb.all)

    assert_equal [@bulb1, @bulb2, @bulb3, @bulb4], @group.bulbs
  end

  def test_delegates_save_to_bulbs
    @group = Huey::Group.new(@bulb1, @bulb2, @bulb3)

    [@bulb1, @bulb2, @bulb3].each do |bulb|
      Huey::Request.expects(:put).with("lights/#{bulb.id}/state", body: MultiJson.dump({on: true, bri: 100})).once.returns(true)
    end

    @group.on = true
{'fraction_non_alphanumeric': 0.16298675230830992, 'fraction_numerical': 0.02729827378562826, 'mean_word_length': 4.148760330578512, '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': '1646454', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1015, 'n_words': 186}