Esempio n. 1
0
def get():
    """
    Processes the user inputs and returns tests or lists to process
    :return:
    """
    args = arguments()
    tests = []
    resources = []
    report_name = ''

    if args.plan:
        tests = test.get(plan=args.plan)
        report_name = 'plan ' + args.plan
    elif args.test:
        tests = test.get(name=args.test)
        report_name = 'test ' + args.test
    elif args.tag:
        tests = test.get(tag=args.tag)
        report_name = 'dynamic'
    elif args.list:
        if args.list == 'plan':
            resources = plan.get()
        elif args.list == 'test':
            resources = test.get()
        elif args.list == 'tag':
            resources = tag.get()
    else:
        tests = test.get()
        report_name = 'all'

    return [tests, report_name, resources, args.list]
Esempio n. 2
0
 def do_test (self, test):
     recs = self.db.search(self.db.recipe_table,
                           'title',
                           test['title'],
                           exact=True,
                           use_regexp=False)
     rec = recs[0]
     ings = self.db.get_ings(rec)
     if test.get('all_ings_have_amounts',False):
         for i in ings:
             assert(i.amount)
     if test.get('all_ings_have_units',False):
         for i in ings:
             assert(i.unit)
Esempio n. 3
0
 def do_test(self, test):
     recs = self.db.search(self.db.recipe_table,
                           'title',
                           test['title'],
                           exact=True,
                           use_regexp=False)
     rec = recs[0]
     ings = self.db.get_ings(rec)
     if test.get('all_ings_have_amounts', False):
         for i in ings:
             assert (i.amount)
     if test.get('all_ings_have_units', False):
         for i in ings:
             assert (i.unit)
Esempio n. 4
0
    def user_detail(self):

        header = {
            'content-type':
            'application/json',
            'User-Agent':
            'Mozilla/5.0 (X11; Linux x86_64) '
            'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.15 Safari/537.36',
            'X-token':
            'eyJhbGciOiJIUzUxMiIsImlhdCI6MTU4ODE1MTU1NSwiZXhwIjoxNTg4MTU1MTU1fQ.eyJ1c2VyX25hbWUiOiJuamN4In0.vdgljMLqgESOdKycG1dL0ROfP912DJtSr0Bv-sY97yt8HBL-1h01JSgsrZyv4RJUBS6sVh1RpBoO-lzbYx_MKA'
        }
        r = get(self.user_detail_, header=header)
        html_detail(r)
Esempio n. 5
0
def run():
    result = test.get(app=Application)
    print (result[ 'status' ], result[ 'headers' ], result[ 'body' ], file=sys.stdout)
Esempio n. 6
0
 def do_test(self, test):
     recs = self.db.search_recipes([{
         'column': 'deleted',
         'search': False,
         'operator': '='
     }, {
         'column': 'title',
         'search': test['title'],
         'operator': '=',
     }])
     if not recs:
         raise AssertionError('No recipe found with title "%s".' %
                              test['title'])
     rec = recs[0]
     ings = self.db.get_ings(rec)
     if test.get('all_ings_have_amounts', False):
         for i in ings:
             try:
                 assert (i.amount)
             except:
                 print i, i.amount, i.unit, i.item, 'has no amount!'
                 raise
     if test.get('all_ings_have_units', False):
         for i in ings:
             try:
                 assert (i.unit)
             except:
                 print i, i.amount, i.unit, i.item, 'has no unit'
                 raise
     for blobby_attribute in ['instructions', 'modifications']:
         if test.get(blobby_attribute, False):
             match_text = test[blobby_attribute]
             match_text = re.sub('\s+', '\s+', match_text)
             try:
                 assert (re.match(match_text,
                                  getattr(rec, blobby_attribute)))
             except:
                 raise AssertionError(
                     '%s == %s != %s' %
                     (blobby_attribute, getattr(
                         rec, blobby_attribute), match_text))
     for non_blobby_attribute in [
             'source', 'cuisine', 'preptime', 'cooktime'
     ]:
         if test.get(non_blobby_attribute, None) is not None:
             try:
                 assert (getattr(
                     rec,
                     non_blobby_attribute) == test[non_blobby_attribute])
             except:
                 raise AssertionError('%s == %s != %s' %
                                      (non_blobby_attribute,
                                       getattr(rec, non_blobby_attribute),
                                       test[non_blobby_attribute]))
     if test.get('categories', None):
         cats = self.db.get_cats(rec)
         for c in test.get('categories'):
             try:
                 assert (c in cats)
             except:
                 raise AssertionError("Found no category %s, only %s" %
                                      (c, cats))
             cats.remove(c)
         try:
             assert (not cats)
         except:
             raise AssertionError(
                 'Categories include %s not specified in %s' %
                 (cats, test['categories']))
     print 'Passed test:', test
Esempio n. 7
0
 def do_test (self, test):
     recs = self.db.search_recipes(
         [
             {'column':'deleted',
              'search':False,
              'operator':'='},
             {'column':'title',
              'search':test['title'],
              'operator':'=',
              }
          ]
         )
     if not recs:
         raise AssertionError(
             'No recipe found with title "%s".'%test['title']
             )
     rec = recs[0]
     ings = self.db.get_ings(rec)
     if test.get('all_ings_have_amounts',False):
         for i in ings:
             try:
                 assert(i.amount)
             except:
                 print i,i.amount,i.unit,i.item,'has no amount!'
                 raise
     if test.get('all_ings_have_units',False):
         for i in ings:
             try:
                 assert(i.unit)
             except:
                 print i,i.amount,i.unit,i.item,'has no unit'
                 raise
     for blobby_attribute in ['instructions','modifications']:
         if test.get(blobby_attribute,False):
             match_text = test[blobby_attribute]
             match_text = re.sub('\s+','\s+',match_text)
             try:
                 assert(re.match(match_text,getattr(rec,blobby_attribute)))
             except:
                 raise AssertionError('%s == %s != %s'%(blobby_attribute,
                                                        getattr(rec,blobby_attribute),
                                                        match_text)
                                      )
     for non_blobby_attribute in ['source','cuisine','preptime','cooktime']:
         if test.get(non_blobby_attribute,None) is not None:
             try: assert(getattr(rec,non_blobby_attribute)==test[non_blobby_attribute])
             except:
                 raise AssertionError('%s == %s != %s'%(non_blobby_attribute,
                                                        getattr(rec,non_blobby_attribute),
                                                        test[non_blobby_attribute])
                                      )
     if test.get('categories',None):
         cats = self.db.get_cats(rec)
         for c in test.get('categories'):
             try:
                 assert(c in cats)
             except:
                 raise AssertionError("Found no category %s, only %s"%(c,cats))
             cats.remove(c)
         try:
             assert(not cats)
         except:
             raise AssertionError('Categories include %s not specified in %s'%(cats,test['categories']))
     print 'Passed test:',test