server/test/unittest_storage.py
branchstable
changeset 6340 470d8e828fda
parent 5877 0c7b7b76a84f
child 6382 4efd0f07fd53
--- a/server/test/unittest_storage.py	Fri Sep 24 18:20:57 2010 +0200
+++ b/server/test/unittest_storage.py	Fri Sep 24 18:20:59 2010 +0200
@@ -78,15 +78,15 @@
         expected_filepath = osp.join(self.tempdir, '%s_data_%s' %
                                      (f1.eid, f1.data_name))
         self.failUnless(osp.isfile(expected_filepath))
-        self.assertEquals(file(expected_filepath).read(), 'the-data')
+        self.assertEqual(file(expected_filepath).read(), 'the-data')
         self.rollback()
         self.failIf(osp.isfile(expected_filepath))
         f1 = self.create_file()
         self.commit()
-        self.assertEquals(file(expected_filepath).read(), 'the-data')
+        self.assertEqual(file(expected_filepath).read(), 'the-data')
         f1.set_attributes(data=Binary('the new data'))
         self.rollback()
-        self.assertEquals(file(expected_filepath).read(), 'the-data')
+        self.assertEqual(file(expected_filepath).read(), 'the-data')
         f1.cw_delete()
         self.failUnless(osp.isfile(expected_filepath))
         self.rollback()
@@ -98,14 +98,14 @@
     def test_bfss_sqlite_fspath(self):
         f1 = self.create_file()
         expected_filepath = osp.join(self.tempdir, '%s_data_%s' % (f1.eid, f1.data_name))
-        self.assertEquals(self.fspath(f1), expected_filepath)
+        self.assertEqual(self.fspath(f1), expected_filepath)
 
     def test_bfss_fs_importing_doesnt_touch_path(self):
         self.session.transaction_data['fs_importing'] = True
         filepath = osp.abspath(__file__)
         f1 = self.session.create_entity('File', data=Binary(filepath),
                                         data_format=u'text/plain', data_name=u'foo')
-        self.assertEquals(self.fspath(f1), filepath)
+        self.assertEqual(self.fspath(f1), filepath)
 
     def test_source_storage_transparency(self):
         with self.temporary_appobjects(DummyBeforeHook, DummyAfterHook):
@@ -114,11 +114,11 @@
     def test_source_mapped_attribute_error_cases(self):
         ex = self.assertRaises(QueryError, self.execute,
                                'Any X WHERE X data ~= "hop", X is File')
-        self.assertEquals(str(ex), 'can\'t use File.data (X data ILIKE "hop") in restriction')
+        self.assertEqual(str(ex), 'can\'t use File.data (X data ILIKE "hop") in restriction')
         ex = self.assertRaises(QueryError, self.execute,
                                'Any X, Y WHERE X data D, Y data D, '
                                'NOT X identity Y, X is File, Y is File')
-        self.assertEquals(str(ex), "can't use D as a restriction variable")
+        self.assertEqual(str(ex), "can't use D as a restriction variable")
         # query returning mix of mapped / regular attributes (only file.data
         # mapped, not image.data for instance)
         ex = self.assertRaises(QueryError, self.execute,
@@ -127,19 +127,19 @@
                                '  UNION '
                                ' (Any D WHERE X data D, X is File)'
                                ')')
-        self.assertEquals(str(ex), 'query fetch some source mapped attribute, some not')
+        self.assertEqual(str(ex), 'query fetch some source mapped attribute, some not')
         ex = self.assertRaises(QueryError, self.execute,
                                '(Any D WHERE X data D, X is File)'
                                ' UNION '
                                '(Any D WHERE X title D, X is Bookmark)')
-        self.assertEquals(str(ex), 'query fetch some source mapped attribute, some not')
+        self.assertEqual(str(ex), 'query fetch some source mapped attribute, some not')
 
         storages.set_attribute_storage(self.repo, 'State', 'name',
                                        storages.BytesFileSystemStorage(self.tempdir))
         try:
             ex = self.assertRaises(QueryError,
                                    self.execute, 'Any D WHERE X name D, X is IN (State, Transition)')
-            self.assertEquals(str(ex), 'query fetch some source mapped attribute, some not')
+            self.assertEqual(str(ex), 'query fetch some source mapped attribute, some not')
         finally:
             storages.unset_attribute_storage(self.repo, 'State', 'name')
 
@@ -150,30 +150,30 @@
                             '  UNION '
                             ' (Any D, X WHERE X eid %(x)s, X data D)'
                             ')', {'x': f1.eid})
-        self.assertEquals(len(rset), 2)
-        self.assertEquals(rset[0][0], f1.eid)
-        self.assertEquals(rset[1][0], f1.eid)
-        self.assertEquals(rset[0][1].getvalue(), 'the-data')
-        self.assertEquals(rset[1][1].getvalue(), 'the-data')
+        self.assertEqual(len(rset), 2)
+        self.assertEqual(rset[0][0], f1.eid)
+        self.assertEqual(rset[1][0], f1.eid)
+        self.assertEqual(rset[0][1].getvalue(), 'the-data')
+        self.assertEqual(rset[1][1].getvalue(), 'the-data')
         rset = self.execute('Any X,LENGTH(D) WHERE X eid %(x)s, X data D',
                             {'x': f1.eid})
