Sha256: e882a508eed99955933a095757dc23360b09712fa12ee5b60d7ec216e6ef14c9

Contents?: true

Size: 1.83 KB

Versions: 29

Compression:

Stored size: 1.83 KB

Contents

require 'helper'
require 'gooddata/command'

class TestGuesser < Test::Unit::TestCase
  should "order LDM types as follows: cp, fact, date, attribute" do
    assert_equal [ :connection_point, :fact, :date, :attribute ], \
                 GoodData::Command::Guesser::sort_types([ :fact, :attribute, :connection_point, :date ])
    assert_equal [ :fact ], GoodData::Command::Guesser::sort_types([ :fact ])
    assert_equal [], GoodData::Command::Guesser::sort_types([])
  end

  should "guess facts, dates and connection points from a simple CSV" do
    csv = [
      [ 'cp', 'a1', 'a2', 'd1', 'd2', 'f'],
      [ '1', 'one', 'huh', '2001-01-02', nil, '-1' ],
      [ '2', 'two', 'blah', nil, '1970-10-23', '2.3' ],
      [ '3', 'three', 'bleh', '0000-00-00', nil, '-3.14159'],
      [ '4', 'one', 'huh', '2010-02-28 08:12:34', '1970-10-23', nil ]
    ]
    fields = GoodData::Command::Guesser.new(csv).guess(csv.size + 10)

    assert_kind_of Hash, fields, "guesser should return a Hash"
    fields.each do |field, info|
      assert_kind_of Array, info, "guess for '%s' is not an Array" % field
    end

    type_msg_fmt = 'checking guessed types of "%s"'

    assert_equal GoodData::Command::Guesser::sort_types([
        :connection_point, :fact, :attribute
      ]), fields['cp'], type_msg_fmt % 'cp'

    assert_equal [ :attribute ], fields['a1'], type_msg_fmt % 'a1'
    assert_equal [ :attribute ], fields['a2'], type_msg_fmt % 'a2'

    assert_equal GoodData::Command::Guesser::sort_types([
        :attribute, :connection_point, :date
      ]), fields['d1'], type_msg_fmt % 'd1'
    assert_equal GoodData::Command::Guesser::sort_types([
        :attribute, :date
      ]), fields['d2'], type_msg_fmt % 'd2'
    assert_equal GoodData::Command::Guesser::sort_types([
        :attribute, :connection_point, :fact
      ]), fields['f'], type_msg_fmt % 'f'
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
gooddata-0.6.0.pre11 test/test_guessing.rb
gooddata-0.6.0.pre10 test/test_guessing.rb
gooddata-0.6.0.pre9 test/test_guessing.rb
gooddata-0.6.0.pre8 test/test_guessing.rb
gooddata-0.6.0.pre7 test/test_guessing.rb
gooddata-0.6.0.pre6 test/test_guessing.rb
gooddata-0.6.0.pre5 test/test_guessing.rb
gooddata-0.6.0.pre4 test/test_guessing.rb
gooddata-0.6.0.pre3 test/test_guessing.rb
gooddata-0.6.0.pre2 test/test_guessing.rb
gooddata-0.5.16 test/test_guessing.rb
gooddata-0.5.15 test/test_guessing.rb
gooddata-0.5.14 test/test_guessing.rb
gooddata-0.5.13 test/test_guessing.rb
gooddata-0.5.12 test/test_guessing.rb
gooddata-0.5.11 test/test_guessing.rb
gooddata-0.5.10 test/test_guessing.rb
gooddata-0.5.9 test/test_guessing.rb
gooddata-0.5.8 test/test_guessing.rb
gooddata-0.5.7 test/test_guessing.rb