11import unittest
2+ import json
23from configcatclient .user import User
34
45
@@ -10,13 +11,35 @@ def test_empty_or_none_identifier(self):
1011 self .assertEqual ('' , u2 .get_identifier ())
1112
1213 def test_attribute_case_sensitivity (self ):
14+ user_id = 'id'
13151416 country = 'country'
15- user = User ('user_id' , email = email , country = country )
16- self .assertEqual (email , user .get_attribute ("Email" ))
17- self .assertIsNone (user .get_attribute ("EMAIL" ))
18- self .assertIsNone (user .get_attribute ("email" ))
19-
20- self .assertEqual (country , user .get_attribute ("Country" ))
21- self .assertIsNone (user .get_attribute ("COUNTRY" ))
22- self .assertIsNone (user .get_attribute ("country" ))
17+ custom = {'custom' : 'test' }
18+ user = User (identifier = user_id , email = email , country = country , custom = custom )
19+
20+ self .assertEqual (user_id , user .get_identifier ())
21+
22+ self .assertEqual (email , user .get_attribute ('Email' ))
23+ self .assertIsNone (user .get_attribute ('EMAIL' ))
24+ self .assertIsNone (user .get_attribute ('email' ))
25+
26+ self .assertEqual (country , user .get_attribute ('Country' ))
27+ self .assertIsNone (user .get_attribute ('COUNTRY' ))
28+ self .assertIsNone (user .get_attribute ('country' ))
29+
30+ self .assertEqual ('test' , user .get_attribute ('custom' ))
31+ self .assertIsNone (user .get_attribute ('non-existing' ))
32+
33+ def test_to_str (self ):
34+ user_id = 'id'
35+ 36+ country = 'country'
37+ custom = {'custom' : 'test' }
38+ user = User (identifier = user_id , email = email , country = country , custom = custom )
39+
40+ user_json = json .loads (str (user ))
41+
42+ self .assertEqual (user_id , user_json ['Identifier' ])
43+ self .assertEqual (email , user_json ['Email' ])
44+ self .assertEqual (country , user_json ['Country' ])
45+ self .assertEqual (custom , user_json ['Custom' ])
0 commit comments