66from protos .objects import Profile , Listings , Following , Metadata , Followers , Node , FULL_CONE
77from protos .countries import CountryCode
88
9-
109class DatastoreTest (unittest .TestCase ):
1110 def setUp (self ):
11+
1212 self .db = Database (filepath = "test.db" )
1313 self .test_hash = "87e0555568bf5c7e4debd6645fc3f41e88df6ca8"
1414 self .test_hash2 = "97e0555568bf5c7e4debd6645fc3f41e88df6ca8"
@@ -104,10 +104,13 @@ def test_setProto(self):
104104 def test_addListing (self ):
105105 self .ls .delete_all_listings ()
106106 self .ls .add_listing (self .lm )
107+ self .ls .add_listing (self .lm )
108+
107109 l = self .ls .get_proto ()
108110 val = Listings ()
109111 val .ParseFromString (l )
110112 self .assertEqual (self .lm , val .listing [0 ])
113+ self .assertEqual (1 , len (val .listing ))
111114
112115 def test_deleteListing (self ):
113116 self .ls .delete_all_listings ()
@@ -141,21 +144,40 @@ def test_follow_unfollow(self):
141144 following = self .fd .get_following ()
142145 self .assertIsNotNone (following )
143146
147+ self .fd .follow (self .u )
144148 self .assertTrue (self .fd .is_following (self .u .guid ))
145149
146150 self .fd .unfollow (self .u .guid )
151+ self .fd .unfollow (self .f )
147152 following = self .fd .get_following ()
148153 self .assertEqual (following , '' )
149154 self .assertFalse (self .fd .is_following (self .u .guid ))
150155
151156 def test_deleteFollower (self ):
157+ self .fd .set_follower (self .f )
152158 self .fd .set_follower (self .f )
153159 f = self .fd .get_followers ()
154160 self .assertIsNotNone (f )
155161 self .fd .delete_follower (self .f .guid )
156162 f = self .fd .get_followers ()
157163 self .assertEqual (f , '' )
158164
165+ def test_convesations (self ):
166+ conversations = self .ms .get_conversations ()
167+ self .assertTrue (len (conversations ) == 0 )
168+ self .ms .save_message (self .u .guid , self .m .handle , self .u .signed_pubkey ,
169+ '' , 'SUBJECT' , 'CHAT' , 'MESSAGE' , '0000-00-00 00:00:00' ,
170+ '' , '' , '0' )
171+ # msgs = self.ms.get_unread()
172+ # self.assertEqual(1, len(msgs))
173+
174+ # self.ms.mark_as_read(self.u.guid)
175+ # msgs = self.ms.get_unread()
176+ # self.assertEqual(0, len(msgs))
177+
178+ conversations = self .ms .get_conversations ()
179+ self .assertIsNotNone (conversations )
180+
159181 def test_saveMessage (self ):
160182 msgs = self .ms .get_messages (self .u .guid , 'CHAT' )
161183 self .assertTrue (len (msgs ) == 0 )
@@ -175,6 +197,8 @@ def test_notificationStore(self):
175197 '0000-00-00 00:00:00' , '' , 0 )
176198 n = self .ns .get_notifications ()
177199 self .assertIsNotNone (n )
200+ self .ns .mark_as_read ("1234" )
201+
178202 self .ns .delete_notification ("1234" )
179203 n = self .ns .get_notifications ()
180204 self .assertTrue (len (n ) == 0 )
0 commit comments