def test_save(self): # check if makes credentials file test_s = "testing" iofunctions.my_logger(test_s,root=ROOT) self.assertTrue(os.path.exists(self.p)) # check contents of file with open(self.filename) as f: s = f.readline().split('\t') self.assertEqual(s[1],test_s+' \n')
def test_save_30_logs(self): # check if makes credentials file longstr = '' for i in range(30): longstr += str(i) + ' ' + str(i) +'\n' with open(self.filename,'w') as f: f.write(longstr) test_s = "testing" iofunctions.my_logger(test_s,root=ROOT) self.assertTrue(os.path.exists(self.p)) # check contents of file with open(self.filename) as f: line = f.readline() while line!= "": s = line.split('\t') line = f.readline() self.assertEqual(s[1],test_s+' \n')
def test_save_4_logs(self): # check if makes credentials file test_s = "testing" iofunctions.my_logger(test_s,root=ROOT) iofunctions.my_logger(test_s,root=ROOT) iofunctions.my_logger(test_s,root=ROOT) iofunctions.my_logger(test_s,root=ROOT) self.assertTrue(os.path.exists(self.p)) # check contents of file with open(self.filename) as f: line = f.readline() s = [] while line!= "": s.append(line.split('\t')[1]) line = f.readline() self.assertEqual(s,[test_s+' \n' for i in range(4)])
big_string = '' for i, name in enumerate(names): big_string += name + '\t' big_string += descriptions[i] + '\t' big_string += grades[i] + '\n' # save with open(root+'/marks.txt','w') as file: file.write(big_string.encode("UTF-8")) # open import webbrowser webbrowser.open(root+"/marks.txt") # Email iofunctions.build_and_send_email(my_credentials,big_string) #log iofunctions.my_logger("successful-changes made") else: # log iofunctions.my_logger("successful-no changes") except pycurl.error as e: # log print e print "could not connect" iofunctions.my_logger("unsuccessful-connection problem")