ken 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  class SessionTest < Test::Unit::TestCase
4
4
  context "A Session instance" do
5
5
  setup do
6
- Ken::Logger.new(STDOUT, :info)
6
+ # Ken::Logger.new(STDOUT, :info)
7
7
  Ken::Session.new('http://www.freebase.com', 'ma', 'xxxxx')
8
8
  end
9
9
 
@@ -23,7 +23,7 @@ class SessionTest < Test::Unit::TestCase
23
23
  should 'do cursored queries' do
24
24
  Ken.session.mqlread([{:type => '/chemistry/chemical_element'}], :cursor => true).length.should >= 117
25
25
  end
26
-
26
+
27
27
  should 'do raw content requests' do
28
28
  Ken.session.raw_content("/guid/9202a8c04000641f800000000002c4f3").length.should >= 50
29
29
  end
@@ -31,5 +31,9 @@ class SessionTest < Test::Unit::TestCase
31
31
  should 'do blurb content requests' do
32
32
  Ken.session.blurb_content("/guid/9202a8c04000641f800000000002c4f3", :maxlength => 200).length.should >= 50
33
33
  end
34
+
35
+ should 'do topic requests' do
36
+ Ken.session.topic("/en/the_police")
37
+ end
34
38
  end # context
35
39
  end # SessionTest
@@ -0,0 +1,92 @@
1
+ require 'test_helper'
2
+
3
+ class TopicTest < Test::Unit::TestCase
4
+ context "A Topic instance" do
5
+ setup do
6
+ data = load_fixture('the_police_topic')
7
+ @the_police = Ken::Topic.new(data)
8
+ end
9
+
10
+ should "have an id" do
11
+ @the_police.id.should == "/en/the_police"
12
+ end
13
+
14
+ should "have aliases" do
15
+ @the_police.aliases.length.should >= 1
16
+ end
17
+
18
+ should "have a text/name" do
19
+ @the_police.text.should == "The Police"
20
+ @the_police.name.should == "The Police"
21
+ end
22
+
23
+ should "have a thumbnail" do
24
+ @the_police.thumbnail.should == "http://api.freebase.com/api/trans/image_thumb/en/the_police"
25
+ end
26
+
27
+ should "have webpages" do
28
+ @the_police.webpages.length.should == 5
29
+ end
30
+
31
+ should "have types" do
32
+ @the_police.types.length.should == 7
33
+ @the_police.types.first.should be_kind_of(Ken::Type)
34
+ end
35
+
36
+ should "have properties" do
37
+ @the_police.properties.length.should >= 1
38
+ @the_police.properties.first.should be_kind_of(Ken::Property)
39
+ end
40
+
41
+ should "have attributes" do
42
+ @the_police.attributes.first.should be_kind_of(Ken::Attribute)
43
+
44
+ # TODO support mediator properties (CVT's)
45
+ # @the_police.attributes.length.should == @the_police.properties.length
46
+ end
47
+
48
+ should "have views" do
49
+ @the_police.should have(7).views
50
+ @the_police.views.first.should be_kind_of(Ken::View)
51
+ @the_police.views.first.type.should be_kind_of(Ken::Type)
52
+ end
53
+
54
+ should "return individual view based requested type id" do
55
+ @the_police.view('/music/artist').should be_kind_of(Ken::View)
56
+ @the_police.view('/music/artist').attributes.length.should == 9
57
+ @the_police.view('/location/location').should be_nil # not existent view
58
+ end
59
+
60
+ should "return individual type based requested type id" do
61
+ @the_police.type('/music/artist').should be_kind_of(Ken::Type)
62
+ @the_police.type('/location/location').should be_nil # not existent type
63
+ end
64
+
65
+ should 'have a full set of attributes' do
66
+ @the_police.attributes.should_not be_nil
67
+ end
68
+
69
+ should "have id and name properties" do
70
+ @the_police.id.should be_kind_of(String)
71
+ @the_police.name.should be_kind_of(String)
72
+ end
73
+
74
+ should 'load attributes only on demand' do
75
+ @the_police.attributes_loaded?.should == false
76
+ @the_police.attributes
77
+ @the_police.attributes_loaded?.should == true
78
+ end
79
+
80
+ should 'load schema only on demand when calling types' do
81
+ @the_police.schema_loaded?.should == false
82
+ @the_police.types
83
+ @the_police.schema_loaded?.should == true
84
+ end
85
+
86
+ should 'load schema only on demand when calling views' do
87
+ @the_police.schema_loaded?.should == false
88
+ @the_police.views
89
+ @the_police.schema_loaded?.should == true
90
+ end
91
+ end # context
92
+ end # TopicTest
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - michael
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-23 00:00:00 +02:00
12
+ date: 2009-11-02 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -71,6 +71,7 @@ files:
71
71
  - lib/ken/property.rb
72
72
  - lib/ken/resource.rb
73
73
  - lib/ken/session.rb
74
+ - lib/ken/topic.rb
74
75
  - lib/ken/type.rb
75
76
  - lib/ken/util.rb
76
77
  - lib/ken/view.rb
@@ -79,12 +80,14 @@ files:
79
80
  - tasks/spec.rb
80
81
  - test/fixtures/music_artist.json
81
82
  - test/fixtures/the_police.json
83
+ - test/fixtures/the_police_topic.json
82
84
  - test/integration/ken_test.rb
83
85
  - test/test_helper.rb
84
86
  - test/unit/attribute_test.rb
85
87
  - test/unit/property_test.rb
86
88
  - test/unit/resource_test.rb
87
89
  - test/unit/session_test.rb
90
+ - test/unit/topic_test.rb
88
91
  - test/unit/type_test.rb
89
92
  - test/unit/view_test.rb
90
93
  has_rdoc: true
@@ -122,6 +125,7 @@ test_files:
122
125
  - test/unit/property_test.rb
123
126
  - test/unit/resource_test.rb
124
127
  - test/unit/session_test.rb
128
+ - test/unit/topic_test.rb
125
129
  - test/unit/type_test.rb
126
130
  - test/unit/view_test.rb
127
131
  - examples/artist.rb