aeden / activewarehouse

ActiveWarehouse for Rails - Implement data warehouses with Rails

activewarehouse / test / aggregate_field_test.rb
100644 56 lines (43 sloc) 1.884 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
require File.join(File.dirname(__FILE__), 'test_helper')
 
class AggregateFieldTest < Test::Unit::TestCase
 
  def setup
    super
    @field = ActiveWarehouse::AggregateField.new(StoreInventorySnapshotFact,
        StoreInventorySnapshotFact.columns_hash["quantity_sold"])
  end
  
  def test_fact_class
    assert StoreInventorySnapshotFact, @field.fact_class
  end
  
  def test_semiadditive
    assert ! @field.is_semiadditive?
    
    @field = ActiveWarehouse::AggregateField.new(StoreInventorySnapshotFact,
        StoreInventorySnapshotFact.columns_hash["quantity_sold"], :sum, :semiadditive => :date)
        
    assert @field.is_semiadditive?
  end
  
  def test_semiadditive_over
    @field = ActiveWarehouse::AggregateField.new(StoreInventorySnapshotFact,
        StoreInventorySnapshotFact.columns_hash["quantity_sold"], :sum, :semiadditive => :date)
    assert DateDimension, @field.semiadditive_over
  end
  
  def test_default_strategy_name
    assert :sum, @field.strategy_name
  end
  
  def test_strategy_name_specified
    @field = ActiveWarehouse::AggregateField.new(StoreInventorySnapshotFact,
        StoreInventorySnapshotFact.columns_hash["quantity_sold"], :count)
    assert :count, @field.strategy_name
  end
  
  def test_default_label
    assert "store_inventory_snapshot_facts_quantity_sold_sum", @field.label
  end
  
  def test_label
    @field = ActiveWarehouse::AggregateField.new(StoreInventorySnapshotFact,
        StoreInventorySnapshotFact.columns_hash["quantity_sold"], :sum, :label => "My Sum")
    assert "My Sum", @field.label
  end
  
  def test_label_for_table
    @field = ActiveWarehouse::AggregateField.new(StoreInventorySnapshotFact,
        StoreInventorySnapshotFact.columns_hash["quantity_sold"], :sum, :label => "My Sum")
    assert "my_sum", @field.label_for_table
  end
  
end