How to use get_status method in yandex-tank

Best Python code snippet using yandex-tank

dibas_tests.py

Source:dibas_tests.py Github

copy

Full Screen

...179 print "Status memory:", be.status_mem_local180 print "Roach (int) registers:", be.roach_registers_local181 be.show_switching_setup()182 DEFAULT_VALUE = "unspecified"183 assert_almost_equal(float(be.get_status("_SBLK_01")), blanktm, 5)184 assert_almost_equal(float(be.get_status("_SBLK_02")), blanktm, 5)185 assert_almost_equal(float(be.get_status("_SBLK_03")), blanktm, 5)186 assert_almost_equal(float(be.get_status("_SBLK_04")), blanktm, 5)187 assert_equal(be.get_status("_SCAL_01"), '1')188 assert_equal(be.get_status("_SCAL_02"), '0')189 assert_equal(be.get_status("_SCAL_03"), '1')190 assert_equal(be.get_status("_SCAL_04"), '0')191 assert_almost_equal(float(be.get_status("_SPHS_01")), 0,)192 assert_almost_equal(float(be.get_status("_SPHS_02")), 0.25)193 assert_almost_equal(float(be.get_status("_SPHS_03")), 0.5)194 assert_almost_equal(float(be.get_status("_SPHS_04")), 0.75)195 assert_equal(be.get_status("_SSRF_01"), '0')196 assert_equal(be.get_status("_SSRF_02"), '0')197 assert_equal(be.get_status("_SSRF_03"), '1')198 assert_equal(be.get_status("_SSRF_04"), '1')199 assert_equal(be.get_status('BANKNAM') , 'BANKA')200 assert_equal(be.get_status('MODENUM') , mode)201 assert_equal(be.get_status("BW_MODE") , bw_mode)202 assert_almost_equal(float(be.get_status("CHAN_BW")), chan_bw)203 assert_almost_equal(float(be.get_status("EFSAMPFR")), efsampfr)204 assert_almost_equal(float(be.get_status("EXPOSURE")), exposure)205 assert_almost_equal(float(be.get_status("FPGACLK")), fpga_clk)206 assert_equal(be.get_status("OBSNCHAN"), str(m.nchan))207 assert_equal(be.get_status("OBS_MODE"), obs_mode)208 assert_equal(be.get_status("PKTFMT") , "SPEAD")209 assert_equal(be.get_status("NCHAN") , str(m.nchan))210 assert_equal(be.get_status("NPOL") , '2')211 assert_equal(be.get_status("NSUBBAND"), '1') # mode 1 uses just one.212 assert_equal(be.get_status("SUB0FREQ"), str(efsampfr / 4))213 assert_equal(be.get_status("SUB1FREQ"), str(efsampfr / 4))214 assert_equal(be.get_status("SUB2FREQ"), str(efsampfr / 4))215 assert_equal(be.get_status("SUB3FREQ"), str(efsampfr / 4))216 assert_equal(be.get_status("SUB4FREQ"), str(efsampfr / 4))217 assert_equal(be.get_status("SUB5FREQ"), str(efsampfr / 4))218 assert_equal(be.get_status("SUB6FREQ"), str(efsampfr / 4))219 assert_equal(be.get_status("SUB7FREQ"), str(efsampfr / 4))220 assert_equal(be.get_status("BASE_BW"), str(m.filter_bw)) # from config file221 assert_equal(be.get_status("NOISESRC"), 'OFF')222 assert_equal(be.get_status("NUMPHASE"), '4')223 assert_almost_equal(float(be.get_status("SWPERIOD")), exposure)224 assert_equal(be.get_status("SWMASTER"), "VEGAS")225 assert_equal(be.get_status("POLARIZE"), "SELF")226 assert_equal(be.get_status("CRPIX1"), str(m.nchan / 2 + 1))227 assert_almost_equal(float(be.get_status("SWPERINT")), 1.0)228 assert_equal(be.get_status("NMSTOKES"), "2")229 assert_equal(be.get_status("CAL_DCYC"), DEFAULT_VALUE)230 assert_equal(be.get_status("CAL_FREQ"), DEFAULT_VALUE)231 assert_equal(be.get_status("CAL_MODE"), DEFAULT_VALUE)232 assert_equal(be.get_status("CAL_PHS") , DEFAULT_VALUE)233 assert_equal(be.get_status("DATADIR") , dibas_data)234 assert_equal(be.get_status("DATAPORT"), '60000')235 assert_equal(be.get_status("FILENUM") , DEFAULT_VALUE)236 assert_almost_equal(float(be.get_status("HWEXPOSR")), hwexposr)237 assert_equal(be.get_status("M_STTMJD"), '0')238 assert_equal(be.get_status("M_STTOFF"), '0')239 assert_equal(be.get_status("NBITS") , '8')240 assert_equal(be.get_status("NBITSADC"), '8')241 assert_equal(be.get_status("NPKT") , DEFAULT_VALUE)242 assert_equal(be.get_status("OBSBW") , str(frequency))243 assert_equal(be.get_status("OBSFREQ") , DEFAULT_VALUE)244 assert_equal(be.get_status("OBSERVER"), DEFAULT_VALUE)245 assert_equal(be.get_status("OBSID") , DEFAULT_VALUE)246 assert_equal(be.get_status("SWVER") , DEFAULT_VALUE)247def check_l1lbw1_mode(mode, expo):248 """A VegasLBWBackend setup test case.249 """250 params = dibas_vals(mode, expo)251 b, m, frequency, exposure, expoclks, blanktm, spec_tick, efsampfr, \252 hwexposr, chan_bw, bw_mode, obs_mode, fpga_clk = params253 be = VegasL1LBWBackend(b, m, None, None, None, unit_test = True)254 nchan = m.nchan255 frequency_resolution = abs(chan_bw)256 be.setPolarization('SELF')257 be.setProjectId('JUNK')258 be.setScanLength(60.0)259 be.setIntegrationTime(expo)260 be.clear_switching_states()261 ssg_duration = expo262 be.set_gbt_ss(ssg_duration,263 ((0.0, SWbits.SIG, SWbits.CALON, 0.002),264 (0.25, SWbits.SIG, SWbits.CALOFF, 0.002),265 (0.5, SWbits.REF, SWbits.CALON, 0.002),266 (0.75, SWbits.REF, SWbits.CALOFF, 0.002))267 )268 # call dependency methods and update shared memory269 be.prepare()270# print "Status memory:", be.status_mem_local271# print "Roach (int) registers:", be.roach_registers_local272 be.show_switching_setup()273 DEFAULT_VALUE = "unspecified"274 assert_equal(be.get_status('PROJID'), 'JUNK')275 assert_equal(be.get_status('SCANLEN'), '60.0')276 assert_almost_equal(float(be.get_status("_SBLK_01")), blanktm, 6)277 assert_almost_equal(float(be.get_status("_SBLK_02")), blanktm, 6)278 assert_almost_equal(float(be.get_status("_SBLK_03")), blanktm, 6)279 assert_almost_equal(float(be.get_status("_SBLK_04")), blanktm, 6)280 assert_equal(be.get_status("_SCAL_01"), '1')281 assert_equal(be.get_status("_SCAL_02"), '0')282 assert_equal(be.get_status("_SCAL_03"), '1')283 assert_equal(be.get_status("_SCAL_04"), '0')284 assert_almost_equal(float(be.get_status("_SPHS_01")), 0,)285 assert_almost_equal(float(be.get_status("_SPHS_02")), 0.25)286 assert_almost_equal(float(be.get_status("_SPHS_03")), 0.5)287 assert_almost_equal(float(be.get_status("_SPHS_04")), 0.75)288 assert_equal(be.get_status("_SSRF_01"), '0')289 assert_equal(be.get_status("_SSRF_02"), '0')290 assert_equal(be.get_status("_SSRF_03"), '1')291 assert_equal(be.get_status("_SSRF_04"), '1')292 assert_equal(be.get_status('BANKNAM') , 'BANKA')293 assert_equal(be.get_status('MODENUM') , mode)294 assert_equal(be.get_status("BW_MODE") , "low")295 assert_almost_equal(float(be.get_status("CHAN_BW")), chan_bw)296 assert_almost_equal(float(be.get_status("EFSAMPFR")), efsampfr)297 assert_almost_equal(float(be.get_status("EXPOSURE")), exposure, 7)298 assert_equal(int(be.get_status('EXPOCLKS')), expoclks)299 assert_almost_equal(float(be.get_status("FPGACLK")), fpga_clk)300 assert_equal(be.get_status("OBSNCHAN"), str(nchan))301 assert_equal(be.get_status("OBS_MODE"), "LBW")302 assert_equal(be.get_status("PKTFMT") , "SPEAD")303 assert_equal(be.get_status("NCHAN") , str(nchan))304 assert_equal(be.get_status("NPOL") , '2')305 assert_equal(be.get_status("NSUBBAND"), '1')306 assert_equal(be.get_status("SUB0FREQ"), str(frequency / 2))307 assert_equal(be.get_status("SUB1FREQ"), str(frequency / 2))308 assert_equal(be.get_status("SUB2FREQ"), str(frequency / 2))309 assert_equal(be.get_status("SUB3FREQ"), str(frequency / 2))310 assert_equal(be.get_status("SUB4FREQ"), str(frequency / 2))311 assert_equal(be.get_status("SUB5FREQ"), str(frequency / 2))312 assert_equal(be.get_status("SUB6FREQ"), str(frequency / 2))313 assert_equal(be.get_status("SUB7FREQ"), str(frequency / 2))314 assert_equal(be.get_status("BASE_BW"), str(m.filter_bw)) # from config file315 assert_equal(be.get_status("NOISESRC"), 'OFF')316 assert_equal(be.get_status("NUMPHASE"), '4')317 assert_almost_equal(float(be.get_status("SWPERIOD")), exposure, 5)318 assert_equal(be.get_status("SWMASTER"), "VEGAS")319 assert_equal(be.get_status("POLARIZE"), "SELF")320 assert_equal(be.get_status("CRPIX1"), str(nchan / 2 + 1))321 assert_almost_equal(float(be.get_status("SWPERINT")), 0.1 / ssg_duration)322 assert_equal(be.get_status("NMSTOKES"), "2")323 assert_equal(be.get_status("CAL_DCYC"), DEFAULT_VALUE)324 assert_equal(be.get_status("CAL_FREQ"), DEFAULT_VALUE)325 assert_equal(be.get_status("CAL_MODE"), DEFAULT_VALUE)326 assert_equal(be.get_status("CAL_PHS") , DEFAULT_VALUE)327 assert_equal(be.get_status("DATADIR") , dibas_data)328 assert_equal(be.get_status("DATAPORT"), '60000')329 assert_equal(be.get_status("EFSAMPFR"), str(efsampfr))330 assert_equal(be.get_status("FILENUM") , DEFAULT_VALUE)331 assert_almost_equal(float(be.get_status("FPGACLK")), frequency / 8)332 assert_almost_equal(float(be.get_status("HWEXPOSR")), hwexposr, 5)333 assert_equal(be.get_status("M_STTMJD"), '0')334 assert_equal(be.get_status("M_STTOFF"), '0')335 assert_equal(be.get_status("NBITS") , '8')336 assert_equal(be.get_status("NBITSADC"), '8')337 assert_equal(be.get_status("NPKT") , DEFAULT_VALUE)338 assert_equal(be.get_status("OBSBW") , str(m.nchan * chan_bw))339 assert_equal(be.get_status("OBSFREQ") , DEFAULT_VALUE)340 assert_equal(be.get_status("OBSERVER"), DEFAULT_VALUE)341 assert_equal(be.get_status("OBSID") , DEFAULT_VALUE)342 assert_equal(be.get_status("SWVER") , DEFAULT_VALUE)343def check_l8lbw1_mode(mode, expo):344 """345 Single L8LBW1 subband test (Mode 10).346 """347 params = dibas_vals(mode, expo)348 b, m, frequency, exposure, expoclks, blanktm, spec_tick, efsampfr, \349 hwexposr, chan_bw, bw_mode, obs_mode, fpga_clk = params350 print "frequency", frequency351 print "exposure", exposure352 print "expoclks", expoclks353 print "blanktm", blanktm354 print "spec_tick", spec_tick355 print "efsampfr", efsampfr356 print "hwexposr", hwexposr357 print "chan_bw", chan_bw358 print "bw_mode", bw_mode359 print "obs_mode", obs_mode360 print "fpga_clk", fpga_clk361 be = VegasL8LBWBackend(b, m, None, None, None, unit_test = True)362 be.setPolarization('CROSS')363 be.setScanLength(60.0)364 be.setIntegrationTime(expo)365 be.set_param("subband_freq", [ 300000000.0000 ])366 be.clear_switching_states()367 ssg_duration = expo368 be.set_gbt_ss(ssg_duration,369 ((0.0, SWbits.SIG, SWbits.CALON, 0.002),370 (0.25, SWbits.SIG, SWbits.CALOFF, 0.002),371 (0.5, SWbits.REF, SWbits.CALON, 0.002),372 (0.75, SWbits.REF, SWbits.CALOFF, 0.002))373 )374 # call dependency methods and update shared memory375 be.prepare()376 regs = be.roach_registers_local377 shm = be.status_mem_local378 shmkeys = shm.keys()379 shmkeys.sort()380 print "Status memory:"381 for i in shmkeys:382 print "%s = %s" % (i, shm[i])383 assert_equals(int(shm['NCHAN']), m.nchan)384 assert_equals(int(shm['NSUBBAND']), 1)385 #print be.actual_subband_freq386 for i in range(16):387 assert_true("s0_lo_%i_lo_ram" % (i) in regs.keys())388 assert_true("s1_lo_%i_lo_ram" % (i) not in regs.keys())389 assert_true("s2_lo_%i_lo_ram" % (i) not in regs.keys())390 assert_true("s3_lo_%i_lo_ram" % (i) not in regs.keys())391 assert_true("s4_lo_%i_lo_ram" % (i) not in regs.keys())392 assert_true("s5_lo_%i_lo_ram" % (i) not in regs.keys())393 assert_true("s6_lo_%i_lo_ram" % (i) not in regs.keys())394 assert_true("s7_lo_%i_lo_ram" % (i) not in regs.keys())395 be.set_param("gain", [1024])396 be.prepare()397 regs = be.roach_registers_local398 assert_true('mode_sel' in regs.keys())399 assert_true('s0_quant_gain' in regs.keys())400 assert_equals(int(regs['s0_quant_gain']), 1024)401 assert_equals(int(regs['mode_sel']), 1)402 be.show_switching_setup()403 DEFAULT_VALUE = "unspecified"404 assert_equal(be.get_status('PROJID'), 'JUNK')405 assert_equal(be.get_status('SCANLEN'), '60.0')406 assert_almost_equal(float(be.get_status("_SBLK_01")), blanktm, 6)407 assert_almost_equal(float(be.get_status("_SBLK_02")), blanktm, 6)408 assert_almost_equal(float(be.get_status("_SBLK_03")), blanktm, 6)409 assert_almost_equal(float(be.get_status("_SBLK_04")), blanktm, 6)410 assert_equal(be.get_status("_SCAL_01"), '1')411 assert_equal(be.get_status("_SCAL_02"), '0')412 assert_equal(be.get_status("_SCAL_03"), '1')413 assert_equal(be.get_status("_SCAL_04"), '0')414 assert_almost_equal(float(be.get_status("_SPHS_01")), 0,)415 assert_almost_equal(float(be.get_status("_SPHS_02")), 0.25)416 assert_almost_equal(float(be.get_status("_SPHS_03")), 0.5)417 assert_almost_equal(float(be.get_status("_SPHS_04")), 0.75)418 assert_equal(be.get_status("_SSRF_01"), '0')419 assert_equal(be.get_status("_SSRF_02"), '0')420 assert_equal(be.get_status("_SSRF_03"), '1')421 assert_equal(be.get_status("_SSRF_04"), '1')422 assert_equal(be.get_status('BANKNAM') , 'BANKA')423 assert_equal(be.get_status('MODENUM') , mode)424 assert_equal(be.get_status("BW_MODE") , bw_mode)425 assert_almost_equal(float(be.get_status("CHAN_BW")), chan_bw)426 assert_almost_equal(float(be.get_status("EFSAMPFR")), efsampfr)427 assert_almost_equal(float(be.get_status("EXPOSURE")), exposure, 7)428 assert_equal(int(be.get_status('EXPOCLKS')), expoclks)429 assert_almost_equal(float(be.get_status("FPGACLK")), fpga_clk)430 assert_equal(be.get_status("OBSNCHAN"), str(m.nchan))431 assert_equal(be.get_status("OBS_MODE"), obs_mode)432 assert_equal(be.get_status("PKTFMT") , "SPEAD")433 assert_equal(be.get_status("NCHAN") , str(m.nchan))434 assert_equal(be.get_status("NPOL") , '2')435 assert_equal(be.get_status("NSUBBAND"), '1')436 # 8 subbands checked. L8LBW1 modes only use first value but set all437 # 8 to same value. 'assert_almost_equal' checks values to their438 # difference rounded to the value given (5 here), not significant439 # digits. So first obtain real subfreq, divide it by desired440 # subfreq, and that should give a number very close to 1.0, within 5441 # decimal places.442 for i in range(0, 8):443 asb = float(be.get_status("SUB%iFREQ" % i))444 assert_almost_equal(asb / 300e6, 1.0, 3)445 assert_equal(be.get_status("BASE_BW"), str(m.filter_bw)) # from config file446 assert_equal(be.get_status("NOISESRC"), 'OFF')447 assert_equal(be.get_status("NUMPHASE"), '4')448 assert_almost_equal(float(be.get_status("SWPERIOD")), exposure, 5)449 assert_equal(be.get_status("SWMASTER"), "VEGAS")450 assert_equal(be.get_status("POLARIZE"), "CROSS")451 assert_equal(be.get_status("CRPIX1"), str(m.nchan / 2 + 1))452 assert_almost_equal(float(be.get_status("SWPERINT")), expo / ssg_duration)453 assert_equal(be.get_status("NMSTOKES"), "4")454 assert_equal(be.get_status("CAL_DCYC"), DEFAULT_VALUE)455 assert_equal(be.get_status("CAL_FREQ"), DEFAULT_VALUE)456 assert_equal(be.get_status("CAL_MODE"), DEFAULT_VALUE)457 assert_equal(be.get_status("CAL_PHS") , DEFAULT_VALUE)458 assert_equal(be.get_status("DATADIR") , dibas_data)459 assert_equal(be.get_status("DATAPORT"), '60000')460 assert_equal(be.get_status("EFSAMPFR"), str(efsampfr))461 assert_equal(be.get_status("FILENUM") , DEFAULT_VALUE)462 assert_almost_equal(float(be.get_status("FPGACLK")), frequency / 8)463 assert_almost_equal(float(be.get_status("HWEXPOSR")), hwexposr, 5)464 assert_equal(be.get_status("M_STTMJD"), '0')465 assert_equal(be.get_status("M_STTOFF"), '0')466 assert_equal(be.get_status("NBITS") , '8')467 assert_equal(be.get_status("NBITSADC"), '8')468 assert_equal(be.get_status("NPKT") , DEFAULT_VALUE)469 assert_equal(be.get_status("OBSBW") , str(m.nchan * chan_bw))470 assert_equal(be.get_status("OBSFREQ") , DEFAULT_VALUE)471 assert_equal(be.get_status("OBSERVER"), DEFAULT_VALUE)472 assert_equal(be.get_status("OBSID") , DEFAULT_VALUE)473 assert_equal(be.get_status("SWVER") , DEFAULT_VALUE)474def check_l8lbw8_mode(mode, expo):475 """L8LBW8 8-subbands test. This test is not as comprehensive as the476 L8LBW1 tests, since it uses the same code--already tested by L8LBW1477 tests--and focuses instead on the 8-subbands.478 """479 params = dibas_vals(mode, expo)480 b, m, frequency, exposure, expoclks, blanktm, spec_tick, efsampfr, \481 hwexposr, chan_bw, bw_mode, obs_mode, fpga_clk = params482 print "frequency", frequency483 print "exposure", exposure484 print "expoclks", expoclks485 print "blanktm", blanktm486 print "spec_tick", spec_tick487 print "efsampfr", efsampfr488 print "hwexposr", hwexposr489 print "chan_bw", chan_bw490 print "bw_mode", bw_mode491 print "obs_mode", obs_mode492 print "fpga_clk", fpga_clk493 be = VegasL8LBWBackend(b, m, None, None, None, unit_test = True)494 be.setPolarization('CROSS')495 be.setIntegrationTime(expo)496 sbfreqs = [ 300e6, 320e6, 340e6, 360e6, 400e6, 420e6, 440e6, 460e6 ]497 be.set_param("subband_freq", sbfreqs)498 be.clear_switching_states()499 ssg_duration = 0.1500 be.set_gbt_ss(ssg_duration,501 ((0.0, SWbits.SIG, SWbits.CALON, 0.002),502 (0.25, SWbits.SIG, SWbits.CALOFF, 0.002),503 (0.5, SWbits.REF, SWbits.CALON, 0.002),504 (0.75, SWbits.REF, SWbits.CALOFF, 0.002))505 )506 # call dependency methods and update shared memory507 be.prepare()508 regs = be.roach_registers_local509 shm = be.status_mem_local510 shmkeys = shm.keys()511 shmkeys.sort()512 print "Status memory:"513 for i in shmkeys:514 print "%s = %s" % (i, shm[i])515 assert_equals(int(shm['NCHAN']), m.nchan)516 assert_equals(int(shm['NSUBBAND']), 8)517 # 8 subbands checked. L8LBW8 modes use all 8 values.518 # 'assert_almost_equal' checks values to their519 # difference rounded to the value given (5 here), not significant520 # digits. So first obtain real subfreq, divide it by desired521 # subfreq, and that should give a number very close to 1.0, within 5522 # decimal places.523 for i in range(0, 8):524 asb = float(be.get_status("SUB%iFREQ" % i))525 assert_almost_equal(asb / sbfreqs[i], 1.0, 3)526 for i in range(16):527 assert_true("s0_lo_%i_lo_ram" % (i) in regs.keys())528 assert_true("s1_lo_%i_lo_ram" % (i) in regs.keys())529 assert_true("s2_lo_%i_lo_ram" % (i) in regs.keys())530 assert_true("s3_lo_%i_lo_ram" % (i) in regs.keys())531 assert_true("s4_lo_%i_lo_ram" % (i) in regs.keys())532 assert_true("s5_lo_%i_lo_ram" % (i) in regs.keys())533 assert_true("s6_lo_%i_lo_ram" % (i) in regs.keys())534 assert_true("s7_lo_%i_lo_ram" % (i) in regs.keys())535 be.set_param("gain", [1024] * 8)536 be.prepare()537 regs = be.roach_registers_local538 assert_true('mode_sel' in regs.keys())539 assert_equals(int(regs['mode_sel']), 0)540 for i in range(0, 8):541 quant_gain_reg = 's%i_quant_gain' % (i)542 assert_true(quant_gain_reg in regs.keys())543 assert_equals(int(regs[quant_gain_reg]), 1024)544# @with_setup(setup_dibas_tests, None)545def test_MODE1():546 """547 A VegasBackend setup test case.548 """549 check_hbw_mode("MODE1", 0.1)550def test_MODE2():551 """552 A VegasBackend setup test case.553 """554 check_hbw_mode("MODE2", 0.1)555def test_MODE3():556 """557 A VegasBackend setup test case.558 """559 check_hbw_mode("MODE3", 0.1)560def test_MODE4():561 """562 MODE4 L1LBW1 case563 """564 check_l1lbw1_mode("MODE4", 0.1)565def test_MODE5():566 """567 MODE5 L1LBW1 case568 """569 check_l1lbw1_mode("MODE5", 0.1)570def test_MODE6():571 """572 MODE6 L1LBW1 case573 """574 check_l1lbw1_mode("MODE6", 0.1)575def test_MODE7():576 """577 MODE7 L1LBW1 case578 """579 check_l1lbw1_mode("MODE7", 0.1)580def test_MODE8():581 """582 MODE8 L1LBW1 case583 """584 check_l1lbw1_mode("MODE8", 0.1)585def test_MODE9():586 """587 MODE9 L1LBW1 case588 """589 check_l1lbw1_mode("MODE9", 0.1)590def test_MODE10():591 """592 MODE10 L8LBW1 case593 """594 check_l8lbw1_mode("MODE10", 0.1)595def test_MODE11():596 """597 MODE11 L8LBW1 case598 """599 check_l8lbw1_mode("MODE11", 0.1)600def test_MODE12():601 """602 MODE12 L8LBW1 case603 """604 check_l8lbw1_mode("MODE12", 0.1)605def test_MODE13():606 """607 MODE13 L8LBW1 case608 """609 check_l8lbw1_mode("MODE13", 0.1)610def test_MODE14():611 """612 MODE14 L8LBW1 case613 """614 check_l8lbw1_mode("MODE14", 0.1)615def test_MODE15():616 """617 MODE15 L8LBW1 case618 """619 check_l8lbw1_mode("MODE15", 0.1)620def test_MODE16():621 """622 MODE16 L8LBW1 case623 """624 check_l8lbw1_mode("MODE16", 0.1)625def test_MODE17():626 """627 MODE17 L8LBW1 case628 """629 check_l8lbw1_mode("MODE17", 0.1)630def test_MODE18():631 """632 MODE18 L8LBW1 case633 """634 check_l8lbw1_mode("MODE18", 0.1)635def test_MODE19():636 """637 MODE19 L8LBW1 case638 """639 check_l8lbw1_mode("MODE19", 0.1)640def test_MODE20():641 """642 MODE20 L8LBW8 case643 """644 check_l8lbw8_mode("MODE20", 0.1)645def test_MODE21():646 """647 MODE21 L8LBW8 case648 """649 check_l8lbw8_mode("MODE21", 0.1)650def test_MODE22():651 """652 MODE22 L8LBW8 case653 """654 check_l8lbw8_mode("MODE22", 0.1)655def test_MODE23():656 """657 MODE23 L8LBW8 case658 """659 check_l8lbw8_mode("MODE23", 0.1)660def test_MODE24():661 """662 MODE24 L8LBW8 case663 """664 check_l8lbw8_mode("MODE24", 0.1)665def test_MODE25():666 """667 MODE25 L8LBW8 case668 """669 check_l8lbw8_mode("MODE25", 0.1)670def test_MODE26():671 """672 MODE26 L8LBW8 case673 """674 check_l8lbw8_mode("MODE26", 0.1)675def test_MODE27():676 """677 MODE27 L8LBW8 case678 """679 check_l8lbw8_mode("MODE27", 0.1)680def test_MODE28():681 """682 MODE28 L8LBW8 case683 """684 check_l8lbw8_mode("MODE28", 0.1)685def test_MODE29():686 """687 MODE29 L8LBW8 case688 """689 check_l8lbw8_mode("MODE29", 0.1)690def test_GUPPI_INCO_64_backend():691 """692 A GUPPI INCO backend (GuppyBackend) test setup.693 """694 config = ConfigParser.ConfigParser()695 config.readfp(open(dibas_dir + "/etc/config/dibas.conf"))696 b = BankData()697 b.load_config(config, "BANKA")698 m = ModeData()699 m.load_config(config, "INCO_MODE_64")700 m.frequency=800.0701 be = GuppiBackend(b, m, None, None, None, unit_test = True)702 be.set_obs_frequency(1500.0)703 be.prepare()704 print "Status memory:", be.status_mem_local705 print "Roach (int) registers:", be.roach_registers_local706 assert_equal(be.get_status('ACC_LEN'), '512')707 assert_equal(be.get_status('BLOCSIZE'), '33554432')708 assert_almost_equal(float(be.get_status('CHAN_DM')), 0.0)709 assert_almost_equal(float(be.get_status('CHAN_BW')), 12.5)710 assert_equal(be.get_status('DATADIR'), dibas_data)711 assert_equal(be.get_status('DS_TIME'), '1')712 assert_equal(be.get_status('FFTLEN'), '16384')713 assert_equal(be.get_status('NPOL'), '4')714 assert_equal(be.get_status('NRCVR'), '2')715 assert_equal(be.get_status('NBIN'), '256')716 assert_equal(be.get_status('NBITS'), '8')717 assert_almost_equal(float(be.get_status('OBSFREQ')), 1500.0)718 assert_almost_equal(float(be.get_status('OBSBW')), 800.0)719 assert_equal(be.get_status('OBSNCHAN'), '64')720 assert_equal(be.get_status('OBS_MODE'), 'SEARCH')721 assert_almost_equal(float(be.get_status('OFFSET0')), 0.0)722 assert_almost_equal(float(be.get_status('OFFSET1')), 0.0)723 assert_almost_equal(float(be.get_status('OFFSET2')), 0.0)724 assert_almost_equal(float(be.get_status('OFFSET3')), 0.0)725 assert_equal(be.get_status('ONLY_I'), '0')726 assert_equal(be.get_status('OVERLAP'), '0')727 assert_equal(be.get_status('POL_TYPE'), 'IQUV')728 assert_equal(be.get_status('PFB_OVER'), '12')729 assert_equal(be.get_status('PARFILE'), os.getenv('DIBAS_DIR') + '/etc/config/example.par')730 assert_equal(be.get_status('PKTFMT'), '1SFA')731 assert_almost_equal(float(be.get_status('SCALE0')), 1.0)732 assert_almost_equal(float(be.get_status('SCALE1')), 1.0)733 assert_almost_equal(float(be.get_status('SCALE2')), 1.0)734 assert_almost_equal(float(be.get_status('SCALE3')), 1.0)735 assert_almost_equal(float(be.get_status('TBIN')), 4.096e-05)736 assert_almost_equal(float(be.get_status('TFOLD')), 1.0)737 be.set_param("only_i", 1)738 be.prepare()739 assert_equal(be.get_status('ONLY_I'), '1')740 assert_equal(be.get_status('NPOL'), '4')741def test_GUPPI_CODD_64_backend():742 """743 A GUPPI CODD backend (GuppyCODDBackend) test setup.744 """745 config = ConfigParser.ConfigParser()746 config.readfp(open(dibas_dir + "/etc/config/dibas.conf"))747 b = BankData()748 b.load_config(config, "BANKA")749 m = ModeData()750 m.load_config(config, "CODD_MODE_64")751 be = GuppiCODDBackend(b, m, None, None, None, unit_test = True)752 be.set_obs_frequency(1500.0)753 be.set_bandwidth(800.0)754 be.prepare()755 print "Status memory:", be.status_mem_local756 print "Roach (int) registers:", be.roach_registers_local757 assert_equal(be.get_status('NBITS'), '8')758 assert_equal(be.get_status('OFFSET0'), '0.0')759 assert_equal(be.get_status('OFFSET1'), '0.0')760 assert_equal(be.get_status('OFFSET2'), '0.0')761 assert_equal(be.get_status('OFFSET3'), '0.0')762 assert_equal(be.get_status('TFOLD'), '1.0')763 assert_equal(be.get_status('NRCVR'), '2')764 assert_equal(be.get_status('FFTLEN'), '32768')765 assert_equal(be.get_status('CHAN_BW'), '12.5')766 assert_equal(be.get_status('NBIN'), '256')767 assert_equal(be.get_status('OBSNCHAN'), '8')768 assert_equal(be.get_status('SCALE0'), '1.0')769 assert_equal(be.get_status('SCALE1'), '1.0')770 assert_equal(be.get_status('SCALE2'), '1.0')771 assert_equal(be.get_status('SCALE3'), '1.0')772 assert_equal(be.get_status('NPOL'), '4')773 assert_equal(be.get_status('POL_TYPE'), 'AABBCRCI')774 assert_equal(be.get_status('BANKNUM'), '0')775 assert_equal(be.get_status('ONLY_I'), '0')776 assert_equal(be.get_status('BLOCSIZE'), '134201344')777 assert_equal(be.get_status('ACC_LEN'), '1')778 assert_equal(be.get_status('OVERLAP'), '512')779 assert_equal(be.get_status('OBS_MODE'), 'COHERENT_SEARCH')780 assert_almost_equal(float(be.get_status('OBSFREQ')), 1143.75)781 assert_equal(be.get_status('PFB_OVER'), '12')782 assert_equal(be.get_status('PARFILE'), os.getenv('DIBAS_DIR') + '/etc/config/example.par')783 assert_equal(be.get_status('OBSBW'), '100.0')784 assert_equal(be.get_status('DS_TIME'),'512')785 assert_equal(be.get_status('PKTFMT'), '1SFA')786 assert_equal(be.get_status('TBIN'), '8e-08')787 assert_equal(be.get_status('CHAN_DM'), '0.0')788 be.set_param("only_i", 1)789 be.prepare()790 assert_equal(be.get_status('ONLY_I'), '1')...

