コード例 #1
0
 def setup_method(self, _):
     dirName = 'forms'
     formDirName = osp.join(dirName, 'static', 'pdf')
     theForm = 'f1040.pdf'
     dbpath = 'sqlite:///' + ut.Resource('test',
                                         'opentaxforms.sqlite3').path()
     if not osp.exists(formDirName):
         os.makedirs(formDirName)
     formpath = osp.join(formDirName, theForm)
     if not osp.exists(formpath):
         formResourcePath = ut.Resource('test',
                                        osp.join('forms-common',
                                                 theForm)).path()
         shutil.copy(formResourcePath, formpath)
     filesToCleanup = 'failurls.pickl'.split()
     for f in filesToCleanup:
         if osp.exists(f):
             os.remove(f)
     self.defaultArgs = dict(
         # skip cleanupFiles to allow comparison with target output
         #skip=['c'],
         dirName=dirName,
         # todo change dbpath to dburl
         dbpath=dbpath,
     )
コード例 #2
0
    def run(self, **kw):
        checkDependencies()
        #rootForms=kw.get('rootForms') or ['1040']
        rootForms = kw.get('rootForms') or '1040'
        filesToCheck = kw.get('filesToCheck') or [
            'f%s-p1.html' % (form, ) for form in rootForms
        ]
        kw.update(self.defaultArgs)
        from opentaxforms import main as otf
        returnval = otf.opentaxforms(okToDownload=False, **kw)
        if returnval != 0:
            raise Exception('run failed, no output to compare against target')
        import filecmp
        shallow = False
        outdir = 'forms'
        targetdir = ut.Resource('test', 'forms-targetOutput').path()

        def fmtmsg(result, verb):
            return '{}: output file "{}" in "{}" {} target in "{}"'.format(
                result, fileToCheck, outdir, verb, targetdir)

        for fileToCheck in filesToCheck:
            filesMatch = filecmp.cmp(osp.join(outdir, fileToCheck),
                                     osp.join(targetdir, fileToCheck), shallow)
            if filesMatch:
                result, verb = 'PASS', 'matches'
                print(fmtmsg(result, verb))
            else:
                result, verb = 'FAIL', 'does NOT match'
                raise Exception(fmtmsg(result, verb))
コード例 #3
0
 def setup_method(self):
     '''setup'''
     self.testdir = ut.Resource('test', '').path()
     dbpath = 'sqlite:///' + self.testdir + '/opentaxforms.sqlite3'
     self.default_args = dict(
         # skip cleanupFiles to allow comparison with target output
         # skip=['c'],
         # todo change dbpath to dburl
         dbpath=dbpath, )
コード例 #4
0
 def setup_method(self):
     '''pre-test setup'''
     from opentaxforms.serve import createApp
     # we just read from this db
     dbpath = 'sqlite:///' + ut.Resource(
         'test', 'forms-common/f1040.sqlite3').path()
     # dirName=None means dont look for a forms/ directory
     self.app = createApp(dbpath=dbpath, dirName=None)
     self.client = self.app.test_client()
コード例 #5
0
 def setup_method(self, _):
     from opentaxforms.serve import createApp
     dbResourcePath = ut.Resource('test',
                                  osp.join('forms-common',
                                           'f1040.sqlite3')).path()
     dbFilePath = osp.join('test', 'opentaxforms.sqlite3')
     shutil.copy(dbResourcePath, dbFilePath)
     dbpath = 'sqlite:///' + dbFilePath
     self.app = createApp(dbpath=dbpath)
     self.client = self.app.test_client()