import unittest
from blueprints.settings import testConfig
from blueprints.requestResult import requestResult
from blueprints.tools.asertcase import asertcase
from blueprints.tools.dealCasefile import readCaseFile
class maintest(unittest.TestCase):
   def __init__(self, methodName='runTest', config=None):
       super(maintest, self).__init__(methodName)
       self.config = config
   @staticmethod
   def parametrize(testcase_klass, config=None):
       testloader = unittest.TestLoader()
       testnames = testloader.getTestCaseNames(testcase_klass) 
       suite = unittest.TestSuite()
       for name in testnames:
           print('name====',name)
           suite.addTest(testcase_klass(name, config=config))
       return suite

class zhongtai_hetong0(maintest):
   def test_100(self):
       res1=requestResult(self.config,'/Users/dm/Desktop/python_script/autoInterface/testCase/zhongtai_hetong/277.json')
       res,finalresult=res1.requestJson()
       t=readCaseFile('/Users/dm/Desktop/python_script/autoInterface/testCase/zhongtai_hetong/277.json').get('result')
       r=0 if 0 in finalresult and len(finalresult)>0 else 1
       if r:
           self.detail=res1.keyoption()+('Success',)
       else:
           if isinstance(res,dict):
               self.detail=res1.keyoption()+(res.__str__(),)
           elif len(res.text)>5000 :
               self.detail=res1.keyoption()+('响应数据过长',)
           else:
               self.detail=res1.keyoption()+(res.text,)
       if r==0:
           msg='断言失败，预期结果：'+str(t)+',实际结果查看响应数据'
           self.assertEqual(1, 0,msg=msg)
       else :
           msg='断言成功，预期结果：'+str(t)+',实际结果查看响应数据'
           self.assertEqual(0, 0,msg=msg)