Full Screen

Full Screen

test_keysight_b220x.py

Source:test_keysight_b220x.py Github

copy

Full Screen

...16 instance = KeysightB220X('switch_matrix',17 address='GPIB::1::INSTR',18 visalib=path_to_yaml + '@sim'19 )20 instance.get_status()21 instance.clear_status()22 instance.reset()23 yield instance24 instance.close()25def test_idn_command(uut):26 assert "AGILENT" in uut.IDN()['vendor']27 assert 0 == uut.get_status()28def test_connect(uut):29 uut.connect(2, 48)30 assert 0 == uut.get_status()31def test_connect_throws_at_invalid_channel_number(uut):32 with pytest.raises(ValueError):33 uut.connect(2, 49)34 with pytest.raises(ValueError):35 uut.connect(2, 0)36 with pytest.raises(ValueError):37 uut.connect(0, 10)38 with pytest.raises(ValueError):39 uut.connect(15, 10)40def test_connect_emits_warning_on_statusbyte_not_null(uut):41 # some tricks are used to trigger an instrument error both in the42 # simulation as well as in the real instrument:43 # 1. with gnd mode enabled, it is illegal to connect to input channel 12,44 # which will raise an instrument error in the physical instrument,45 # but not in the simulated instrument.46 # 2. The simulated instrument only accepts pre-defined channels in the47 # connect command. here a channel is used that was not pre-defined which48 # will cause an instrument error in the simulated instrument, but not in49 # the physical instrument50 uut.gnd_mode(True)51 with pytest.warns(UserWarning):52 uut.connect(12, 33)53 # The simulated instrument does not reset the settings to default54 # values, so gnd mode is explicitly disabled here:55 uut.gnd_mode(False)56def test_disconnect_throws_at_invalid_channel_number(uut):57 with pytest.raises(ValueError):58 uut.disconnect(2, 49)59 with pytest.raises(ValueError):60 uut.disconnect(2, 0)61 with pytest.raises(ValueError):62 uut.disconnect(0, 10)63 with pytest.raises(ValueError):64 uut.disconnect(15, 10)65def test_connections(uut):66 uut.connect(2, 48)67 uut.connect(10, 12)68 assert {(2, 48), (10, 12)} == uut.connections()69def test_to_channel_list(uut):70 assert '(@00345,01109)' == uut.to_channel_list([(3, 45), (11, 9)])71def test_connect_paths(uut):72 uut.disconnect_all()73 uut.connect_paths([(3, 45), (11, 9)])74 assert 0 == uut.get_status()75def test_disconnect_paths(uut):76 uut.connect_paths([(3, 45), (11, 9)])77 uut.disconnect_paths([(3, 45), (11, 9)])78 assert 0 == uut.get_status()79def test_disconnect_all(uut):80 uut.connect(2, 48)81 uut.disconnect_all()82 assert 0 == uut.get_status()83def test_disconnect(uut):84 uut.connect(2, 48)85 assert 0 == uut.get_status()86 uut.disconnect(2, 48)87 assert 0 == uut.get_status()88 uut.disconnect(3, 22)89 assert 0 == uut.get_status()90@pytest.mark.filterwarnings("ignore:When going")91def test_connection_rule(uut):92 uut.connection_rule('single')93 assert 0 == uut.get_status()94 assert 'single' == uut.connection_rule()95 assert 0 == uut.get_status()96def test_connection_rule_emits_warning_when_going_from_free_to_single(uut):97 uut.connection_rule(98 'free') # uut should already be in free mode after reset99 with pytest.warns(UserWarning):100 uut.connection_rule('single')101def test_connection_sequence(uut):102 assert 'bbm' == uut.connection_sequence()103 assert 0 == uut.get_status()104 uut.connection_sequence('mbb')105 assert 0 == uut.get_status()106 assert 'mbb' == uut.connection_sequence()107def test_bias_disable_all_outputs(uut):108 uut.bias_disable_all_outputs()109 assert 0 == uut.get_status()110def test_bias_disable_ouput(uut):111 uut.bias_disable_output(1)112 assert 0 == uut.get_status()113def test_bias_enable_all_outputs(uut):114 uut.bias_enable_all_outputs()115 assert 0 == uut.get_status()116def test_bias_enable_output(uut):117 uut.bias_enable_output(1)118 assert 0 == uut.get_status()119def test_bias_input_port(uut):120 assert 10 == uut.bias_input_port()121 uut.bias_input_port(9)122 assert 9 == uut.bias_input_port()123 assert 0 == uut.get_status()124def test_bias_mode(uut):125 uut.bias_mode(True)126 assert uut.bias_mode()127 assert 0 == uut.get_status()128def test_gnd_disable_all_outputs(uut):129 uut.gnd_disable_all_outputs()130 assert 0 == uut.get_status()131def test_gnd_disable_output(uut):132 uut.gnd_disable_output(1)133 assert 0 == uut.get_status()134def test_gnd_enable_all_outputs(uut):135 uut.gnd_enable_all_outputs()136 assert 0 == uut.get_status()137def test_gnd_enable_output(uut):138 uut.gnd_enable_output(1)139 assert 0 == uut.get_status()140def test_gnd_input_port(uut):141 assert 12 == uut.gnd_input_port()142 uut.gnd_input_port(5)143 assert 5 == uut.gnd_input_port()144 assert 0 == uut.get_status()145def test_gnd_mode(uut):146 assert not uut.gnd_mode()147 uut.gnd_mode(True)148 assert uut.gnd_mode()149 assert 0 == uut.get_status()150def test_unused_inputs(uut):151 uut.unused_inputs()152 assert 0 == uut.get_status()153 uut.unused_inputs([3])154 assert 0 == uut.get_status()155 assert [3] == uut.unused_inputs()156 uut.unused_inputs([5, 6, 7, 8])157 assert 0 == uut.get_status()158 assert [5, 6, 7, 8] == uut.unused_inputs()159def test_couple_mode(uut):160 assert not uut.couple_mode()161 uut.couple_mode(True)162 assert uut.couple_mode()163 assert 0 == uut.get_status()164def test_couple_ports(uut):165 assert not uut.couple_ports()166 assert 0 == uut.get_status()167 uut.couple_ports([1])168 assert 0 == uut.get_status()169 assert [1] == uut.couple_ports()170 uut.couple_ports([1, 3, 5])171 assert 0 == uut.get_status()172 assert [1, 3, 5] == uut.couple_ports()173 with pytest.raises(ValueError):174 uut.couple_ports([2])175 with pytest.raises(ValueError):176 uut.couple_ports([2, 3])177def test_couple_port_autodetect(uut):178 uut.couple_port_autodetect()179 assert 0 == uut.get_status()180def test_get_error(uut):181 uut.get_error()182 assert 0 == uut.get_status()183class TestParseChannelList:184 @staticmethod185 def test_parse_channel_list():186 channel_list = '(@10101,10202)'187 assert {(1, 1), (2, 2)} == KeysightB220X.parse_channel_list(188 channel_list)189 @staticmethod190 def test_all_combinations_zero_padded():191 import itertools192 cards = range(5)193 inputs = range(1, 15)194 outputs = range(1, 49)195 for card, in_port, out_port in itertools.product(cards, inputs,196 outputs):...

