allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [allura] 11/16: [#8375] ForgeImporters test fixes for py3
Date Thu, 27 Aug 2020 20:35:36 GMT
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8375
in repository https://gitbox.apache.org/repos/asf/allura.git

commit f6cfee7eece810ea7cecb5fb6a6b937ab9afb042
Author: Dave Brondsema <dave@brondsema.net>
AuthorDate: Tue Aug 25 18:02:03 2020 -0400

    [#8375] ForgeImporters test fixes for py3
---
 .../forgeimporters/tests/github/test_extractor.py  | 22 +++++++++++-----------
 .../forgeimporters/tests/github/test_tracker.py    |  4 ++--
 .../trac/tests/functional/test_trac.py             |  6 ++----
 3 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/ForgeImporters/forgeimporters/tests/github/test_extractor.py b/ForgeImporters/forgeimporters/tests/github/test_extractor.py
index a3c16f8..42c9818 100644
--- a/ForgeImporters/forgeimporters/tests/github/test_extractor.py
+++ b/ForgeImporters/forgeimporters/tests/github/test_extractor.py
@@ -63,24 +63,24 @@ class TestGitHubProjectExtractor(TestCase):
     def mocked_urlopen(self, url):
         headers = {}
         if url.endswith('/test_project'):
-            response = BytesIO(json.dumps(self.PROJECT_INFO))
+            response = BytesIO(json.dumps(self.PROJECT_INFO).encode('utf-8'))
         elif url.endswith('/issues?state=closed'):
-            response = BytesIO(json.dumps(self.CLOSED_ISSUES_LIST))
+            response = BytesIO(json.dumps(self.CLOSED_ISSUES_LIST).encode('utf-8'))
         elif url.endswith('/issues?state=open'):
-            response = BytesIO(json.dumps(self.OPENED_ISSUES_LIST))
+            response = BytesIO(json.dumps(self.OPENED_ISSUES_LIST).encode('utf-8'))
             headers = {'Link': '</issues?state=open&page=2>; rel="next"'}
         elif url.endswith('/issues?state=open&page=2'):
-            response = BytesIO(json.dumps(self.OPENED_ISSUES_LIST_PAGE2))
+            response = BytesIO(json.dumps(self.OPENED_ISSUES_LIST_PAGE2).encode('utf-8'))
         elif url.endswith('/comments'):
-            response = BytesIO(json.dumps(self.ISSUE_COMMENTS))
+            response = BytesIO(json.dumps(self.ISSUE_COMMENTS).encode('utf-8'))
             headers = {'Link': '</comments?page=2>; rel="next"'}
         elif url.endswith('/comments?page=2'):
-            response = BytesIO(json.dumps(self.ISSUE_COMMENTS_PAGE2))
+            response = BytesIO(json.dumps(self.ISSUE_COMMENTS_PAGE2).encode('utf-8'))
         elif url.endswith('/events'):
-            response = BytesIO(json.dumps(self.ISSUE_EVENTS))
+            response = BytesIO(json.dumps(self.ISSUE_EVENTS).encode('utf-8'))
             headers = {'Link': '</events?page=2>; rel="next"'}
         elif url.endswith('/events?page=2'):
-            response = BytesIO(json.dumps(self.ISSUE_EVENTS_PAGE2))
+            response = BytesIO(json.dumps(self.ISSUE_EVENTS_PAGE2).encode('utf-8'))
 
         response.info = lambda: headers
         return response
@@ -167,7 +167,7 @@ class TestGitHubProjectExtractor(TestCase):
         response_ok.info = lambda: {}
         urlopen.side_effect = [response_limit_exceeded, response_ok]
         e = github.GitHubProjectExtractor('test_project')
-        e.get_page('fake')
+        e.get_page('http://example.com/')
         self.assertEqual(sleep.call_count, 1)
         self.assertEqual(urlopen.call_count, 2)
         log.warn.assert_called_once_with(
@@ -180,7 +180,7 @@ class TestGitHubProjectExtractor(TestCase):
         response_ok = BytesIO(b'{}')
         response_ok.info = lambda: {}
         urlopen.side_effect = [response_ok]
-        e.get_page('fake 2')
+        e.get_page('http://example.com/2')
         self.assertEqual(sleep.call_count, 0)
         self.assertEqual(urlopen.call_count, 1)
         self.assertEqual(log.warn.call_count, 0)
@@ -204,7 +204,7 @@ class TestGitHubProjectExtractor(TestCase):
                 'url', 403, 'msg', limit_exceeded_headers, BytesIO(b'{}'))
         urlopen.side_effect = urlopen_side_effect
         e = github.GitHubProjectExtractor('test_project')
-        e.get_page('fake')
+        e.get_page('http://example.com/')
         self.assertEqual(sleep.call_count, 1)
         self.assertEqual(urlopen.call_count, 2)
         log.warn.assert_called_once_with(
diff --git a/ForgeImporters/forgeimporters/tests/github/test_tracker.py b/ForgeImporters/forgeimporters/tests/github/test_tracker.py
index 4f241bf..8064045 100644
--- a/ForgeImporters/forgeimporters/tests/github/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/github/test_tracker.py
@@ -150,8 +150,8 @@ class TestTrackerImporter(TestCase):
             attachments[0].url, 'https://f.cloud.github.com/assets/979771/1027411/a393ab5e-0e70-11e3-8a38-b93a3df904cf.jpg')
         self.assertEqual(
             attachments[1].url, 'http://f.cl.ly/items/13453x43053r2G0d3x0v/Screen%20Shot%202012-04-28%20at%2010.48.17%20AM.png')
-        self.assertEqual(attachments[0].file.read(), 'data')
-        self.assertEqual(attachments[1].file.read(), 'data')
+        self.assertEqual(attachments[0].file.read(), b'data')
+        self.assertEqual(attachments[1].file.read(), b'data')
 
     def test_get_attachments_404(self):
         importer = tracker.GitHubTrackerImporter()
diff --git a/ForgeImporters/forgeimporters/trac/tests/functional/test_trac.py b/ForgeImporters/forgeimporters/trac/tests/functional/test_trac.py
index 86626f2..fa34cec 100644
--- a/ForgeImporters/forgeimporters/trac/tests/functional/test_trac.py
+++ b/ForgeImporters/forgeimporters/trac/tests/functional/test_trac.py
@@ -25,7 +25,6 @@ from allura.lib import helpers as h
 from allura.tests import TestController
 
 
-
 class TestTracImportController(TestController):
 
     def test_index(self):
@@ -49,11 +48,10 @@ class TestTracImportController(TestController):
                 r.status_int,
                 r.location,
                 self.webflash(r),
-                hasattr(r, 'html') and r.html.find('div', {'class': 'error'})
+                hasattr(r, 'html') and r.html.find_all('div', {'class': 'error'})
             )
 
-
     def test_import_with_phone_validation(self):
         self.app.extra_environ = {'username': str('test-user')}
         with h.push_config(config, **{'project.verify_phone': 'true'}):
-            self.test_submit()
\ No newline at end of file
+            self.test_submit()


Mime
View raw message