<commit_before>require File.join(File.dirname(__FILE__), 'helper')
require 'bicho/plugins/novell'

class NovellPlugin_test < Test::Unit::TestCase

  def test_urls_are_correct
    client = Bicho::Client.new('https://bugzilla.novell.com')

    assert_raises NoMethodError do
      client.url
    end

    assert_equal 'https://apibugzilla.novell.com/tr_xmlrpc.cgi', "#{client.api_url.scheme}://#{client.api_url.host}#{client.api_url.path}"
    assert_equal 'https://bugzilla.novell.com', "#{client.site_url.scheme}://#{client.site_url.host}#{client.site_url.path}"

  end

  def test_oscrc_parsing
    Bicho::Plugins::Novell.oscrc_path = "/space/tmp/oscrc-uwe"
    plugin = Bicho::Plugins::Novell.new
    credentials = Bicho::Plugins::Novell.oscrc_credentials
    assert_not_nil(credentials)
    assert(credentials.has_key?(:user))
    assert(credentials.has_key?(:password))
  end

end<commit_msg>use a temp directory with a fake oscrc<commit_after>require File.join(File.dirname(__FILE__), 'helper')
require 'bicho/plugins/novell'
require 'tmpdir'

class NovellPlugin_test < Test::Unit::TestCase

  def test_urls_are_correct
    client = Bicho::Client.new('https://bugzilla.novell.com')

    assert_raises NoMethodError do
      client.url
    end

    assert_equal 'https://apibugzilla.novell.com/tr_xmlrpc.cgi', "#{client.api_url.scheme}://#{client.api_url.host}#{client.api_url.path}"
    assert_equal 'https://bugzilla.novell.com', "#{client.site_url.scheme}://#{client.site_url.host}#{client.site_url.path}"

  end

  def self.write_fake_oscrc(path)
    File.open(path, 'w') do |f|
      f.write(<<EOS)
[https://api.opensuse.org]
user= foo
pass=<PASSWORD>
# fake osc file
EOS
    end
  end

  def test_oscrc_parsing
    Dir.mktmpdir do |tmp|
      fake_oscrc = File.join(tmp, 'oscrc')
      write_fake_oscrc(fake_oscrc)
      Bicho::Plugins::Novell.oscrc_path = fake_oscrc
      plugin = Bicho::Plugins::Novell.new
      credentials = Bicho::Plugins::Novell.oscrc_credentials
      assert_not_nil(credentials)
      assert(credentials.has_key?(:user))
      assert(credentials.has_key?(:password))
    end
  end

end
{'fraction_non_alphanumeric': 0.14238566713814238, 'fraction_numerical': 0.0, 'mean_word_length': 4.372151898734177, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 4, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '4009202', 'n_tokens_mistral': 790, 'n_tokens_neox': 778, 'n_words': 107}