-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathuser_preferences_service_test.py
More file actions
37 lines (31 loc) · 1.65 KB
/
user_preferences_service_test.py
File metadata and controls
37 lines (31 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import json
import os
from pyopenproject.model.user_preferences import UserPreferences
from tests.test_cases.openproject_test_case import OpenProjectTestCase
class UserPreferencesServiceTestCase(OpenProjectTestCase):
def setUp(self):
super().setUp()
DATA = os.path.join(self.TEST_CASES, '../data/user_preferences.json')
self.userPrefSer = self.op.get_user_preferences_service()
with open(DATA) as f:
self.user_preferences = UserPreferences(json.load(f))
def test_find(self):
user_preferences = self.userPrefSer.find()
self.assertEqual(self.user_preferences.__dict__, user_preferences.__dict__)
# FIXME: We need an application user to update its preferences
# Actual user => {'href': '/api/v3/users/3', 'title': 'System'}
# {
# "_type":"Error",
# "errorIdentifier":"urn:openproject-org:api:v3:errors:Unauthenticated",
# "message":"You need to be authenticated to access this resource."
# }
def test_update(self):
user_preferences = self.userPrefSer.find()
user_preferences.timeZone = "Europe/London"
user_preferences.hideMail = False
# updated_user_preferences = self.userPrefSer.update(user_preferences)
# self.assertEqual(user_preferences.timeZone, updated_user_preferences.timeZone)
# self.assertEqual(user_preferences.hideMail, updated_user_preferences.hideMail)
# updated_user_preferences = self.userPrefSer.update(self.user_preferences)
# self.assertNotEqual(user_preferences.timeZone, updated_user_preferences.timeZone)
# self.assertNotEqual(user_preferences.hideMail, updated_user_preferences.hideMail)