<commit_before>#! /usr/bin/env ruby

require 'spec_helper'
require 'yaml'
require 'puppet/util/network_device/brocade_fos/device'
require 'puppet/provider/brocade_fos'
require 'puppet/util/network_device/transport_fos/ssh'

describe "Integration test for brocade alias membership" do

  device_conf =  YAML.load_file(my_deviceurl('brocade','device_conf.yml'))

  before :each do
    Facter.stubs(:value).with(:url).returns(device_conf['url'])
  end

  let :create_alias do
    Puppet::Type.type(:brocade_alias).new(
    :alias_name  => 'testalias2',
    :ensure   => 'present',
    :member   => 'fc00:db20:35b:7399::5',
    )
  end
  let :add_members do
    Puppet::Type.type(:brocade_alias_membership).new(
    :alias_name  => 'testalias2',
    :ensure   => 'present',
    :member   => 'fc00:e968:6179::de52:7100',
    )
  end
  let :remove_members do
    Puppet::Type.type(:brocade_alias).new(
    :alias_name  => 'testalias2',
    :ensure   => 'absent',
    :member   => 'fc00:e968:6179::de52:7100',
    )
  end
  let :destroy_alias do
    Puppet::Type.type(:brocade_alias).new(
    :alias_name  => 'testalias2',
    :ensure   => 'absent',
    )
  end

  context "when add and remove alias members without any error" do
    it "should create a brocade alias" do
      create_alias.provider.device_transport.connect
      create_alias.provider.create
      response = create_alias.provider.device_transport.command(get_alias_show_cmd(create_alias[:alias_name]),:noop=>false)
      response.should_not include("does not exist")
    end
    it "should add a member brocade alias" do
      add_members.provider.device_transport.connect
      add_members.provider.create
      response = add_members.provider.device_transport.command(get_alias_show_cmd(add_members[:alias_name]),:noop=>false)
      response.should_not include("does not exist")
    end
    it "should delete member from brocade alias" do
      remove_members.provider.device_transport.connect
      remove_members.provider.destroy
      response = remove_members.provider.device_transport.command(get_alias_show_cmd(remove_members[:alias_name]),:noop=>false)
    # response.should include("does not exist")
    end
    it "should delete the brocade alias" do
      destroy_alias.provider.device_transport.connect
      destroy_alias.provider.destroy
      response = destroy_alias.provider.device_transport.command(get_alias_show_cmd(destroy_alias[:alias_name]),:noop=>false)
      response.should include("does not exist")
    end
  end

  def get_alias_show_cmd(aliasname)
    command = "alishow #{aliasname}"
  end

end<commit_msg>Integration test for brocade alias membership<commit_after>#! /usr/bin/env ruby

require 'spec_helper'
require 'yaml'
require 'puppet/util/network_device/brocade_fos/device'
require 'puppet/provider/brocade_fos'
require 'puppet/util/network_device/transport_fos/ssh'

describe "Integration test for brocade alias membership" do

  device_conf =  YAML.load_file(my_deviceurl('brocade','device_conf.yml'))

  let :create_alias do
    Puppet::Type.type(:brocade_alias).new(
    :alias_name  => 'testalias2',
    :ensure   => 'present',
    :member   => 'fc00:db20:35b:7399::5',
    )
  end
  let :add_members do
    Puppet::Type.type(:brocade_alias_membership).new(
    :alias_name  => 'testalias2',
    :ensure   => 'present',
    :member   => 'fc00:e968:6179::de52:7100',
    )
  end
  let :remove_members do
    Puppet::Type.type(:brocade_alias_membership).new(
    :alias_name  => 'testalias2',
    :ensure   => 'absent',
    :member   => 'fc00:e968:6179::de52:7100',
    )
  end
  let :destroy_alias do
    Puppet::Type.type(:brocade_alias).new(
    :alias_name  => 'testalias2',
    :ensure   => 'absent',
    )
  end
  #Before every test alias will be created
  before :each do
    Facter.stubs(:value).with(:url).returns(device_conf['url'])
    create_alias.provider.device_transport.connect
    create_alias.provider.create
    create_alias.provider.device_transport.close    
  end
  
  #After every test alias will be destroyed
  after :each do
    destroy_alias.provider.device_transport.connect
    destroy_alias.provider.destroy
    destroy_alias.provider.device_transport.close
  end

  context "when add and remove alias members without any error" do
        
    it "should add a member brocade alias" do
      add_members.provider.device_transport.connect
      add_members.provider.create
      response = add_members.provider.device_transport.command(get_alias_show_cmd(add_members[:alias_name]),:noop=>false)
      add_members.provider.device_transport.close
      response.should_not include("does not exist")
    end
    
    it "should delete member from brocade alias" do
      remove_members.provider.device_transport.connect
      remove_members.provider.destroy
      response = remove_members.provider.device_transport.command(get_alias_show_cmd(remove_members[:alias_name]),:noop=>false)
      remove_members.provider.device_transport.close      
      response.should_not include(remove_members[:member])
    end   
  end

  def get_alias_show_cmd(aliasname)
    command = "alishow #{aliasname}"
  end

end
{'fraction_non_alphanumeric': 0.11046171829339567, 'fraction_numerical': 0.017533606078316773, 'mean_word_length': 4.033333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, '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': '7396277', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1678, 'n_words': 306}