def test_001_read_valid(self): """ Read a valid on value back from chamber led. """ r = http.get(PREFIX + "/led/rack_1/00000070/0001/on/ffffff/steady") self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response["led_state"], 'on') self.assertEqual(response["led_color"], 'ffffff') self.assertEqual(response["blink_state"], 'steady') r = http.get(PREFIX + "/led/rack_1/00000070/0001/off/000000/no_override") self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response["led_state"], 'off') self.assertEqual(response["led_color"], '000000') self.assertEqual(response["blink_state"], 'steady') r = http.get(PREFIX + "/led/rack_1/00000070/0001/no_override/7ac055/blink") self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response["led_state"], 'off') self.assertEqual(response["led_color"], '7ac055') self.assertEqual(response["blink_state"], 'blink') r = http.get(PREFIX + "/led/rack_1/00000070/0001/on/0beef0/no_override") self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response["led_state"], 'on') self.assertEqual(response["led_color"], '0beef0') self.assertEqual(response["blink_state"], 'blink')
def test_05_read(self): """ Test reading a Redfish device. This should fail since the fan device is not 'present' in the emulator. """ with self.assertRaises(VaporHTTPError): http.get(PREFIX + '/read/fan_speed/rack_1/70000000/0041')
def test_002_read_mid(self): """ Get a midpoint value for each supported conversion method """ r = http.get(PREFIX + "/read/thermistor/rack_1/00000014/04FF") self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response["device_raw"], 32768) self.assertEqual(response["temperature_c"], -4173.97) r = http.get(PREFIX + "/read/humidity/rack_1/00000014/05FF") self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response["device_raw"], 65535) # 0x0000FFFF self.assertAlmostEqual(response["temperature_c"], 125, 1) # max self.assertEqual(response["humidity"], 0) # zero r = http.get(PREFIX + "/read/humidity/rack_1/00000014/05FF") self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response["device_raw"], 4294901760) # 0xFFFF0000 self.assertEqual(response["temperature_c"], -40) # zero self.assertAlmostEqual(response["humidity"], 100, 1) # max with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/read/rack_1/none/00000014/06FF") self.assertEqual(ctx.exception.status, 500)
def test_017_read_pressure_invalid(self): """ Read invalid pressure value (invalid) """ with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/read/rack_1/pressure/00000016/0002") self.assertEqual(ctx.exception.status, 500)
def test_012_read_temperature_invalid(self): """ Read invalid temperature value (invalid) """ with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/read/temperature/rack_1/00000015/0002") self.assertEqual(ctx.exception.status, 500)
def test_06_read(self): """ Test reading a Redfish device. This should fail since 'power' is unsupported for Redfish reads. """ with self.assertRaises(VaporHTTPError): http.get(PREFIX + '/read/rack_1/power/70000000/0100')
def test_003_read_diff_board_diff_device(self): """ Test reading thermistor devices on different boards, where both devices have the same length of responses and repeatable=true. One device being tested does not start at the first response since previous tests have incremented its counter. """ r = http.get(PREFIX + "/read/temperature/rack_1/00000001/03FF") self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response["temperature_c"], 202) r = http.get(PREFIX + "/read/temperature/rack_1/00000003/02FF") self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response["temperature_c"], 800) r = http.get(PREFIX + "/read/temperature/rack_1/00000001/03FF") self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response["temperature_c"], 203) r = http.get(PREFIX + "/read/temperature/rack_1/00000003/02FF") self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response["temperature_c"], 801)
def test_003_read_empty(self): """ Read an empty data value back. """ with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/boot_target/rack_1/00000040/0003") self.assertEqual(ctx.exception.status, 500)
def test_003_no_boards(self): """ Test for no boards. """ with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/scan/rack_1/000000D2") self.assertEqual(ctx.exception.status, 500)
def test_013_scan_board_id_invalid(self): """ Test scan while specifying different invalid representations for the board id to ensure out-of-range values are not handled (e.g. set bits on packet that should not be set) """ with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/scan/rack_1/FFFFFFFF") self.assertEqual(ctx.exception.status, 500) with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/scan/rack_1/FFFFFFFFFFFFFFFF") self.assertEqual(ctx.exception.status, 500) with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/scan/rack_1/20000000") self.assertEqual(ctx.exception.status, 500) with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/scan/rack_1/10000000") self.assertEqual(ctx.exception.status, 500) with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/scan/rack_1/-10000000") self.assertEqual(ctx.exception.status, 500)
def test_011_write_neg_num(self): """ Test write with negative numbers. """ with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/fan/rack_1/00000028/0001/-4100") self.assertEqual(ctx.exception.status, 500)
def test_015_triple_version_retry_fail(self): """ Single retry, valid retry response """ with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + '/version/rack_1/14') self.assertEqual(ctx.exception.status, 500)
def test_012_write_string(self): """ Test write with string. """ with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/fan/rack_1/00000028/0001/faster") self.assertEqual(ctx.exception.status, 500)
def test_013_triple_read_retry_fail(self): """ Single retry, valid retry response """ with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + '/read/thermistor/rack_1/14/01ff') self.assertEqual(ctx.exception.status, 500)
def test_014_triple_power_retry_fail(self): """ Single retry, valid retry response """ with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + '/power/status/14/02ff') self.assertEqual(ctx.exception.status, 500)
def test_003_invalid_board_location(self): """ Test simple location (invalid board) """ with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/location/rack_1/800000000") self.assertEqual(ctx.exception.status, 500) with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/location/rack_1/8000000000") self.assertEqual(ctx.exception.status, 500) with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/location/rack_1/hot_dog") self.assertEqual(ctx.exception.status, 500) with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/location/rack_1/AAAAAAAAA") self.assertEqual(ctx.exception.status, 500) with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/location/rack_1/-1") self.assertEqual(ctx.exception.status, 500)
def test_010_write_with_bad_response(self): """ Test write with bad responses. """ # W2 with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/led/rack_1/00000030/0003/on") self.assertEqual(ctx.exception.status, 500) # W3 with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/led/rack_1/00000030/0003/on") self.assertEqual(ctx.exception.status, 500) # 1 with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/led/rack_1/00000030/0003/on") self.assertEqual(ctx.exception.status, 500) # 0 with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/led/rack_1/00000030/0003/on") self.assertEqual(ctx.exception.status, 500) # 2 with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/led/rack_1/00000030/0003/on") self.assertEqual(ctx.exception.status, 500)
def test_08_asset(self): """ Test the asset endpoint in Redfish mode. Tests getting asset info of a device that does not exist """ with self.assertRaises(VaporHTTPError): http.get(PREFIX + '/asset/rack_1/70000000/0056')
def test_015_write_with_bad_response(self): """ Test write with bad response. """ with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/fan/rack_1/00000028/0002/4100") self.assertEqual(ctx.exception.status, 500)
def test_011_write_with_bad_response(self): """ Test write with bad response. """ with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/boot_target/rack_1/00000040/0003/hdd") self.assertEqual(ctx.exception.status, 500)
def test_002_device_reads(self): for x in range(100): r = http.get(PREFIX + "/read/thermistor/rack_1/00000001/01FF") self.assertTrue(http.request_ok(r.status_code)) r = http.get(PREFIX + "/read/humidity/rack_1/00000001/0CFF") self.assertTrue(http.request_ok(r.status_code))
def test_007_board_id_representation(self): """ Test reading while specifying different representations (same value) for the board id """ r = http.get(PREFIX + "/read/thermistor/rack_1/14/04FF") self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response["device_raw"], 32768) self.assertEqual(response["temperature_c"], -4173.97) r = http.get(PREFIX + "/read/thermistor/rack_1/014/04FF") self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response["device_raw"], 32768) self.assertEqual(response["temperature_c"], -4173.97) r = http.get(PREFIX + "/read/thermistor/rack_1/00014/04FF") self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response["device_raw"], 32768) self.assertEqual(response["temperature_c"], -4173.97) r = http.get(PREFIX + "/read/thermistor/rack_1/000014/04FF") self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response["device_raw"], 32768) self.assertEqual(response["temperature_c"], -4173.97) r = http.get(PREFIX + "/read/thermistor/rack_1/00000014/04FF") self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response["device_raw"], 32768) self.assertEqual(response["temperature_c"], -4173.97)
def test_08_led(self): """ Test the led endpoint in Redfish mode. Test passing in an invalid LED command option. """ with self.assertRaises(VaporHTTPError): http.get(PREFIX + '/led/rack_1/70000000/0300/non-option')
def test_005_many_devices(self): """ Test for one board many devices. """ with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/scan/rack_1/00000002") self.assertEqual(ctx.exception.status, 500)
def test_007_write_ok(self): """ Test write with an ok response. """ r = http.get(PREFIX + "/led/rack_1/00000030/0001/on") self.assertTrue(http.request_ok(r.status_code)) r = http.get(PREFIX + "/led/rack_1/00000030/0001/off") self.assertTrue(http.request_ok(r.status_code))
def test_08_fan(self): """ Test the fan endpoint in Redfish mode. This should fail because the fan device is not present, so it cannot be read from. """ with self.assertRaises(VaporHTTPError): http.get(PREFIX + '/fan/rack_1/70000000/0042')
def test_010_bad_url(self): """ Get no packet in return. """ # bad url with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/scan/") self.assertEqual(ctx.exception.status, 404)
def test_004_no_devices(self): """ Test for one board no devices. """ with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/scan/rack_1/00000001") self.assertEqual(ctx.exception.status, 500) # should this really be so?
def test_006_no_data(self): """ Timeout. """ # timeout with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/read/rack_1/none/00000014/10FF") self.assertEqual(ctx.exception.status, 500)
def test_009_no_data(self): """ Get no packet in return. """ # TIMEOUT with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + "/scan/rack_1/0000C800") self.assertEqual(ctx.exception.status, 500)