def t4(): pretty = '%s t4' % __file__ print(pretty) vcsjob.set_profiles(None) if 'VCSJOB_PROFILES' in os.environ: print( 'FAIL %s: set_profiles() did not clear environment variable: %s' % (pretty, os.environ['VCSJOB_PROFILES'])) return False try: vcsjob.get_profiles() print('FAIL %s: could get profiles' % pretty) return False except Exception, e: if 'no profiles' not in str(e): print('FAIL %s: wrong error 1: %s' % (pretty, e)) return False
def t6(): pretty = '%s t6' % __file__ print(pretty) # with u prefixes for the string literals profiles = [{u'type': u'sömething', u'är': u'"lurt"'}, {u'type': u'också'}] vcsjob.set_profiles(profiles) try: hints = vcsjob.get_profiles() except Exception, e: print('FAIL %s: could not get hints: %s' % (pretty, e)) return False
def t5(): pretty = '%s t5' % __file__ print(pretty) vcsjob.set_profiles(None) profiles = [{'type': 'something'}, {'type': 'else', 'more': 'junk'}] vcsjob.set_profiles(profiles) try: hints = vcsjob.get_profiles() except Exception, e: print('FAIL %s: could not get hint: %s' % (pretty, e)) return False
def allocate_by_profiles(local=False): # get profiles from vcsjob file and attempt to allocate the resources. # return as a tuple including the broker: # (<broker>, <allocated 1>, <allocated 2>,...) profiles = vcsjob.get_profiles() b = Broker() try: allocated = b.get(*profiles) except (Busy, NoSuch, Exit) as e: print('BUSY: %s' % e) sys.exit(vcsjob.BUSY) res = [b] allocated = [allocated] if not '__iter__' in dir(allocated) else allocated for a in allocated: if local and a.profile['type'] == 'handset': if a.profile['platform'] == 'android': a = PatchedAndroidHandset(HandsetProfile(a.get_profile())) else: a = Handset(HandsetProfile(a.get_profile())) res.append(a) return tuple(res)
print('FAIL %s: could not set profiles: %s' % (pretty, e)) return False if 'VCSJOB_PROFILES' not in os.environ: print('FAIL %s: $VCSJOB_PROFILES not set' % pretty) return False try: hints = json.loads(os.environ['VCSJOB_PROFILES']) except Exception, e: print('FAIL %s: could not parse $VCSJOB_PROFILES: %s' % (pretty, e)) return False if hints != profiles: print('FAIL %s: wrong profiles: %s' % (pretty, profiles)) return False try: hints = vcsjob.get_profiles() except Exception, e: print('FAIL %s: could not get hints: %s' % (pretty, e)) return False if hints != expected: print('FAIL %s: wrong profiles: %s' % (pretty, hints)) print profiles return False return True #Adapt vcsjob for multipel allocation @setup
def all_usb_power(debug=False, report=False): profiles = vcsjob.get_profiles() b = Broker() r, h = b.get(*profiles) result = run_suite([(tests.usb_power, (b, r, h))], report)