How to use test_get_string method in tempest

Best Python code snippet using tempest_python

proses_test.py

Source:proses_test.py Github

copy

Full Screen

...24 """fungsi untuk merubah input yang berformat string dari jadwal menjadi datetime"""25 x = dt.strptime(arg,'%H:%M')26 return td(hours = x.hour, minutes = x.minute)2728def test_get_string(day,delta):29 """fungsi untuk merubah input yang berformat datetime menjadi string"""30 if type(delta) == str:31 return " "32 else:33 x = day + delta34 return x.strftime('%H:%M')3536def test_get_late_in(hour_in,check_in,tolerance):37 """menghitung berapa lama pegawai terlambat"""38 if check_in > hour_in:39 if (check_in - hour_in) < tolerance:40 return ' '41 else:42 return check_in - hour_in43 else:44 return ' '4546def test_get_early_out(hour_out,check_out,tolerance):47 """menghitung berapa lama pegawai pulang lebih awal"""48 if hour_out > check_out:49 if (hour_out - check_out) < tolerance:50 return ' '51 else:52 return hour_out - check_out53 else:54 return ' '5556def test_get_overtime(hour_out,check_out):57 """menghitung lembur pegawai"""58 if check_out > hour_out:59 return check_out - hour_out60 else:61 return ' '6263def test_get_worktime(hour_in,hour_out,check_in,check_out):64 """menghitung jam kerja minus telat dan pulang awal"""65 if check_in > hour_in:66 return hour_out - check_in67 elif check_out > hour_out:68 return check_out - hour_in69 else:70 return hour_out - hour_in7172def test_get_totaltime(check_in,check_out):73 """menghitung jam kerja dari jam masuk dan jam keluar"""74 return (check_out - check_in)7576def test_get_overtype(hour_out,check_out):77 """menghitung jam lembur dalam desimal"""78 if check_out > hour_out:79 return round((check_out - hour_out)/td(hours = 1),2)80 else:81 return ' '8283def test_process(start,end,buffer):84 """fungsi untuk memproses pegawai tanggal waktu dan input ke buffer"""85 """start = tanggal mulai"""86 """end = tanggal akhir """87 """buffer berfungsi sebagai penampung data"""88 89 """ambil library yang dibutuhkan"""90 employee = test_get_data('data/pegawai.json')91 schedule = test_get_data('data/jadwal.json')92 subdata = test_get_data('data/judul.json')93 holiday = list(map(lambda x:dt.strptime(x,'%Y-%m-%d'),list(test_get_data('data/libur.json').keys())))94 95 """daftar tanggal"""96 delta = end - start97 98 """looping pegawai"""99 for x in range(len(employee)):100 x = x + 1 #variabel untuk data pegawai101 """looping tanggal"""102 for day in range(delta.days+1):103 """fungsi untuk mengisi waktu"""104 data = {}105 thisday = start + td(days = day)106 107 data["0"] = employee[str(x)]['nopeg'] #nomor pegawai108 data["1"] = employee[str(x)]['akun'] #nomor akun109 data["2"] = employee[str(x)]['nomor'] #nomor induk110 data["3"] = employee[str(x)]['nama'] #nama pegawai111 data["4"] = ' ' #masuk otomatis (biarkan kosong)112 data["5"] = thisday.strftime('%Y-%m-%d') #tanggal113 data["12"] = '1' #waktu real114 data["19"] = ' ' #status115 data["20"] = ' ' #harus check in116 data["21"] = ' ' #harus check out117 data["22"] = employee[str(x)]['dpt'] #departemen118 119 if not thisday in holiday:120 if thisday.weekday() == 6:121 """hari minggu """122 thisday_schedule = schedule["2"]123 hour_in = test_get_hour(thisday_schedule['hour start'])124 hour_out = test_get_hour(thisday_schedule['hour end'])125 check_in = ' '126 check_out = ' '127 late_in = ' '128 early_out = ' '129 overtime = ' '130 worktime = ' '131 totaltime = ' '132 overtype = ' '133 134 data["6"] = thisday_schedule["name"] #nama jadwal135 data["7"] = thisday_schedule['hour start'] #jadwal masuk136 data["8"] = thisday_schedule['hour end'] #jadwal keluar137 data["9"] = ' ' #jam masuk138 data["10"] = ' ' #jam keluar139 data["11"] = ' ' #jam normal140 141 data["13"] = ' ' #terlambat142 data["14"] = ' ' #pulang cepat143 try:144 if isinstance(check_in,td) == False:145 data["15"] = 'True' #bolos146 elif check_in == td(seconds = 0):147 data["15"] = 'True' #bolos148 elif late_in > test_get_hour(thisday_schedule["checkin max"]):149 data["15"] = 'True' #bolos150 elif check_out < test_get_hour(thisday_schedule["checkin max"]):151 data["15"] = 'True' #bolos152 else : 153 data["15"] = ' ' #bolos154 except Exception:155 data["15"] = ' ' #bolos156 data["16"] = ' ' #lembur157 data["17"] = ' ' #jam kerja158 data["18"] = ' ' #waktu kerja159 data["23"] = ' ' #normal days160 data["24"] = '1' #akhir pekan161 data["25"] = ' ' #hari libur162 data["26"] = ' ' # lembur hari normal163 data["27"] = str(overtype) #lembur akhir pekan164 data["28"] = ' ' #lembur hari libur165 166 elif thisday.weekday() == 5:167 """hari sabtu """168 thisday_schedule = schedule["2"]169 hour_in = test_get_hour(thisday_schedule['hour start'])170 hour_out = test_get_hour(thisday_schedule['hour end'])171 hour = ri(7,8)172 if hour == 8:173 minute = ri(0,15)174 second = ri(0,59)175 else:176 minute = ri(0,59)177 second = ri(0,59)178 check_in = td(hours = hour, minutes = minute, seconds = second)179 check_out = td(hours = ri(15,18), minutes = ri(0,59),seconds = ri(0,59))180 late_in = test_get_late_in(hour_in,check_in,test_get_hour(thisday_schedule['late in']))181 early_out = test_get_early_out(hour_out,check_out,test_get_hour(thisday_schedule['early out']))182 overtime = test_get_overtime(hour_out,check_out)183 worktime = test_get_worktime(hour_in,hour_out,check_in,check_out)184 totaltime = test_get_totaltime(check_in,check_out)185 overtype = test_get_overtype(hour_out,check_out)186 187 data["6"] = thisday_schedule["name"] #nama jadwal188 data["7"] = thisday_schedule['hour start'] #jadwal masuk189 data["8"] = thisday_schedule['hour end'] #jadwal keluar190 data["9"] = test_get_string(thisday,check_in) #jam masuk191 data["10"] = test_get_string(thisday,check_out) #jam keluar192 data["11"] = '1' #jam normal193 data["13"] = test_get_string(thisday,late_in) #terlambat194 data["14"] = test_get_string(thisday,early_out) #pulang cepat195 try:196 if isinstance(check_in,td) == False:197 data["15"] = 'True' #bolos198 elif check_in == td(seconds = 0):199 data["15"] = 'True' #bolos200 elif late_in > test_get_hour(thisday_schedule["checkin max"]):201 data["15"] = 'True' #bolos202 elif check_out < test_get_hour(thisday_schedule["checkin max"]):203 data["15"] = 'True' #bolos204 else : 205 data["15"] = ' ' #bolos206 except Exception:207 data["15"] = ' ' #bolos208 data["16"] = test_get_string(thisday,overtime) #lembur209 data["17"] = test_get_string(thisday,worktime) #jam kerja210 data["18"] = test_get_string(thisday,totaltime) #waktu kerja211 data["23"] = ' ' #normal days212 data["24"] = '1' #akhir pekan213 data["25"] = ' ' #hari libur214 data["26"] = ' ' # lembur hari normal215 data["27"] = str(overtype) #lembur akhir pekan216 data["28"] = ' ' #lembur hari libur217 218 else:219 """hari senin sarmpai jumat"""220 thisday_schedule = schedule["1"]221 hour_in = test_get_hour(thisday_schedule['hour start'])222 hour_out = test_get_hour(thisday_schedule['hour end'])223 hour = ri(7,8)224 if hour == 8:225 minute = ri(0,15)226 second = ri(0,59)227 else:228 minute = ri(0,59)229 second = ri(0,59)230 check_in = td(hours = hour, minutes = minute, seconds = second)231 check_out = td(hours = ri(15,18), minutes = ri(0,59),seconds = ri(0,59))232 late_in = test_get_late_in(hour_in,check_in,test_get_hour(thisday_schedule['late in']))233 early_out = test_get_early_out(hour_out,check_out,test_get_hour(thisday_schedule['early out']))234 overtime = test_get_overtime(hour_out,check_out)235 worktime = test_get_worktime(hour_in,hour_out,check_in,check_out)236 totaltime = test_get_totaltime(check_in,check_out)237 overtype = test_get_overtype(hour_out,check_out)238 239 data["6"] = schedule["1"]["name"] #nama jadwal240 data["7"] = schedule["1"]['hour start'] #jadwal masuk241 data["8"] = schedule["1"]['hour end'] #jadwal keluar242 data["9"] = test_get_string(thisday,check_in) #jam masuk243 data["10"] = test_get_string(thisday,check_out) #jam keluar244 data["11"] = '1' #jam normal245 data["13"] = test_get_string(thisday,late_in) #terlambat246 data["14"] = test_get_string(thisday,early_out) #pulang cepat247 try:248 if isinstance(check_in,td) == False:249 data["15"] = 'True' #bolos250 elif check_in == td(seconds = 0):251 data["15"] = 'True' #bolos252 elif late_in > test_get_hour(thisday_schedule["checkin max"]):253 data["15"] = 'True' #bolos254 elif check_out < test_get_hour(thisday_schedule["checkin max"]):255 data["15"] = 'True' #bolos256 else : 257 data["15"] = ' ' #bolos258 except Exception:259 data["15"] = ' ' #bolos260 data["16"] = test_get_string(thisday,overtime) #lembur261 data["17"] = test_get_string(thisday,worktime) #jam kerja262 data["18"] = test_get_string(thisday,totaltime) #waktu kerja263 data["23"] = '1' #normal days264 data["24"] = ' ' #akhir pekan265 data["25"] = ' ' #hari libur266 data["26"] = str(overtype) # lembur hari normal267 data["27"] = ' ' #lembur akhir pekan268 data["28"] = ' ' #lembur hari libur269 else:270 """hari libur"""271 thisday_schedule = schedule["0"]272 hour_in = test_get_hour(thisday_schedule['hour start'])273 hour_out = test_get_hour(thisday_schedule['hour end'])274 check_in = ' '275 check_out = ' '276 late_in = ' '277 early_out = ' '278 overtime = ' '279 worktime = ' '280 totaltime = ' '281 overtype = ' '282 283 data["6"] = thisday_schedule["name"] #nama jadwal284 data["7"] = thisday_schedule['hour start'] #jadwal masuk285 data["8"] = thisday_schedule['hour end'] #jadwal keluar286 data["9"] = test_get_string(thisday,check_in) #jam masuk287 data["10"] = test_get_string(thisday,check_out) #jam keluar288 data["11"] = ' ' #jam normal289 290 data["13"] = test_get_string(thisday,late_in) #terlambat291 data["14"] = test_get_string(thisday,early_out) #pulang cepat292 if isinstance(check_in,td) == False:293 data["15"] = 'True' #bolos294 elif check_in == td(seconds = 0):295 data["15"] = 'True' #bolos296 elif late_in > test_get_hour(thisday_schedule["checkin max"]):297 data["15"] = 'True' #bolos298 elif check_out < test_get_hour(thisday_schedule["checkin max"]):299 data["15"] = 'True' #bolos300 else : 301 data["15"] = ' ' #bolos302 data["16"] = test_get_string(thisday,overtime) #lembur303 data["17"] = test_get_string(thisday,worktime) #jam kerja304 data["18"] = test_get_string(thisday,totaltime) #waktu kerja305 data["23"] = ' ' #normal days306 data["24"] = ' ' #akhir pekan307 data["25"] = '1' #hari libur308 data["26"] = ' ' # lembur hari normal309 data["27"] = ' ' #lembur akhir pekan310 data["28"] = str(overtype) #lembur hari libur311 """mengisi data ke buffer"""312 buffer.append(data)313314def test_main():315 print("not ready yet")316317if __name__ == '__main__':318 test_main()

