aboutsummaryrefslogtreecommitdiffstats
path: root/test/mainapp
diff options
context:
space:
mode:
authorvrvarma <vikas.varma@att.com>2020-09-17 02:24:00 -0400
committervrvarma <vikas.varma@att.com>2020-09-17 04:52:05 -0400
commita55cbabaef4975d5007363e59d4560cb30a855e3 (patch)
treec30f83a71fee88744acbfd8bf8447c7ccbf24395 /test/mainapp
parent2024d8efab152980640b624402b6076da338ef7f (diff)
Fix osdf code after upgrading to py38
Fix osdf logging to work with 3.8 Fix osdf code that broke after migration Fix test cases after migration Fixing pep8 violations Change-Id: I11ca33959882c8b9010f00ff744d59c7eeb3c2f2 Signed-off-by: vrvarma <vikas.varma@att.com> Issue-ID: OPTFRA-796
Diffstat (limited to 'test/mainapp')
-rw-r--r--test/mainapp/test_osdfapp.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/test/mainapp/test_osdfapp.py b/test/mainapp/test_osdfapp.py
index d1f6d7e..e4f12e6 100644
--- a/test/mainapp/test_osdfapp.py
+++ b/test/mainapp/test_osdfapp.py
@@ -17,20 +17,25 @@
#
import unittest
+from unittest import TestCase
+from unittest import mock
+from unittest.mock import patch
+
+from requests import Request
+from requests import RequestException
+from schematics.exceptions import DataError
from osdf.apps import baseapp
+from osdf.apps.baseapp import app
from osdf.operation.exceptions import BusinessException
-from requests import Request, RequestException
-from schematics.exceptions import DataError
-from unittest import mock, TestCase
-from unittest.mock import patch
class TestOSDFApp(TestCase):
def setUp(self):
- self.patcher_g = patch('osdf.apps.baseapp.g', return_value={'request_id':'DUMMY-REQ'})
- self.Mock_g = self.patcher_g.start()
+ with app.app_context():
+ self.patcher_g = patch('osdf.apps.baseapp.g', return_value={'request_id': 'DUMMY-REQ'})
+ self.Mock_g = self.patcher_g.start()
# self.patcher2 = patch('package.module.Class2')
# self.MockClass2 = self.patcher2.start()
@@ -45,7 +50,7 @@ class TestOSDFApp(TestCase):
e.response.content = "Some request exception occurred"
# request().raise_for_status.side_effect = e
return e
-
+
def test_handle_business_exception(self):
e = BusinessException("Business Exception Description")
resp = baseapp.handle_business_exception(e)
@@ -67,9 +72,8 @@ class TestOSDFApp(TestCase):
assert resp.status_code == 500
def test_get_options_default(self):
- opts = baseapp.get_options(["PROG"]) # ensure nothing breaks
+ baseapp.get_options(["PROG"]) # ensure nothing breaks
if __name__ == "__main__":
unittest.main()
-