Permalink
Browse files

Completed CWIGA GET calls, will do PUT's (create,login,send calls) to…

…morrow.
  • Loading branch information...
1 parent 2d32186 commit 0eab948f568c26677fe9274523e4c38676ff1ad1 @baphled committed Mar 28, 2009
Showing with 30 additions and 1 deletion.
  1. +6 −0 lib/chatterl/src/cwiga.erl
  2. +24 −1 lib/chatterl/src/test_cwiga.erl
@@ -61,8 +61,14 @@ handle('GET',"/users/list",ContentType,_Post) ->
success(chatterl_mid_man:user_list(ContentType),ContentType);
handle('GET',"/users/poll/" ++ Client,ContentType,_Post) ->
success(chatterl_mid_man:user_poll(ContentType,Client),ContentType);
+handle('GET',"/users/groups/" ++ Client,ContentType,_Post) ->
+ success(chatterl_mid_man:user_groups(ContentType,Client),ContentType);
+handle('GET',"/groups/poll/" ++ Group,ContentType,_Post) ->
+ success(chatterl_mid_man:group_poll(ContentType,Group),ContentType);
handle('GET',"/groups/list",ContentType,_Post) ->
success(chatterl_mid_man:group_list(ContentType),ContentType);
+handle('GET',"/groups/info/" ++ Group,ContentType,_Post) ->
+ success(chatterl_mid_man:group_info(ContentType,Group),ContentType);
handle(_,Path,ContentType,_) ->
Response = message_handler:get_response_body(ContentType,
message_handler:build_carrier("error", "Unknown command: " ++Path)),
@@ -44,6 +44,21 @@ handles_test_() ->
?assertEqual({struct,[{<<"clients">>,[]}]},check_json(mochijson2:decode(check_response(body,Response)))),
?assertEqual(<<"Group: blah doesn't exist">>,check_json(mochijson2:decode(check_response(body,Response2))))
end},
+ {"CWIGA can retrieve a groups information",
+ fun() ->
+ Response = http:request("http://127.0.0.1:8080/groups/info/" ++ Group),
+ Response2 = http:request("http://127.0.0.1:8080/groups/info/" ++ "blah"),
+ ?assertEqual(200,check_response(code,Response)),
+ ?assert(is_tuple(check_json(mochijson2:decode(check_response(body,Response))))),
+ ?assertEqual(<<"Group doesn't exist!">>,check_json(mochijson2:decode(check_response(body,Response2))))
+ end},
+ {"CWIGA can retrieve a groups messages",
+ fun() ->
+ Response = http:request("http://127.0.0.1:8080/groups/poll/" ++ Group),
+ Response2 = http:request("http://127.0.0.1:8080/groups/poll/" ++ "blah"),
+ ?assertEqual(200,check_response(code,Response)),
+ ?assertEqual(<<"Group: blah doesn't exist!">>,check_json(mochijson2:decode(check_response(body,Response2))))
+ end},
{"CWIGA can retrieve responses in XML format",
fun() ->
Response = http:request("http://127.0.0.1:8080/users/list.xml"),
@@ -81,7 +96,15 @@ groups_handle_test_() ->
chatterl_serv:stop(),
cwiga:stop()
end,
- [
+ [{"CWIGA allows clients to retrieves a list of the groups they are connected to",
+ fun() ->
+ Response = http:request("http://127.0.0.1:8080/users/groups/" ++ Client),
+ Response2 = http:request("http://127.0.0.1:8080/users/groups/" ++ "blah"),
+ ?assertEqual(200,check_response(code,Response)),
+ ?assertEqual(200,check_response(code,Response2)),
+ ?assertEqual({struct,[{<<"groups">>,[]}]},check_json(mochijson2:decode(check_response(body,Response)))),
+ ?assertEqual(<<"Client: blah doesn't exist">>,check_json(mochijson2:decode(check_response(body,Response2))))
+ end},
{"CWIGA allows clients to poll chatterl for messages",
fun() ->
Response = http:request("http://127.0.0.1:8080/users/poll/" ++ "blah"),

0 comments on commit 0eab948

Please sign in to comment.