Full Screen

Full Screen

marlin_command_tests.py

Source:marlin_command_tests.py Github

copy

Full Screen

...34 # should return 4935 self.line.set_param("Z", 49)36 result = self.line.get_param("Z")37 self.assertEqual(result, 49, msg="test_set_param()")38 def test_get_string(self):39 """Test proper string is returned"""40 result = self.line.get_string()41 self.assertEqual(result, "G0 X1.0 Y-2.0 Z49.0 E4.0", msg="test_get_string()")42if __name__ == "__main__":...

Full Screen

Full Screen

test_app.py

Source:test_app.py Github

copy

Full Screen

...8class TestToken(unittest.TestCase):9 @classmethod10 def setUpClass(self):11 np.random.seed(31)12 def test_get_string(self):13 token = Token("Hallo")14 self.assertEqual(token.get_string(), 'Hallo')15 def test_shuffle_letters(self):16 word = "Allgäu"17 token = Token(word)18 token.shuffle()19 word_shuffled = token.get_string()20 self.assertEqual(len(word_shuffled), len(word))21 self.assertNotEqual(word_shuffled, word)22class TestSentence(unittest.TestCase):23 @classmethod24 def setUpClass(self):25 np.random.seed(31)26 def setUp(self):27 self.sentence = "This is awesome python code"28 def test_get_string(self):29 sentence = Sentence(self.sentence)30 self.assertEqual(sentence.get_string(), self.sentence)31 def test_shuffle(self):32 sentence = Sentence(self.sentence)33 sentence.shuffle()34 self.assertNotEqual(sentence.get_string(), self.sentence)35class TestText(unittest.TestCase):36 @classmethod37 def setUpClass(self):38 np.random.seed(31)39 def setUp(self):40 self.text = "This is awesome python code. It is free of bugs"41 def test_get_string(self):42 text = Text(self.text)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful