Top Level Namespace

Includes:
GoodData::Model

Defined Under Namespace

Modules: Enumerable, GoodData, RestClient Classes: BigDecimal, FalseClass, Hash, NilClass, Numeric, Object, Symbol, TestLogger, TrueClass

Constant Summary collapse

RAW_DATA =
{
  'metric'=>
  {'content'=>
    {'format'=>'#,##0',
     'expression'=> 'SELECT SUM([/gdc/md/ksjy0nr3goz6k8yrpklz97l0mych7nez/obj/700])'},
   'meta' =>
    {'author'=>'/gdc/account/profile/4e1e8cacc4989228e0ae531b30853248',
     'uri'=>'/gdc/md/ksjy0nr3goz6k8yrpklz97l0mych7nez/obj/70',
     'tags'=>'a a   b cg r t',
     'created'=>'2014-04-30 22:47:57',
     'identifier'=>'afo7bx1VakCz',
     'deprecated'=>'0',
     'summary'=>'',
     'title'=>'sum of Lines changed',
     'category'=>'metric',
     'updated'=>'2014-05-05 20:00:42',
     'contributor'=>'/gdc/account/profile/4e1e8cacc4989228e0ae531b30853248'}}
}
ROW_BASED_DATA =
[
  ['[email protected]', 'US', 'CZ', 'KZ'],
  ['[email protected]', 'US'],
  ['[email protected]','KZ']
]
COLUMN_BASED_DATA_WITH_HEADERS =
[
  {
    :login => '[email protected]',
    :country => 'US',
    :age => 14
  },
  {
    :login => '[email protected]',
    :country => 'US',
    :age => 19
  },
  {
    :login => '[email protected]',
    :country => 'KZ',
    :age => 30
  }
]
COLUMN_BASED_DATA_WITH_HEADERS_AND_NIL_VAL =
[
  {
    :login => '[email protected]',
    :country => 'US',
    :age => 14
  },
  {
    :login => '[email protected]',
    :country => 'US',
    :age => 19
  },
  {
    :login => '[email protected]',
    :country => 'KZ',
    :age => nil
  }
]
COLUMN_BASED_DATA_WITH_HEADERS_AND_EMPTY_VAL =
[
  {
    :login => '[email protected]',
    :country => 'US',
    :age => 14
  },
  {
    :login => '[email protected]',
    :country => 'US',
    :age => 19
  },
  {
    :login => '[email protected]',
    :country => 'KZ',
    :age => ''
  }
]

Constants included from GoodData::Model

GoodData::Model::ATTRIBUTE_FOLDER_PREFIX, GoodData::Model::ATTRIBUTE_PREFIX, GoodData::Model::DATE_ATTRIBUTE, GoodData::Model::DATE_ATTRIBUTE_DEFAULT_DISPLAY_FORM, GoodData::Model::DATE_COLUMN_PREFIX, GoodData::Model::DATE_FACT_PREFIX, GoodData::Model::DEFAULT_ATTRIBUTE_DATATYPE, GoodData::Model::DEFAULT_DATE_FORMAT, GoodData::Model::DEFAULT_FACT_DATATYPE, GoodData::Model::DEFAULT_TYPE, GoodData::Model::FACT_COLUMN_PREFIX, GoodData::Model::FACT_FOLDER_PREFIX, GoodData::Model::FACT_PREFIX, GoodData::Model::FIELD_PK, GoodData::Model::FK_SUFFIX, GoodData::Model::GD_DATA_TYPES, GoodData::Model::GD_TYPES, GoodData::Model::LABEL_COLUMN_PREFIX, GoodData::Model::LABEL_PREFIX, GoodData::Model::LDM_CTG, GoodData::Model::LDM_MANAGE_CTG, GoodData::Model::TIME_ATTRIBUTE_PREFIX, GoodData::Model::TIME_COLUMN_PREFIX, GoodData::Model::TIME_FACT_PREFIX

