@@ -67,6 +67,41 @@ def test_constructor(self):
6767 self .assertEqual (self .db .r_session , self .client .r_session )
6868 self .assertIsInstance (self .db .result , Result )
6969
70+ def test_bulk_docs_uses_custom_encoder (self ):
71+ """
72+ Test that the bulk_docs method uses the custom encoder
73+ """
74+ self .set_up_client (auto_connect = True , encoder = "AEncoder" )
75+ docs = [
76+ {'_id' : 'julia{0:03d}' .format (i ), 'name' : 'julia' , 'age' : i }
77+ for i in range (3 )
78+ ]
79+ database = self .client [self .test_dbname ]
80+ with self .assertRaises (TypeError ):
81+ # since the encoder is a str a type error should be thrown.
82+ database .bulk_docs (docs )
83+
84+ def test_missing_revisions_uses_custom_encoder (self ):
85+ """
86+ Test that missing_revisions uses the custom encoder.
87+ """
88+ revs = ['1-1' , '2-1' , '3-1' ]
89+ self .set_up_client (auto_connect = True , encoder = "AEncoder" )
90+ database = self .client [self .test_dbname ]
91+ with self .assertRaises (TypeError ):
92+ # since the encoder is a str a type error should be thrown.
93+ database .missing_revisions ('no-such-doc' , * revs )
94+
95+ def test_revs_diff_uses_custom_encoder (self ):
96+ """
97+ Test that revisions_diff uses the custom encoder.
98+ """
99+ revs = ['1-1' , '2-1' , '3-1' ]
100+ self .set_up_client (auto_connect = True , encoder = "AEncoder" )
101+ database = self .client [self .test_dbname ]
102+ with self .assertRaises (TypeError ):
103+ database .revisions_diff ('no-such-doc' , * revs )
104+
70105 def test_retrieve_db_url (self ):
71106 """
72107 Test retrieving the database URL
@@ -822,6 +857,27 @@ def tearDown(self):
822857 self .db_tear_down ()
823858 super (CloudantDatabaseTests , self ).tearDown ()
824859
860+ def test_share_database_uses_custom_encoder (self ):
861+ """
862+ Test that share_database uses custom encoder
863+ """
864+ share = 'user-{0}' .format (unicode_ (uuid .uuid4 ()))
865+ self .set_up_client (auto_connect = True , encoder = "AEncoder" )
866+ database = self .client [self .test_dbname ]
867+ with self .assertRaises (TypeError ):
868+ database .share_database (share )
869+
870+
871+ def test_unshare_database_uses_custom_encoder (self ):
872+ """
873+ Test that unshare_database uses custom encoder
874+ """
875+ share = 'user-{0}' .format (unicode_ (uuid .uuid4 ()))
876+ self .set_up_client (auto_connect = True , encoder = "AEncoder" )
877+ database = self .client [self .test_dbname ]
878+ with self .assertRaises (TypeError ):
879+ database .unshare_database (share )
880+
825881 def test_get_security_document (self ):
826882 """
827883 Test the retrieval of the security document.
0 commit comments