def __init__(self, dryrun=False, isTest=False): print("Fetching people from phonebook...") if False and dryrun: people_json = (get_project_root_path() + '/auto_nag/tests/people.json') with open(people_json, 'r') as pj: self.people = json.load(pj) else: # when phonebook bug will be fixed: remove these lines and uncomment the following people_json = (get_project_root_path() + '/auto_nag/scripts/configs/people.json') if isTest: people_json = (get_project_root_path() + '/auto_nag/tests/people.json') with open(people_json, 'r') as pj: self.people = {} entries = json.load(pj) for entry in entries: self.people[entry['mail']] = entry if 'title' not in entry: entry['title'] = '' # config = get_config_path() # config = json.load(open(config, 'r')) # self.people = json.loads(requests.get(PEOPLE_URL, # auth=(config['ldap_username'], # config['ldap_password'])).content) self.people_by_bzmail = self.get_people_by_bzmail() self.managers = self.get_managers() self.vices = self.get_vices()
def __init__(self, dryrun=False): print "Fetching people from phonebook..." if dryrun: people_json = (get_project_root_path() + '/auto_nag/tests/people.json') with open(people_json, 'r') as pj: self.people = json.load(pj) else: # when phonebook bug will be fixed: remove these lines and uncomment the following people_json = (get_project_root_path() + '/auto_nag/scripts/configs/people.json') with open(people_json, 'r') as pj: self.people = {} entries = json.load(pj) for entry in entries: self.people[entry['mail']] = entry if 'title' not in entry: entry['title'] = '' # config = get_config_path() # config = json.load(open(config, 'r')) # self.people = json.loads(requests.get(PEOPLE_URL, # auth=(config['ldap_username'], # config['ldap_password'])).content) self.people_by_bzmail = self.get_people_by_bzmail() self.managers = self.get_managers() self.vices = self.get_vices()
def test_get_credentials(self): # if already bztoolsrc is present, backup the existing '~/.bztoolsrc' rcfile = os.path.expanduser('~/.bztoolsrc') rcfile_backup = os.path.expanduser('~/.bztoolsrc_backup') if os.path.exists(rcfile): shutil.move(rcfile, rcfile_backup) cmd = 'python ' + get_project_root_path() + \ 'auto_nag/tests/_get_credential.py' child = pexpect.spawn(cmd, timeout=180) child.expect('username') child.sendline('test_username') child.expect('password') child.sendline('test_password') child.expect(pexpect.EOF) child.close() credentials = get_credentials() # Removing the ~/.bztoolsrc which generated for testing. os.remove(rcfile) # copy back bztoolsrc_backup to ~/.bztoolsrc if os.path.exists(rcfile_backup): shutil.move(rcfile_backup, rcfile) assert_equals(credentials, ('test_username', 'test_password'))
def __init__(self): self.queries_dir = get_project_root_path() + "queries/" self.url = (settings.API_ROOT + '/buglist.cgi?o5=nowordssubstr' '&f1=OP&f0=OP&f8=owner_idle_time&o2=equals&f4=OP&' 'v5=fixed%20verified%20unaffected%20wontfix&' 'j1=OR&f3=CP&f2=cf_blocking_b2g&bug_status=UNCONFIRMED&' 'bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&' 'j4=OR&f5=cf_status_b2g_1_2&v8=-3d&f6=CP&' 'v2=koi%2B&f7=CP&o8=greaterthan')
def __init__(self, dryrun=False): print "Fetching people from phonebook..." if dryrun: people_json = (get_project_root_path() + '/auto_nag/tests/people.json') with open(people_json, 'r') as pj: self.people = json.load(pj) else: config = get_config_path() config = json.load(open(config, 'r')) self.people = json.loads(requests.get(PEOPLE_URL, auth=(config['ldap_username'], config['ldap_password'])).content) self.people_by_bzmail = self.get_people_by_bzmail() self.managers = self.get_managers() self.vices = self.get_vices()
def __init__(self, dryrun=False): print "Fetching people from phonebook..." if dryrun: people_json = (get_project_root_path() + '/auto_nag/tests/people.json') with open(people_json, 'r') as pj: self.people = json.load(pj) else: config = get_config_path() config = json.load(open(config, 'r')) self.people = json.loads( requests.get(PEOPLE_URL, auth=(config['ldap_username'], config['ldap_password'])).content) self.people_by_bzmail = self.get_people_by_bzmail() self.managers = self.get_managers() self.vices = self.get_vices()
def cleanUp(queries_dir): try: for file in os.listdir(queries_dir): if file.startswith(str(datetime.date.today())): os.remove(os.path.join(queries_dir, file)) return True except Exception as error: print "Error: ", str(error) return False if __name__ == '__main__': # basic setups CONFIG_JSON = get_config_path() config = json.load(open(CONFIG_JSON, 'r')) scripts_dir = get_project_root_path() + "auto_nag/scripts/" queries_dir = get_project_root_path() + "queries/" parser = ArgumentParser(__doc__) parser.set_defaults(queries_only=False, ) parser.add_argument("-q", "--queries-only", dest="queries_only", action="store_true", help="just create and print queries") options, args = parser.parse_known_args() weekday = datetime.datetime.today().weekday() queries = createQueriesList(queries_dir, weekday, print_all=options.queries_only)
(1, ["Koi Blocking Nominiations for B2G: Communications", "team_comm_koi_nom", team_comm_koi_nom, 1, ["*****@*****.**", ]]), (1, ["Koi Blocker Bugs, B2G: Communications", "team_comm_koi_blockers", team_comm_koi_blockers, 1, ["*****@*****.**", ]]), (4, ["Koi Blocker Bugs, No Comment from Assignee in 3 days or more", "koi_assignee_no_comment_three_days", koi_assignee_no_comment_three_days, 1]), (4, ["Koi Blocker Bugs, Regressions", "koi_regressions_unfixed", koi_regressions_unfixed, 1]), ] def cleanUp(): for file in os.listdir(queries_dir): if file.startswith(str(datetime.date.today())): os.remove(os.path.join(queries_dir, file)) if __name__ == '__main__': CONFIG_JSON = get_config_path() config = json.load(open(CONFIG_JSON, 'r')) scripts_dir = get_project_root_path() + "auto_nag/scripts/" queries_dir = get_project_root_path() + "queries/" parser = ArgumentParser(__doc__) parser.set_defaults( queries_only=False, ) parser.add_argument("-q", "--queries-only", dest="queries_only", action="store_true", help="just create and print queries") options, args = parser.parse_known_args() queries = createQueriesList(print_all=options.queries_only, queries_dir=queries_dir) if options.queries_only: for url in urls: print url
def test_get_project_root_path(self): rpath = get_project_root_path() assert os.path.isdir(rpath)
def setUp(self): self.queries_dir = get_project_root_path() + 'queries/'