octopi 0.4.2 → 0.4.3

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.
@@ -1,20 +0,0 @@
1
- # Tests for octopi core functionality go here.
2
- require File.join(File.dirname(__FILE__), 'test_helper')
3
-
4
- class TagTest < Test::Unit::TestCase
5
- include Octopi
6
-
7
- def setup
8
- fake_everything
9
- end
10
-
11
- context Tag do
12
- should "be able to find all tags" do
13
- tags = Tag.all(:user => "fcoury", :repository => "octopi")
14
- assert_not_nil tags
15
- assert_equal 9, tags.size
16
- assert tags.first.is_a?(Tag)
17
- end
18
- end
19
-
20
- end
@@ -1,250 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
- require 'fakeweb'
5
-
6
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
- $LOAD_PATH.unshift(File.dirname(__FILE__))
8
- require 'octopi'
9
-
10
- ENV['HOME'] = File.dirname(__FILE__)
11
- FakeWeb.allow_net_connect = false
12
-
13
- @the_repo = ["fcoury", "octopi"]
14
-
15
- def stub_file(*path)
16
- File.join(File.dirname(__FILE__), "stubs", path)
17
- end
18
-
19
- def commits(*args)
20
- File.join("commits", "fcoury", "octopi", args)
21
- end
22
-
23
- def issues(*args)
24
- File.join("issues", "fcoury", "octopi", args)
25
- end
26
-
27
- def repos(*args)
28
- File.join("repos", "fcoury", "octopi", args)
29
- end
30
-
31
- def users(*args)
32
- File.join("users", args)
33
- end
34
-
35
- def auth(&block)
36
- authenticated_with(:login => "fcoury", :token => "8f700e0d7747826f3e56ee13651414bd") do
37
- yield
38
- end
39
- end
40
-
41
- # Methodized so it can be used in tests, an instance would do also.
42
- def yaml_api
43
- "github.com/api/v2/yaml"
44
- end
45
-
46
- def fake_everything
47
- FakeWeb.clean_registry
48
- # helper variables to make things shorter.
49
- sha = "f6609209c3ac0badd004512d318bfaa508ea10ae"
50
- fake_sha = "ea3cd978650417470535f3a4725b6b5042a6ab59"
51
-
52
- plain_api = "github.com/api/v2/plain"
53
-
54
- # Public stuff
55
- fakes = {
56
- "blob/show/fcoury/octopi/#{sha}" => File.join("blob", "fcoury", "octopi", "plain", sha),
57
-
58
- "commits/list/fcoury/octopi/master" => commits("master"),
59
- "commits/list/fcoury/octopi/master/lib/octopi.rb" => commits("octopi.rb"),
60
- "commits/list/fcoury/octopi/lazy" => commits("lazy"),
61
- "commits/show/fcoury/octopi/#{sha}" => commits(sha),
62
-
63
- "issues/list/fcoury/octopi/open" => issues("open"),
64
- "issues/list/fcoury/octopi/closed" => issues("closed"),
65
-
66
- "issues/search/fcoury/octopi/open/test" => issues("search"),
67
-
68
- #comments for an issue
69
- "issues/comments/fcoury/octopi/28" => File.join("comments", "fcoury", "octopi", "comments"),
70
-
71
- # Closed issue
72
- "issues/show/fcoury/octopi/27" => issues("27"),
73
- # Open issue
74
- "issues/show/fcoury/octopi/28" => issues("28"),
75
-
76
- "repos/show/fcoury/octopi/collaborators" => File.join("repos", "fcoury", "octopi", "collaborators"),
77
- "repos/show/fcoury/octopi/languages" => File.join("repos", "fcoury", "octopi", "languages"),
78
- "repos/show/fcoury" => File.join("repos", "show", "fcoury"),
79
- "repos/search/ruby+testing" => File.join("repos", "search"),
80
- "repos/show/fcoury/octopi" => repos("master"),
81
- "repos/show/fcoury/octopi/branches" => repos("branches"),
82
- "repos/show/fcoury/octopi/tags" => repos("tags"),
83
- "repos/watched/radar" => File.join("users", "watched-repos"),
84
-
85
- "tree/show/fcoury/octopi/#{sha}" => File.join("tree", "fcoury", "octopi", sha),
86
-
87
- "user/show/fcoury" => users("fcoury"),
88
-
89
- "user/show/fcoury/followers" => File.join("users", "followers"),
90
- "user/show/fcoury/following" => File.join("users", "following"),
91
- "user/search/radar" => File.join("users", "search-radar")
92
-
93
-
94
- }
95
-
96
- # I follow the following people:
97
- ["Caged",
98
- "FooBarWidget",
99
- "aslakhellesoy",
100
- "augustl",
101
- "benaskins",
102
- "benhoskings",
103
- "bjeanes",
104
- "cldwalker",
105
- "dchelimsky",
106
- "defunkt",
107
- "diy",
108
- "documentcloud",
109
- "drnic",
110
- "eladmeidar",
111
- "entp",
112
- "fcoury",
113
- "giraffesoft",
114
- "hashrocket",
115
- "hcatlin",
116
- "jamis",
117
- "jnicklas",
118
- "jnunemaker",
119
- "kballard",
120
- "knewter",
121
- "lachie",
122
- "lachlanhardy",
123
- "lenary",
124
- "lifo",
125
- "maccman",
126
- "markgandolfo",
127
- "mbleigh",
128
- "mhodgson",
129
- "mocra",
130
- "mojombo",
131
- "newbamboo",
132
- "notahat",
133
- "opscode",
134
- "pvande",
135
- "rack",
136
- "radar",
137
- "rails",
138
- "railscampau",
139
- "redinger",
140
- "shuber",
141
- "softprops",
142
- "svenfuchs",
143
- "technoweenie",
144
- "thoughtbot",
145
- "tobi",
146
- "webbynode",
147
- "wvanbergen",
148
- "wycats"].each do |name|
149
- fakes["user/show/#{name}"] = users(name);
150
- end
151
-
152
- fakes.each do |key, value|
153
- FakeWeb.register_uri(:get, "https://#{yaml_api}/" + key, :response => stub_file(value))
154
- end
155
-
156
- gist_fakes = {
157
- "159579" => File.join("gists", "159579")
158
- }
159
-
160
-
161
- gist_fakes.each do |key, value|
162
- FakeWeb.register_uri(:get, "https://gist.github.com/api/v1/yaml/#{key}", :response => stub_file(value))
163
- end
164
- ["augustl", "bcalloway", "danlucraft", "dcrec1", "derencius", "dustin", "elliottcable", "gwoliveira", "hashrocket", "jruby", "kchris", "paulorv", "radar", "remi", "shanesveller", "superfeedr", "taylorrf", "tgraham", "tmm1", "tpope", "webbynode"].each do |followee|
165
- FakeWeb.register_uri(:get, "https://#{yaml_api}/user/show/#{followee}", :response => stub_file("users/#{followee}") )
166
- end
167
-
168
-
169
- fake_posts = {
170
- "issues/label/add/fcoury/octopi/one-point-oh/28" => issues("labels", "28-one-point-oh"),
171
- "issues/label/add/fcoury/octopi/maybe-two-point-oh/28" => issues("labels", "28-maybe-two-point-oh"),
172
- "issues/label/remove/fcoury/octopi/one-point-oh/28" => issues("labels", "28-remove-one-point-oh"),
173
- "issues/label/remove/fcoury/octopi/maybe-two-point-oh/28" => issues("labels", "28-remove-maybe-two-point-oh"),
174
- "issues/reopen/fcoury/octopi/27" => issues("27-reopened"),
175
- "issues/open/fcoury/octopi" => issues("new"),
176
- "issues/close/fcoury/octopi/28" => issues("28-closed"),
177
- "issues/edit/fcoury/octopi/28" => issues("28-edited"),
178
- "issues/reopen/fcoury/octopi/27" => issues("27-reopened"),
179
- "issues/comment/fcoury/octopi/28" => issues("comment", "28-comment")
180
- }.each do |key, value|
181
- FakeWeb.register_uri(:post, "https://#{yaml_api}/" + key, :response => stub_file(value))
182
- end
183
-
184
- # # rboard is a private repository
185
- FakeWeb.register_uri(:get, "https://#{yaml_api}/repos/show/fcoury/rboard", :response => stub_file("errors", "repository", "not_found"))
186
-
187
- # nothere is obviously an invalid sha
188
- FakeWeb.register_uri(:get, "https://#{yaml_api}/commits/show/fcoury/octopi/nothere", :status => ["404", "Not Found"])
189
- # not-a-number is obviously not a *number*
190
- FakeWeb.register_uri(:get, "https://#{yaml_api}/issues/show/fcoury/octopi/not-a-number", :status => ["404", "Not Found"])
191
- # is an invalid hash
192
- FakeWeb.register_uri(:get, "https://#{yaml_api}/tree/show/fcoury/octopi/#{fake_sha}", :status => ["404", "Not Found"])
193
- # is not a user
194
- FakeWeb.register_uri(:get, "https://#{yaml_api}/user/show/i-am-most-probably-a-user-that-does-not-exist", :status => ["404", "Not Found"])
195
-
196
-
197
- FakeWeb.register_uri(:get, "https://github.com/login", :response => stub_file("login"))
198
- FakeWeb.register_uri(:post, "https://github.com/session", :response => stub_file("dashboard"))
199
- FakeWeb.register_uri(:get, "https://github.com/account", :response => stub_file("account"))
200
-
201
- # Personal & Private stuff
202
-
203
- # To authenticate with the API
204
- # Methodized as it is used also in key_tests
205
- def auth_query
206
- "?login=fcoury&token=8f700e0d7747826f3e56ee13651414bd"
207
- end
208
-
209
- secure_fakes = {
210
-
211
- "commits/list/fcoury/rboard/master" => File.join("commits", "fcoury", "rboard", "master"),
212
-
213
- "repos/show/fcoury" => File.join("repos", "show", "fcoury-private"),
214
- "repos/show/fcoury/octopi" => File.join("repos", "fcoury", "octopi", "master"),
215
- "repos/show/fcoury/rboard" => File.join("repos", "fcoury", "rboard", "master"),
216
-
217
- "user/keys" => File.join("users", "keys"),
218
- "user/show/fcoury" => File.join("users", "fcoury-private")
219
- }
220
-
221
- secure_fakes.each do |key, value|
222
- FakeWeb.register_uri(:get, "https://#{yaml_api}/" + key + auth_query, :response => stub_file(value))
223
- end
224
-
225
- secure_post_fakes = {
226
- "user/key/add" => File.join("users", "key-added"),
227
- "user/key/remove" => File.join("users", "key-removed"),
228
- "user/follow/rails" => File.join("users", "follow-rails"),
229
- "user/unfollow/rails" => File.join("users", "unfollow-rails"),
230
- "repos/create" => File.join("repos", "fcoury", "octopus", "main"),
231
- "repos/delete/octopi" => File.join("repos", "fcoury", "octopi", "delete-token")
232
- }
233
-
234
- secure_post_fakes.each do |key, value|
235
- FakeWeb.register_uri(:post, "https://#{yaml_api}/" + key + auth_query, :response => stub_file(value))
236
- end
237
-
238
-
239
- # And the plain fakes
240
- FakeWeb.register_uri(:get, "https://#{plain_api}/blob/show/fcoury/octopi/#{sha}",
241
- :response => stub_file(File.join("blob", "fcoury", "octopi", "plain", sha)))
242
-
243
-
244
- FakeWeb.register_uri(:get, "https://github.com/fcoury/octopi/comments.atom", :response => stub_file("comments", "fcoury", "octopi", "comments.atom"))
245
- end
246
-
247
-
248
- class Test::Unit::TestCase
249
-
250
- end
@@ -1,92 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
2
-
3
- class UserTest < Test::Unit::TestCase
4
- include Octopi
5
-
6
- def setup
7
- fake_everything
8
- @user = User.find("fcoury")
9
- end
10
-
11
- should "be able to find a user" do
12
- assert_not_nil User.find("fcoury")
13
- end
14
-
15
- should "not be able to find a user that doesn't exist" do
16
- exception = assert_raise NotFound do
17
- User.find("i-am-most-probably-a-user-that-does-not-exist")
18
- end
19
-
20
- assert_equal "The User you were looking for could not be found, or is private.", exception.message
21
- end
22
-
23
- should "be able to look for a user, using find_all" do
24
- users = User.find_all("radar")
25
- assert_not_nil users
26
- end
27
-
28
- should "be able to search for a user" do
29
- users = User.search("radar")
30
- assert_not_nil users
31
- end
32
-
33
- context "authenticated" do
34
- should "return all user information" do
35
- authenticated do
36
- user = Api.api.user
37
- assert_not_nil user
38
- fields = [:company, :name, :following_count, :blog, :public_repo_count,
39
- :public_gist_count, :id, :login, :followers_count, :created_at,
40
- :email, :location, :disk_usage, :private_gist_count, :plan,
41
- :owned_private_repo_count, :total_private_repo_count]
42
- fields.each do |f|
43
- assert_not_nil user.send(f)
44
- end
45
-
46
- plan_fields = [:name, :collaborators, :space, :private_repos]
47
- plan_fields.each do |f|
48
- assert_not_nil user.plan.send(f)
49
- end
50
- end
51
- end
52
-
53
- context "return a list of followers" do
54
-
55
- should "in string format" do
56
- users = @user.followers
57
- assert_not_nil users
58
- assert users.first.is_a?(String)
59
- end
60
-
61
- should "in object format" do
62
- users = @user.followers!
63
- assert_not_nil users
64
- assert users.first.is_a?(User)
65
- end
66
- end
67
-
68
- context "return a list of people who they are following" do
69
- should "in string format" do
70
- users = @user.following
71
- assert_not_nil users
72
- assert users.first.is_a?(String)
73
- end
74
-
75
- should "in object format" do
76
- users = @user.following!
77
- assert_not_nil users
78
- assert users.first.is_a?(User)
79
- end
80
- end
81
-
82
- context "return a list of watched repositories" do
83
- should "in an array" do
84
- @user = User.find("radar")
85
- repos = @user.watching
86
- assert_not_nil repos
87
- assert repos.first.is_a?(Repository)
88
- end
89
- end
90
-
91
- end
92
- end