src/notes/tests/api/sync.py
changeset 129 d48946d164c6
parent 128 34a75bd8d0b9
--- a/src/notes/tests/api/sync.py	Tue Jul 25 19:11:26 2017 +0200
+++ b/src/notes/tests/api/sync.py	Fri Jul 28 19:40:35 2017 +0200
@@ -3,6 +3,7 @@
 """
 import datetime
 import logging
+import uuid
 
 from django.contrib.auth import get_user_model
 from django.contrib.contenttypes.models import ContentType
@@ -40,15 +41,16 @@
             password='top_secret'
         )
 
+        self.clientId = str(uuid.uuid4())
+
         url = reverse('notes:session-list')
         self.client.login(username='test_user1', password='top_secret')
         response = self.client.post(url, {
             'title': "a new session 1",
             'description': "Description 1",
             'protocol': "[]"
-        }, format='json')
+        }, format='json', HTTP_AUDITLOG_CLIENT=self.clientId)
 
-        logger.debug('REPOSNSE %r', response.json())
 
         self.session1 = Session.objects.get(ext_id=response.json()['ext_id'])
         self.client.logout()
@@ -154,7 +156,16 @@
         for sync_def in json_resp['notes']:
             self.assertEqual('note', sync_def['type'])
             self.assertEqual(0, sync_def['action'])
-            self.assertIn(sync_def['ext_id'],[str(self.note1.ext_id), str(self.note2.ext_id)])
+            self.assertIn(sync_def['ext_id'], [str(self.note1.ext_id), str(self.note2.ext_id)])
+
+    def test_simple_output_client_id(self):
+        url = reverse('notes:sync-list')
+        self.client.login(username='test_user1', password='top_secret')
+        response = self.client.get(url, HTTP_AUDITLOG_CLIENT=self.clientId)
+        self.assertEqual(response.status_code, status.HTTP_200_OK)
+        json_resp = response.json()
+        self.assertIn('sessions', json_resp)
+        self.assertEqual(0, len(json_resp['sessions']))
 
     def test_modified_since_empty(self):
         url = reverse('notes:sync-list')