def test_user_to_json(self): """Tests converting a user to JSON.""" u = User( name="someuser", password="******", mail="*****@*****.**", display_name="Some User", created="1234", ) json = u.to_json() self.assertTrue('"principalTypeEnum":"LOCAL_USER"' in json) self.assertTrue('"name":"someuser"' in json) self.assertTrue('"password":"******"' in json) self.assertTrue('"mail":"*****@*****.**"' in json) self.assertTrue('"displayName":"Some User"' in json) self.assertTrue('"visibility":"' + Visibility.DEFAULT + '"' in json) self.assertTrue('"created":"' + "1234" + '"' in json) self.assertTrue(json[0], "{") self.assertTrue(json.endswith("}"))
def test_non_shareable_user_to_json(self): """Tests converting a non-shareable user to JSON.""" u = User( name="someuser", password="******", mail="*****@*****.**", display_name="Some User", visibility=Visibility.NON_SHAREABLE, ) json = u.to_json() self.assertTrue('"principalTypeEnum":"LOCAL_USER"' in json) self.assertTrue('"name":"someuser"' in json) self.assertTrue('"password":"******"' in json) self.assertTrue('"mail":"*****@*****.**"' in json) self.assertTrue('"displayName":"Some User"' in json) self.assertTrue('"visibility":"' + Visibility.NON_SHAREABLE + '"' in json) self.assertTrue(json[0], "{") self.assertTrue(json.endswith("}"))
def test_blank_values_in_json(self): """Tests missing values are being left out of JSON""" u = User("user1") json = u.to_json() self.assertFalse(", ," in json)