Full Screen

Full Screen

streamings.py

Source:streamings.py Github

copy

Full Screen

1from schemas.status import Status2from mastodon import Mastodon, StreamListener3from utils.load_env import ACCESS_TOKEN4from utils.load_yaml import config_dict5from .functions import ( buzz_toot, change_bot_status, get_name, rewrite, food_terro, save_toot, humor_sense,6 humor_sense_return, parrot_toot, greeting_toot, delete_rockman_toot, reply_random_toot, my_post_count, 7 post_count, toot_todays_info, toot_now_info, battle_operation, three_point_generator, base_url)8from datetime import datetime9import time10import re11class Bot(StreamListener):12 bool_keywords = {13 'stop': False,14 'start': True,15 }16 status_keywords = [17 'chime',18 'summer',19 'spring',20 'random'21 ]22 def __init__(self, client):23 super(Bot, self).__init__()24 self.client = client25 def on_update(self, status: Status):26 get_status = status27 get_status['content'] = rewrite(get_status['content'])28 print(datetime.now())29 print(f"==={get_name(get_status['account'])}======\n{get_status['content']}\n\n")30 if get_status['account']['bot'] or get_status['reblog'] != None:31 return32 if 'ロックマン' in get_status['content']:33 self.client.status_favourite(get_status)34 if re.search(r'((お(腹|なか)(空|す)いた)|(腹|はら)(減|へ)った)', get_status['content']):35 food_terro(self.client)36 return37 if "トゥート" in get_status['content'] and "保存" in get_status['content']:38 save_toot(self.client, get_status['content'])39 return40 if re.search(r'(ユーモアセンス|面白い事)', get_status['content']):41 humor_sense(self.client)42 return43 if re.search(r'(つまらない|面白くない)', get_status['content']):44 humor_sense_return(self.client)45 return46 if "何か言って" in get_status['content']:47 reply_random_toot(self.client, get_status)48 return49 if not "りあむ" in get_status['content']:50 if "って言" in get_status['content']:51 parrot_toot(self.client, get_status['content'])52 return53 for greet_word in config_dict['word']['ign_riam']:54 if greet_word['input'] in get_status['content']:55 greeting_toot(self.client, greet_word['output'])56 return57 if "消して" in get_status['content']:58 delete_rockman_toot(self.client, get_status['content'])59 return60 if config_dict['tag']['boost_tag'] in get_status['content']:61 self.client.status_reblog(get_status)62 return63 if "お返事して" in get_status['content']:64 reply_random_toot(self.client, get_status)65 return66 if "トゥート数" in get_status['content'] and "教えて" in get_status['content']:67 if "ロックマンの" in get_status['content']:68 my_post_count(self.client, get_status)69 return70 else:71 post_count(self.client, get_status)72 return73 if "今日" in get_status['content'] and "何日" in get_status['content']:74 toot_todays_info(self.client, get_status)75 return76 if "今" in get_status['content'] and "何時" in get_status['content']:77 toot_now_info(self.client, get_status)78 return79 else:80 if re.match(r'^バトルオペレーション(、|,|!| )?セット!*$', get_status['content']):81 battle_operation(self.client, get_status)82 return83 if get_status['content'].find('三点リーダージェネレーター\n') == 0 and re.search(r'(…|\.\.\.|・・・|・・・)', get_status['content']):84 three_point_generator(self.client, get_status)85 return86 if get_status['account']['id'] == config_dict['developer_account_id']:87 for b_key, b_value in self.bool_keywords.items():88 if b_key in get_status['content']:89 for s_value in self.status_keywords:90 if s_value in get_status['content']:91 change_bot_status(self.client, s_value, b_value, status)92 return93 if "test" in get_status['content']:94 if "buzz_toot" in get_status['content']:95 buzz_toot(self.client)96def Login() -> Mastodon:97 mastodon = Mastodon(98 access_token = ACCESS_TOKEN,99 api_base_url = base_url100 )101 return mastodon102def LTLlisten(client: Mastodon):103 bot = Bot(client)104 while True:105 try:106 client.stream_local(bot)107 except Exception as e:108 print(datetime.now())109 print(e)...

