mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
9628253fd8
Summary: There is a new column in users table called ref (user reference). It holds user's unique reference number that can be used for features that require some kind of ownership logic (like comments). Test Plan: Updated tests Reviewers: georgegevoian, paulfitz Reviewed By: georgegevoian, paulfitz Differential Revision: https://phab.getgrist.com/D3641
61 lines
1.9 KiB
Python
61 lines
1.9 KiB
Python
from user import User
|
|
import test_engine
|
|
import testsamples
|
|
|
|
class TestUser(test_engine.EngineTestCase):
|
|
# pylint: disable=no-member
|
|
def setUp(self):
|
|
super(TestUser, self).setUp()
|
|
self.load_sample(testsamples.sample_students)
|
|
|
|
def test_constructor_sets_user_attributes(self):
|
|
data = {
|
|
'Access': 'owners',
|
|
'Name': 'Foo Bar',
|
|
'Email': 'email@example.com',
|
|
'UserID': 1,
|
|
'UserRef': '1',
|
|
'LinkKey': {
|
|
'Param1': 'Param1Value',
|
|
'Param2': 'Param2Value'
|
|
},
|
|
'Origin': 'https://getgrist.com',
|
|
'StudentInfo': ['Students', 1],
|
|
'SessionID': 'u1',
|
|
'IsLoggedIn': True
|
|
}
|
|
u = User(data, self.engine.tables)
|
|
self.assertEqual(u.Name, 'Foo Bar')
|
|
self.assertEqual(u.Email, 'email@example.com')
|
|
self.assertEqual(u.UserID, 1)
|
|
self.assertEqual(u.LinkKey.Param1, 'Param1Value')
|
|
self.assertEqual(u.LinkKey.Param2, 'Param2Value')
|
|
self.assertEqual(u.Access, 'owners')
|
|
self.assertEqual(u.Origin, 'https://getgrist.com')
|
|
self.assertEqual(u.StudentInfo.id, 1)
|
|
self.assertEqual(u.StudentInfo.firstName, 'Barack')
|
|
self.assertEqual(u.StudentInfo.lastName, 'Obama')
|
|
self.assertEqual(u.StudentInfo.schoolName, 'Columbia')
|
|
|
|
def test_setting_is_sample_substitutes_attributes_with_samples(self):
|
|
data = {
|
|
'Access': 'owners',
|
|
'Name': None,
|
|
'Email': 'email@getgrist.com',
|
|
'UserID': 1,
|
|
'UserRef': '1',
|
|
'LinkKey': {
|
|
'Param1': 'Param1Value',
|
|
'Param2': 'Param2Value'
|
|
},
|
|
'Origin': 'https://getgrist.com',
|
|
'StudentInfo': ['Students', 1],
|
|
'SessionID': 'u1',
|
|
'IsLoggedIn': True
|
|
}
|
|
u = User(data, self.engine.tables, is_sample=True)
|
|
self.assertEqual(u.StudentInfo.id, 0)
|
|
self.assertEqual(u.StudentInfo.firstName, '')
|
|
self.assertEqual(u.StudentInfo.lastName, '')
|
|
self.assertEqual(u.StudentInfo.schoolName, '')
|