From 2b06239b3c405f269c0f5f0edfaeac7221ad6523 Mon Sep 17 00:00:00 2001
From: Nico Alt <nicoalt@posteo.org>
Date: Sun, 7 Mar 2021 12:00:18 +0100
Subject: [PATCH] Add unit tests

---
 tests/briar_wrapper/models/test_contacts.py | 22 +++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/tests/briar_wrapper/models/test_contacts.py b/tests/briar_wrapper/models/test_contacts.py
index 2017565..6a00d0c 100644
--- a/tests/briar_wrapper/models/test_contacts.py
+++ b/tests/briar_wrapper/models/test_contacts.py
@@ -14,6 +14,7 @@ BASE_HTTP_URL = "http://localhost:7000/v1/contacts/"
 
 TEST_ALIAS = "Alice"
 TEST_CONTACT_ID = 42
+TEST_PENDING_CONTACT_ID = "jsTgWcsEQ2g9rnomeK1g/hmO8M1Ix6ZIGWAjgBtlS9U="
 
 TEST_CONTACT_FIRST = {
     "lastChatActivity": 1
@@ -50,6 +51,27 @@ def match_request_add_pending(request):
     return {"alias": TEST_ALIAS, "link": TEST_LINK} == request.json()
 
 
+@requests_mock.Mocker(kw="requests_mock")
+def test_add_pending_error(api, request_headers, requests_mock):
+    contacts = Contacts(api)
+    requests_mock.post(BASE_HTTP_URL + "add/pending/", status_code=400)
+    contacts.add_pending(TEST_LINK, TEST_ALIAS)
+
+
+@requests_mock.Mocker(kw="requests_mock")
+def test_delete_pending(api, request_headers, requests_mock):
+    contacts = Contacts(api)
+    requests_mock.register_uri("DELETE",
+                               BASE_HTTP_URL + "add/pending/",
+                               request_headers=request_headers,
+                               additional_matcher=match_request_delete_pending)
+    contacts.delete_pending(TEST_PENDING_CONTACT_ID)
+
+
+def match_request_delete_pending(request):
+    return {"pendingContactId": TEST_PENDING_CONTACT_ID} == request.json()
+
+
 @requests_mock.Mocker(kw="requests_mock")
 def test_set_alias(api, request_headers, requests_mock):
     contacts = Contacts(api)
-- 
GitLab