Full Screen

Full Screen

mcping.py

Source:mcping.py Github

copy

Full Screen

...10 # 获取 ping 信息11 host = say.split(":")[0]12 try:13 port = say.split(":")[1]14 get_status = StatusPing(host=host, port=int(port)).get_status()15 except Exception:16 try:17 srv_records = dns.resolver.query("_minecraft._tcp." + host, "SRV")18 srvInfo = {}19 for srv in srv_records:20 srvInfo["host"] = str(srv.target).rstrip(".")21 srvInfo["port"] = srv.port22 get_status = StatusPing(23 host=srvInfo["host"], port=int(srvInfo["port"])24 ).get_status()25 except Exception:26 get_status = StatusPing(host=host).get_status()27 get_status = json.dumps(get_status)28 get_status = re.sub(r"\\u00a7.", "", get_status)29 get_status = json.loads(get_status)30 msg_send = []31 # 服务器信息解析32 # 判断是否报错33 if get_status == "error":34 msg_send = [Plain("服务器信息获取失败")]35 return msg_send36 # 图标37 if "favicon" in get_status:38 favicon = get_status["favicon"][22:-1] + "="39 byte_data = base64.b64decode(favicon)40 img = IMG.open(BytesIO(byte_data)).convert("RGB")...

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 yandex-tank 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