Migrate cube to Python3

  • Fix errors: - TypeError: 'float' object cannot be interpreted as an integer
  • Fix deprecation warnings: - DeprecationWarning: Please use assertEqual instead - DeprecationWarning: Please use assertTrue instead
authorNsukami Patrick <ptrck at nskm dot xyz>
changeset48aae07a4cb3
branchdefault
phasepublic
hiddenno
parent revision#c0284229c882 [flake8] fixes
child revision#d64df6e9653e [autopep8] E731 - Use a def when use do not assign a lambda expression
files modified by this revision
cubicweb_elasticsearch/views.py
test/test_elastic_search.py
# HG changeset patch
# User Nsukami Patrick <ptrck at nskm dot xyz>
# Date 1571055427 0
# Mon Oct 14 12:17:07 2019 +0000
# Node ID 48aae07a4cb39e6d25aaa62c237654051b7091d0
# Parent c0284229c8821000fe7e1c2d2471ec6abd80495a
Migrate cube to Python3

- Fix errors:
- TypeError: 'float' object cannot be interpreted as an integer

- Fix deprecation warnings:
- DeprecationWarning: Please use assertEqual instead
- DeprecationWarning: Please use assertTrue instead

diff --git a/cubicweb_elasticsearch/views.py b/cubicweb_elasticsearch/views.py
@@ -226,11 +226,11 @@
1              if current_page - 1 >= 1:
2                  ul(t.li(t.a(self.previous_link,
3                              href=xml_escape(self._cw.build_url(**url_params)))))
4              else:
5                  ul(t.li(t.a(self.previous_link)))
6 -            total_pages = min((response.hits.total / 10) + 2, 1000)
7 +            total_pages = min((response.hits.total // 10) + 2, 1000)
8              page_padding = 3
9 
10              if current_page > page_padding:
11                  for page in range(1,
12                                    min(page_padding + 1,
diff --git a/test/test_elastic_search.py b/test/test_elastic_search.py
@@ -62,11 +62,11 @@
13          sys.stdout = out = StringIO()
14          try:
15              ccplugin.IndexInES(None).main_run(cmd)
16          finally:
17              sys.stdout = sys.__stdout__
18 -        self.assertEquals('', out.getvalue())
19 +        self.assertEqual('', out.getvalue())
20          create.assert_not_called()
21          bulk.assert_not_called()
22 
23          # TODO try wrong option
24          # cmd = [self.appid, '--wrong-option', 'yes']
@@ -76,11 +76,11 @@
25          try:
26              ccplugin.IndexInES(None).main_run(cmd)
27          finally:
28              sys.stdout = sys.__stdout__
29          with self.admin_access.repo_cnx() as cnx:
30 -            self.assert_(cnx.execute('Any X WHERE X is %(etype)s' %
31 +            self.assertTrue(cnx.execute('Any X WHERE X is %(etype)s' %
32                                       {'etype': self.tested_etype}))
33          # TODO - put this somewhere where it tests on the first get_connection
34          # create.assert_called_with(ignore=400,
35          #                          index='unittest_index_name',
36          #                          body=INDEX_SETTINGS)