shout-mouth-communicator 1.0.1 → 1.0.2
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.
@@ -0,0 +1,30 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<methodResponse>
|
3
|
+
<params>
|
4
|
+
<param>
|
5
|
+
<value>
|
6
|
+
<struct>
|
7
|
+
<member>
|
8
|
+
<name>fault</name>
|
9
|
+
<value>
|
10
|
+
<struct>
|
11
|
+
<member>
|
12
|
+
<name>faultCode</name>
|
13
|
+
<value>
|
14
|
+
<int>-32601</int>
|
15
|
+
</value>
|
16
|
+
</member>
|
17
|
+
<member>
|
18
|
+
<name>faultString</name>
|
19
|
+
<value>
|
20
|
+
<string>server error. requested method ??? does not exist.</string>
|
21
|
+
</value>
|
22
|
+
</member>
|
23
|
+
</struct>
|
24
|
+
</value>
|
25
|
+
</member>
|
26
|
+
</struct>
|
27
|
+
</value>
|
28
|
+
</param>
|
29
|
+
</params>
|
30
|
+
</methodResponse>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<methodResponse>
|
3
|
+
<params>
|
4
|
+
<param>
|
5
|
+
<value>
|
6
|
+
<struct>
|
7
|
+
<member>
|
8
|
+
<name>fault</name>
|
9
|
+
<value>
|
10
|
+
<struct>
|
11
|
+
<member>
|
12
|
+
<name>faultCode</name>
|
13
|
+
<value>
|
14
|
+
<int>-32700</int>
|
15
|
+
</value>
|
16
|
+
</member>
|
17
|
+
<member>
|
18
|
+
<name>faultString</name>
|
19
|
+
<value>
|
20
|
+
<string>parse error. not well formed</string>
|
21
|
+
</value>
|
22
|
+
</member>
|
23
|
+
</struct>
|
24
|
+
</value>
|
25
|
+
</member>
|
26
|
+
</struct>
|
27
|
+
</value>
|
28
|
+
</param>
|
29
|
+
</params>
|
30
|
+
</methodResponse>
|
@@ -0,0 +1,182 @@
|
|
1
|
+
require File.expand_path('../helpers/spec_helper', __FILE__)
|
2
|
+
require File.expand_path('../../lib/shout-mouth-communicator', __FILE__)
|
3
|
+
|
4
|
+
describe "Shout Mouth RPC API" do
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@shout_mouth_client = ShoutMouthCommunicator.new("http://0.0.0.0:4000/xmlrpc.php", "1", "correct", "password")
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:each) do
|
11
|
+
@shout_mouth_client.client.http_header_extra = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should disallow authorization to the system when credentials are incorrect" do
|
15
|
+
shout_mouth_client = ShoutMouthCommunicator.new("http://0.0.0.0:4000/xmlrpc.php", "1", "wrong", "password")
|
16
|
+
shout_mouth_client.authorized?.should be_false
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should allow authorization to the system when the credentails are correct" do
|
20
|
+
@shout_mouth_client.authorized?.should be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return a list of correct tags" do
|
24
|
+
tags = @shout_mouth_client.tags
|
25
|
+
tags[0].should include "tag_id"=>"1"
|
26
|
+
tags[1].should include "tag_id"=>"2"
|
27
|
+
tags[2].should include "tag_id"=>"3"
|
28
|
+
tags[3].should include "tag_id"=>"4"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return the correct response when a tag is edited" do
|
32
|
+
response = @shout_mouth_client.edit_tag 1, "Boooooommmmmmm!"
|
33
|
+
response.should be_true
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return a list of correct categories" do
|
37
|
+
categories = @shout_mouth_client.categories
|
38
|
+
categories[0].should include "categoryId"=> "1"
|
39
|
+
categories[1].should include "categoryId"=> "2"
|
40
|
+
categories[2].should include "categoryId"=> "3"
|
41
|
+
categories[3].should include "categoryId"=> "4"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should return the correct response when a category has been created" do
|
45
|
+
response = @shout_mouth_client.new_category("Category123", "Category123 Description")
|
46
|
+
response.should == 5
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should return the correct response when a category is edited" do
|
50
|
+
response = @shout_mouth_client.edit_category(5, "edited")
|
51
|
+
response.should be_true
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should return a correct list of posts" do
|
55
|
+
posts = @shout_mouth_client.posts
|
56
|
+
posts.count.should == 2
|
57
|
+
posts[0]["title"].should == "This is how we roll"
|
58
|
+
posts[1]["title"].should == "New Post 1"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should return a post when the get_post method is called" do
|
62
|
+
post = @shout_mouth_client.post 1
|
63
|
+
post["title"].should == "This is how we roll"
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should return a correct response when a new post is added" do
|
67
|
+
response = @shout_mouth_client.new_post "title", "description", "category1,category2", "publish", DateTime.now, "tag1,tag2"
|
68
|
+
response.should == 4
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should return a correct response when a post is edited" do
|
72
|
+
response = @shout_mouth_client.edit_post 4, "title_edit", "description_edit", "category9,category10", "publish", DateTime.now, "tag9,tag10"
|
73
|
+
response.should be_true
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should return a correct response when the delete post method is called" do
|
77
|
+
response = @shout_mouth_client.delete_post 4
|
78
|
+
response.should be_true
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should return a correct list of pages when the pages method is called" do
|
82
|
+
pages = @shout_mouth_client.pages
|
83
|
+
pages.first["title"].should == "bang"
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should return a correct page when the page method is called" do
|
87
|
+
page = @shout_mouth_client.page 8
|
88
|
+
page["title"].should == "bang"
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should return a correct response when the new post method is called" do
|
92
|
+
response = @shout_mouth_client.new_page "new page 1", "body", "publish", 1, 0
|
93
|
+
response.should == 10
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should return a correct response when the edit page method is called" do
|
97
|
+
@shout_mouth_client.client.http_header_extra = {"response_file" => "edit_page"}
|
98
|
+
response = @shout_mouth_client.edit_page 10, "new page 123", "body", "publish", 1, 0
|
99
|
+
response.should == 10
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should return a correct response when the delete page method is called" do
|
103
|
+
response = @shout_mouth_client.delete_page 10
|
104
|
+
response.should be_true
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should return comments for a post when the get post comments methods is called" do
|
108
|
+
comments = @shout_mouth_client.comments_for_post 4
|
109
|
+
comments.first["user_id"].should == "ham@ok.com"
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should return no comments for a post when the get comments method is called with the spam flag" do
|
113
|
+
@shout_mouth_client.client.http_header_extra = {"response_file" => "get_comments_spam"}
|
114
|
+
@shout_mouth_client.comments_for_post(4, "spam").should be_empty
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should return all active comments when the comments method is called" do
|
118
|
+
@shout_mouth_client.client.http_header_extra = {"response_file" => "get_comments_all"}
|
119
|
+
comments = @shout_mouth_client.comments
|
120
|
+
comments.count.should == 2
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should return the correct response when the edit comment method is called" do
|
124
|
+
response = @shout_mouth_client.edit_comment(1, "comment_changed", "content", "http://google.com", "dan@dan.com", "active")
|
125
|
+
response.should be_true
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should return a list of avaliable settings for the shout mouth instance when the settings method is called" do
|
129
|
+
settings = @shout_mouth_client.settings
|
130
|
+
settings["software_name"]["value"].should == "Shout Mouth Blog Engine"
|
131
|
+
settings["administrator_email"]["value"].should == "admin@yourserver.com"
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should return a setting when a settings is edited" do
|
135
|
+
setting = @shout_mouth_client.edit_settings({"blog_title" => "ttle"})
|
136
|
+
setting["blog_title"]["value"].should == "ttle"
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should return all users when the user method is called" do
|
140
|
+
users = @shout_mouth_client.users
|
141
|
+
users.first["user_email"].should == "dan@shout_mouth.com"
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should return information about the current user when the current user method is called" do
|
145
|
+
user = @shout_mouth_client.current_user
|
146
|
+
user["firstname"].should == "Daniel"
|
147
|
+
user["lastname"].should == "Watson"
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should return true when the add use method is called" do
|
151
|
+
@shout_mouth_client.add_user("email@address.com", "password", "firstname", "lastname").should be_true
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should return true when the edit user method is called" do
|
155
|
+
@shout_mouth_client.edit_user("1", "email@address.com", "password", "firstname", "lastname").should be_true
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should return true when the delete user method is called" do
|
159
|
+
@shout_mouth_client.delete_user(1).should be_true
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should return the correct url when a file is uploaded" do
|
163
|
+
@shout_mouth_client.upload_file("Austria.gif", [])["url"].should == "http://0.0.0.0:4000/uploads/Austria.gif"
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should have errors if the response contains validation errors" do
|
167
|
+
@shout_mouth_client.client.http_header_extra = {"response_file" => "validation_error"}
|
168
|
+
@shout_mouth_client.edit_user("1", "email@addess.com", "password", "", "")
|
169
|
+
@shout_mouth_client.has_errors?.should be_true
|
170
|
+
@shout_mouth_client.errors.count.should == 3
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should raise an XmlParseError if the xml passed is blank" do
|
174
|
+
@shout_mouth_client.client.http_header_extra = {"response_file" => "xml_parse_error"}
|
175
|
+
lambda{ @shout_mouth_client.upload_file("",[]) }.should raise_error(XmlParseError)
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should raise an NoMethodError if there is a method called with no endpoint" do
|
179
|
+
@shout_mouth_client.client.http_header_extra = {"response_file" => "nomethod_error"}
|
180
|
+
lambda{ @shout_mouth_client.upload_file("",[])}.should raise_error(NoMethodError)
|
181
|
+
end
|
182
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: shout-mouth-communicator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Dan Watson
|
@@ -83,9 +83,12 @@ files:
|
|
83
83
|
- specs/fakes/xmlrpc_server_responses/new_media_object.xml
|
84
84
|
- specs/fakes/xmlrpc_server_responses/new_page.xml
|
85
85
|
- specs/fakes/xmlrpc_server_responses/new_post.xml
|
86
|
+
- specs/fakes/xmlrpc_server_responses/nomethod_error.xml
|
86
87
|
- specs/fakes/xmlrpc_server_responses/set_options.xml
|
87
88
|
- specs/fakes/xmlrpc_server_responses/validation_error.xml
|
89
|
+
- specs/fakes/xmlrpc_server_responses/xml_parse_error.xml
|
88
90
|
- specs/helpers/spec_helper.rb
|
91
|
+
- specs/shout_mouth_client_specification.rb
|
89
92
|
has_rdoc: true
|
90
93
|
homepage: https://github.com/dotnetguyuk/shout-mouth-communicator
|
91
94
|
licenses: []
|
@@ -143,6 +146,9 @@ test_files:
|
|
143
146
|
- specs/fakes/xmlrpc_server_responses/new_media_object.xml
|
144
147
|
- specs/fakes/xmlrpc_server_responses/new_page.xml
|
145
148
|
- specs/fakes/xmlrpc_server_responses/new_post.xml
|
149
|
+
- specs/fakes/xmlrpc_server_responses/nomethod_error.xml
|
146
150
|
- specs/fakes/xmlrpc_server_responses/set_options.xml
|
147
151
|
- specs/fakes/xmlrpc_server_responses/validation_error.xml
|
152
|
+
- specs/fakes/xmlrpc_server_responses/xml_parse_error.xml
|
148
153
|
- specs/helpers/spec_helper.rb
|
154
|
+
- specs/shout_mouth_client_specification.rb
|