Instance Method Summary collapse

Methods included from GoodData::Model

check_gd_data_type, check_gd_type, column_name, description, merge_dataset_columns, normalize_gd_data_type, title, upload_data, upload_multiple_data

Instance Method Details

#check_filters(filters) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'spec/unit/models/user_filters_spec.rb', line 9

def check_filters(filters)
  filters.count.should == 2
  filter = filters.first
  filter[:login].should == "[email protected]"
  filter[:filters].count.should == 1
  filter[:filters].first[:values].count.should == 4
  filter[:filters].first[:values].should == ["USA", "Czech Republic", "Uganda", "Slovakia"]
  filter = filters.last
  filter[:login].should == "[email protected]"
  filter[:filters].count.should == 1
  filter[:filters].first[:values].count.should == 1
end

#test_allObject



64
65
66
67
68
69
# File 'spec/unit/core/logging_spec.rb', line 64

def test_all
  test_error
  test_info
  test_warn
  test_request_id_logging
end

#test_errorObject



44
45
46
# File 'spec/unit/core/logging_spec.rb', line 44

def test_error
  GoodData.logger.error TEST_MESSAGE
end

#test_infoObject



48
49
50
# File 'spec/unit/core/logging_spec.rb', line 48

def test_info
  GoodData.logger.info TEST_MESSAGE
end

#test_request_id_loggingObject



56
57
58
59
60
61
62
# File 'spec/unit/core/logging_spec.rb', line 56

def test_request_id_logging
  c = ConnectionHelper.create_default_connection
  id = c.generate_request_id
  GoodData.logger.info "Request id: #{id} Doing something very useful"
  c.get('/gdc/md', :request_id => id)
  id
end

#test_warnObject



52
53
54
# File 'spec/unit/core/logging_spec.rb', line 52

def test_warn
  GoodData.logger.warn TEST_MESSAGE
end

#test_webdav_upload(params) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'spec/integration/rest_spec.rb', line 29

def test_webdav_upload(params)
  GoodData.with_project(@project, :client => @client) do

    # use current timestamp as a directory name on webdav
    dir = params[:no_dir] ? nil : Time.now.to_i.to_s
    dir = "#{dir}/#{dir}" if params[:nested_dir]
    dir = "#{dir}/" if params[:slash_in_dir]

    # local file path
    path = 'spec/data/test-ci-data.csv'

    if params[:special_chars]
      source_file = Tempfile.new('abc-16:55:29+ha#he.csv')
      FileUtils.cp(path, source_file)
      path = source_file.path
    end

    path = File.expand_path(path) if params[:absolute_path]

    # upload it there
    upload_method = GoodData.method(params[:upload_method])
    upload_method.call(path, directory: dir)

    # download it from there
    temp_file = Tempfile.new('foo.csv')
    expect(temp_file.size).to be == 0

    download_method = GoodData.method(params[:download_method])

    file_basename = File.basename(path)
    file_basename = "NOTTHERE_#{file_basename}" if params[:unknown_file]

    download_block = proc do
      if params[:path_in_file]
        # pass the dir directly in the first param
        # e.g. GoodData.download_from_project_webdav('1234/test-ci-data.csv', '/tmp/myfile.csv')
        download_method.call(File.join(dir, file_basename).to_s, temp_file)
      else
        # pass the dir in the :directory option
        # e.g. GoodData.download_from_project_webdav('test-ci-data.csv', '/tmp/myfile.csv', :directory => '1234')
        download_method.call(file_basename, temp_file, directory: dir)
      end
    end

    # if it's unknown it should raise an error, otherwise it should download the right stuff
    if params[:unknown_file]
      expect{ download_block.call }.to raise_error(ArgumentError)
    else
      download_block.call

      expect(temp_file.size).to be > 0

      # expect the contents of the original file and the downloaded file are the same
      expect(IO.read(temp_file)).to be == IO.read(path)
    end
  end
end