Sha256: 71275a93f3d30995adf63b95c7bf3f27f24814e56a81da763a51896782f735ac

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

require 'logger'
require 'tempfile'
require 'fastercsv'

require 'helper'
require 'gooddata/model'
require 'gooddata/command'

GoodData.logger = Logger.new(STDOUT)

class TestModel < Test::Unit::TestCase
  FILE = [
    [ "cp", "a1", "a2", "f1", "f2" ],
    [ 1, "a1.1", "a2.1", "0", "5" ],
    [ 2, "a1.2", "a2.1", nil, 10 ],
    [ 3, "a1.2", "a2.2", 1, nil ],
    [ 4, "a1.3", "a2.2", 0, 0 ]
  ]
  COLUMNS = [
      { 'type' => 'CONNECTION_POINT', 'name' => 'cp', 'title' => 'CP', 'folder' => 'test' },
      { 'type' => 'ATTRIBUTE', 'name' => 'a1', 'title' => 'A1', 'folder' => 'test' },
      { 'type' => 'ATTRIBUTE', 'name' => 'a2', 'title' => 'A2', 'folder' => 'test' },
      { 'type' => 'FACT', 'name' => 'f1', 'title' => 'F1', 'folder' => 'test' },
      { 'type' => 'FACT', 'name' => 'f2', 'title' => 'F2', 'folder' => 'test' },
    ]
  SCHEMA = GoodData::Model::Schema.new 'title' => 'test', 'columns' => COLUMNS

  context "GoodData model tools" do
    # Initialize a GoodData connection using the credential
    # stored in ~/.gooddata
    #
    # And create a temporary CSV file to test the upload
    setup do
      GoodData::Command::connect
      @file = Tempfile.open 'test_csv'
      FasterCSV.open @file.path, 'w' do |csv|
        FILE.each { |row| csv << row }
      end
      @project = GoodData::Project.create :title => "gooddata-ruby test #{Time.now.to_i}"
    end

    teardown do
      @file.unlink
      @project.delete
    end

    should "upload CSV in a full mode" do
      @project.add_dataset SCHEMA
      @project.upload @file.path, SCHEMA
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gooddata-0.2.0 test/test_upload.rb