-        self.assertEquals(len(rset), 1)
-        self.assertEquals(rset[0][0], f1.eid)
-        self.assertEquals(rset[0][1], len('the-data'))
+        self.assertEqual(len(rset), 1)
+        self.assertEqual(rset[0][0], f1.eid)
+        self.assertEqual(rset[0][1], len('the-data'))
         rset = self.execute('Any X,LENGTH(D) WITH D,X BEING ('
                             ' (Any D, X WHERE X eid %(x)s, X data D)'
                             '  UNION '
                             ' (Any D, X WHERE X eid %(x)s, X data D)'
                             ')', {'x': f1.eid})
-        self.assertEquals(len(rset), 2)
-        self.assertEquals(rset[0][0], f1.eid)
-        self.assertEquals(rset[1][0], f1.eid)
-        self.assertEquals(rset[0][1], len('the-data'))
-        self.assertEquals(rset[1][1], len('the-data'))
+        self.assertEqual(len(rset), 2)
+        self.assertEqual(rset[0][0], f1.eid)
+        self.assertEqual(rset[1][0], f1.eid)
+        self.assertEqual(rset[0][1], len('the-data'))
+        self.assertEqual(rset[1][1], len('the-data'))
         ex = self.assertRaises(QueryError, self.execute,
                                'Any X,UPPER(D) WHERE X eid %(x)s, X data D',
                                {'x': f1.eid})
-        self.assertEquals(str(ex), 'UPPER can not be called on mapped attribute')
+        self.assertEqual(str(ex), 'UPPER can not be called on mapped attribute')
 
 
     def test_bfss_fs_importing_transparency(self):
@@ -181,7 +181,7 @@
         filepath = osp.abspath(__file__)
         f1 = self.session.create_entity('File', data=Binary(filepath),
                                         data_format=u'text/plain', data_name=u'foo')
-        self.assertEquals(f1.data.getvalue(), file(filepath).read(),
+        self.assertEqual(f1.data.getvalue(), file(filepath).read(),
                           'files content differ')
 
     @tag('Storage', 'BFSS', 'update')
@@ -193,10 +193,10 @@
         #       update f1's local dict. We want the pure rql version to work
         self.execute('SET F data %(d)s WHERE F eid %(f)s',
                      {'d': Binary('some other data'), 'f': f1.eid})
-        self.assertEquals(f1.data.getvalue(), 'some other data')
+        self.assertEqual(f1.data.getvalue(), 'some other data')
         self.commit()
         f2 = self.execute('Any F WHERE F eid %(f)s, F is File', {'f': f1.eid}).get_entity(0, 0)
-        self.assertEquals(f2.data.getvalue(), 'some other data')
+        self.assertEqual(f2.data.getvalue(), 'some other data')
 
     @tag('Storage', 'BFSS', 'update', 'extension', 'commit')
     def test_bfss_update_with_different_extension_commited(self):
@@ -208,7 +208,7 @@
         self.commit()
         old_path = self.fspath(f1)
         self.failUnless(osp.isfile(old_path))
-        self.assertEquals(osp.splitext(old_path)[1], '.txt')
+        self.assertEqual(osp.splitext(old_path)[1], '.txt')
         self.execute('SET F data %(d)s, F data_name %(dn)s, F data_format %(df)s WHERE F eid %(f)s',
                      {'d': Binary('some other data'), 'f': f1.eid, 'dn': u'bar.jpg', 'df': u'image/jpeg'})
         self.commit()
@@ -218,7 +218,7 @@
         new_path = self.fspath(f2)
         self.failIf(osp.isfile(old_path))
         self.failUnless(osp.isfile(new_path))
-        self.assertEquals(osp.splitext(new_path)[1], '.jpg')
+        self.assertEqual(osp.splitext(new_path)[1], '.jpg')
 
     @tag('Storage', 'BFSS', 'update', 'extension', 'rollback')
     def test_bfss_update_with_different_extension_rollbacked(self):
@@ -231,7 +231,7 @@
         old_path = self.fspath(f1)
         old_data = f1.data.getvalue()
         self.failUnless(osp.isfile(old_path))
-        self.assertEquals(osp.splitext(old_path)[1], '.txt')
+        self.assertEqual(osp.splitext(old_path)[1], '.txt')
         self.execute('SET F data %(d)s, F data_name %(dn)s, F data_format %(df)s WHERE F eid %(f)s',
                      {'d': Binary('some other data'), 'f': f1.eid, 'dn': u'bar.jpg', 'df': u'image/jpeg'})
         self.rollback()
@@ -241,9 +241,9 @@
         new_path = self.fspath(f2)
         new_data = f2.data.getvalue()
         self.failUnless(osp.isfile(new_path))
-        self.assertEquals(osp.splitext(new_path)[1], '.txt')
-        self.assertEquals(old_path, new_path)
-        self.assertEquals(old_data, new_data)
+        self.assertEqual(osp.splitext(new_path)[1], '.txt')
+        self.assertEqual(old_path, new_path)
+        self.assertEqual(old_data, new_data)
 
     def test_bfss_update_with_fs_importing(self):
         # use self.session to use server-side cache
@@ -256,8 +256,8 @@
         self.execute('SET F data %(d)s WHERE F eid %(f)s',
                      {'d': Binary(new_fspath), 'f': f1.eid})
         self.commit()
-        self.assertEquals(f1.data.getvalue(), 'the new data')
-        self.assertEquals(self.fspath(f1), new_fspath)
+        self.assertEqual(f1.data.getvalue(), 'the new data')
+        self.assertEqual(self.fspath(f1), new_fspath)
         self.failIf(osp.isfile(old_fspath))