From e08eb7c1f4f9b2ac56433a465a4b07bbfc7e8530 Mon Sep 17 00:00:00 2001 From: Steven Blowers Date: Tue, 22 Nov 2016 13:37:00 +0000 Subject: trying out using meck on tickets module --- lib/http_client/in_memory.ex | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'lib/http_client/in_memory.ex') diff --git a/lib/http_client/in_memory.ex b/lib/http_client/in_memory.ex index a448afd..eabe99f 100644 --- a/lib/http_client/in_memory.ex +++ b/lib/http_client/in_memory.ex @@ -6,11 +6,6 @@ defmodule Zendex.HttpClient.InMemory do @base_url "http://test.zendesk.com" - def get!(@base_url <> "/api/v2/tickets.json", - [{"Authorization", _authentication}]) do - fake_response("ticket") - end - def get!(@base_url <> "/api/v2/search.json?query=requester%3AJimbob+type%3Aticket", [{"Authorization", _authentication}]) do fake_response(["Jimbob Ticket 1", "Jimbob Ticket 2"]) @@ -37,12 +32,6 @@ defmodule Zendex.HttpClient.InMemory do %{id: 67, name: "Sarpedon Baumgartner"}]}) end - def post!(@base_url <> "/api/v2/tickets.json", - "{\"ticket\":{}}", - [{"Authorization", _authentication}, {"Content-Type", "application/json"}]) do - fake_response("Ticket created successfully!") - end - def post!(@base_url <> "/api/v2/users.json", "{\"user\":{\"name\":\"Roger\",\"email\":\"roger@dodger.com\"}}", [{"Authorization", _authentication}, {"Content-Type", "application/json"}]) do -- cgit v1.2.1 From 7f7ab146f85c4eb4f9645b0d70109fd278e9561d Mon Sep 17 00:00:00 2001 From: Steven Blowers Date: Tue, 22 Nov 2016 19:13:16 +0000 Subject: removing unused in memory functions --- lib/http_client/in_memory.ex | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'lib/http_client/in_memory.ex') diff --git a/lib/http_client/in_memory.ex b/lib/http_client/in_memory.ex index 934115f..25f1def 100644 --- a/lib/http_client/in_memory.ex +++ b/lib/http_client/in_memory.ex @@ -6,16 +6,6 @@ defmodule Zendex.HttpClient.InMemory do @base_url "http://test.zendesk.com" - def get!(@base_url <> "/api/v2/search.json?query=requester%3AJimbob+type%3Aticket", - [{"Authorization", _authentication}]) do - fake_response(["Jimbob Ticket 1", "Jimbob Ticket 2"]) - end - - def get!(@base_url <> "/api/v2/search.json?query=requester%3AReginald+type%3Aticket&sort_by=created_at&sort_order=desc", - [{"Authorization", _authentication}]) do - fake_response(["Reginald Ticket 1", "Reginald Ticket 2"]) - end - def get!(@base_url <> "/api/v2/users.json", [{"Authorization", _authentication}]) do fake_response("users") -- cgit v1.2.1 From 1bfac92a35eb752c4ed6cc4a510d11786d1a01c8 Mon Sep 17 00:00:00 2001 From: Steven Blowers Date: Tue, 22 Nov 2016 19:39:45 +0000 Subject: finishing off using meck. had to delete doctests, as they don't work with meck --- lib/http_client/in_memory.ex | 117 ------------------------------------------- 1 file changed, 117 deletions(-) delete mode 100644 lib/http_client/in_memory.ex (limited to 'lib/http_client/in_memory.ex') diff --git a/lib/http_client/in_memory.ex b/lib/http_client/in_memory.ex deleted file mode 100644 index 25f1def..0000000 --- a/lib/http_client/in_memory.ex +++ /dev/null @@ -1,117 +0,0 @@ -defmodule Zendex.HttpClient.InMemory do - @moduledoc """ - Allows testing of the Zendex project by mocking out calls to an actual Zendesk - API. - """ - - @base_url "http://test.zendesk.com" - - def get!(@base_url <> "/api/v2/users.json", - [{"Authorization", _authentication}]) do - fake_response("users") - end - - def get!("#{@base_url}/api/v2/users/295204.json", - [{"Authorization", _authentication}]) do - fake_response(%{"user" => %{"ticket_restriction" => nil, - "chat_only" => false, - "shared_phone_number" => nil, - "notes" => "", - "phone" => nil, - "organization_id" => 11129520411, - "last_login_at" => "2016-10-28T21:08:23Z", - "moderator" => true, - "shared" => false, - "id" => 295204, - "role" => "admin", - "external_id" => nil, - "shared_agent" => false, - "photo" => nil, - "verified" => true, - "active" => true, - "locale_id" => 1, - "suspended" => false, - "created_at" => "2015-05-28T09:12:45Z", - "name" => "Nikolao Aikema", - "restricted_agent" => false, - "locale" => "en-US", - "details" => "", - "alias" => nil, - "url" => "https://test.zendesk.com/api/v2/users/295204.json", - "custom_role_id" => nil, - "email" => "nikolao.aikema@test.com", - "signature" => nil, - "two_factor_auth_enabled" => nil, - "time_zone" => "London", - "only_private_comments" => false, - "user_fields" => %{"customer_complaint" => nil}, - "tags" => [], - "updated_at" => "2016-10-28T21:08:23Z"}}) - end - - def get!("#{@base_url}/api/v2/users/show_many.json?ids=6,67", - [{"Authorization", _authentication}]) do - fake_response(%{users: [%{id: 6, name: "Kiki Segal"}, - %{id: 67, name: "Sarpedon Baumgartner"}]}) - end - - def get!("#{@base_url}/api/v2/users/649267/related.json", - [{"Authorization", _authentication}]) do - fake_response(%{"user_related" => %{"assigned_tickets" => 12, - "ccd_tickets" => 5, - "entry_subscriptions" => 1, - "forum_subscriptions" => 3, - "organization_subscriptions" => 1, - "requested_tickets" => 7, - "subscriptions" => 6, - "topic_comments" => 116, - "topics" => 5, - "votes" => 2001}}) - end - - def post!(@base_url <> "/api/v2/users.json", - "{\"user\":{\"name\":\"Roger\",\"email\":\"roger@dodger.com\"}}", - [{"Authorization", _authentication}, {"Content-Type", "application/json"}]) do - fake_response(%{user: %{id: 1234, name: "Roger", email: "roger@dodger.com"}}) - end - - def delete!("#{@base_url}/api/v2/users/49043.json", - [{"Authorization", _authentication}]) do - fake_response(%{"user" => %{"ticket_restriction" => nil, - "chat_only" => false, - "shared_phone_number" => nil, - "notes" => "", - "phone" => nil, - "organization_id" => 149043, - "last_login_at" => "2016-10-28T21:08:23Z", - "moderator" => true, - "shared" => false, - "id" => 49043, - "role" => "admin", - "external_id" => nil, - "shared_agent" => false, - "photo" => nil, - "verified" => true, - "active" => false, - "locale_id" => 1, - "suspended" => false, - "created_at" => "2015-05-28T09:12:45Z", - "name" => "Rian Hawkins", - "restricted_agent" => false, - "locale" => "en-US", - "details" => "", - "alias" => nil, - "url" => "https://test.zendesk.com/api/v2/users/49043.json", - "custom_role_id" => nil, - "email" => "rian.hawkins@test.com", - "signature" => nil, - "two_factor_auth_enabled" => nil, - "time_zone" => "London", - "only_private_comments" => false, - "user_fields" => %{"customer_complaint" => nil}, - "tags" => [], - "updated_at" => "2016-10-28T21:08:23Z"}}) - end - - defp fake_response(body), do: %{body: Poison.encode!(body)} -end -- cgit v1.2.1