示例#1
0
    def test_007_good_multi_read_results(self):
        """
            Threaded test against reading from different devices which should return good results
        """
        def test_read():
            # thermistor request
            r = requests.get(PREFIX + '/read/thermistor/0000000A/01FF',
                             verify=SSL_CERT)
            self.assertEqual(r.status_code, 200)
            response = json.loads(r.text)
            # self.assertEqual(response['device_raw'], 656)
            self.assertAlmostEqual(response['temperature_c'], 28.7, delta=0.1)

            # humidity request
            r = requests.get(PREFIX + '/read/humidity/0000000A/0CFF',
                             verify=SSL_CERT)
            self.assertEqual(r.status_code, 200)
            response = json.loads(r.text)
            # self.assertEqual(response['device_raw'], 1486313281)
            self.assertEqual(response['temperature_c'], 16.24)
            self.assertEqual(response['humidity'], 38.43)

        executor = TestThreadExecutor(THREAD_COUNT, test_read)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)
示例#2
0
    def test_007_good_multi_read_results(self):
        """
            Threaded test against reading from different devices which should return good results
        """

        def test_read():
            # thermistor request
            r = requests.get(PREFIX + "/read/thermistor/0000000A/01FF", verify=SSL_CERT)
            self.assertEqual(r.status_code, 200)
            response = json.loads(r.text)
            # self.assertEqual(response['device_raw'], 656)
            self.assertAlmostEqual(response["temperature_c"], 28.7, delta=0.1)

            # humidity request
            r = requests.get(PREFIX + "/read/humidity/0000000A/0CFF", verify=SSL_CERT)
            self.assertEqual(r.status_code, 200)
            response = json.loads(r.text)
            # self.assertEqual(response['device_raw'], 1486313281)
            self.assertEqual(response["temperature_c"], 16.24)
            self.assertEqual(response["humidity"], 38.43)

        executor = TestThreadExecutor(THREAD_COUNT, test_read)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)
示例#3
0
    def test_002_bad_scan_results(self):
        """
            Threaded test against a scan which should not return good results
        """
        def test_scan():
            r = requests.get(PREFIX + '/scan/0000000B', verify=SSL_CERT)
            self.assertEqual(r.status_code, 500)

        executor = TestThreadExecutor(THREAD_COUNT, test_scan)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)
示例#4
0
    def test_002_bad_scan_results(self):
        """
            Threaded test against a scan which should not return good results
        """

        def test_scan():
            r = requests.get(PREFIX + "/scan/0000000B", verify=SSL_CERT)
            self.assertEqual(r.status_code, 500)

        executor = TestThreadExecutor(THREAD_COUNT, test_scan)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)
示例#5
0
    def test_010_bad_power_results(self):
        """
            Threaded test against a power status request which should not return good results
        """
        def test_power():
            r = requests.get(PREFIX + "/power/status/0000000B/02FF",
                             auth=HTTPBasicAuth(TEST_USERNAME, TEST_PASSWORD),
                             verify=SSL_CERT)
            self.assertEqual(r.status_code, 500)

        executor = TestThreadExecutor(THREAD_COUNT, test_power)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)
示例#6
0
    def test_003_good_version_results(self):
        """
            Threaded test against a version request which should return good results
        """
        def test_version():
            r = requests.get(PREFIX + '/version/0000000A', verify=SSL_CERT)
            self.assertEqual(r.status_code, 200)
            response = json.loads(r.text)
            self.assertEqual(response['firmware_version'],
                             'Version Response 1')

        executor = TestThreadExecutor(THREAD_COUNT, test_version)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)
示例#7
0
    def test_001_good_scan_results(self):
        """
            Threaded test against a scan which should return good results
        """
        def test_scan():
            r = requests.get(PREFIX + '/scan/0000000A', verify=SSL_CERT)
            self.assertEqual(r.status_code, 200)
            response = json.loads(r.text)
            self.assertEqual(len(response['boards']), 1)
            self.assertEqual(len(response['boards'][0]['devices']), 3)

        executor = TestThreadExecutor(THREAD_COUNT, test_scan)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)
示例#8
0
    def test_003_good_version_results(self):
        """
            Threaded test against a version request which should return good results
        """

        def test_version():
            r = requests.get(PREFIX + "/version/0000000A", verify=SSL_CERT)
            self.assertEqual(r.status_code, 200)
            response = json.loads(r.text)
            self.assertEqual(response["firmware_version"], "Version Response 1")

        executor = TestThreadExecutor(THREAD_COUNT, test_version)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)
示例#9
0
    def test_001_good_scan_results(self):
        """
            Threaded test against a scan which should return good results
        """

        def test_scan():
            r = requests.get(PREFIX + "/scan/0000000A", verify=SSL_CERT)
            self.assertEqual(r.status_code, 200)
            response = json.loads(r.text)
            self.assertEqual(len(response["boards"]), 1)
            self.assertEqual(len(response["boards"][0]["devices"]), 3)

        executor = TestThreadExecutor(THREAD_COUNT, test_scan)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)
示例#10
0
    def test_010_bad_power_results(self):
        """
            Threaded test against a power status request which should not return good results
        """

        def test_power():
            r = requests.get(
                PREFIX + "/power/status/0000000B/02FF",
                auth=HTTPBasicAuth(TEST_USERNAME, TEST_PASSWORD),
                verify=SSL_CERT,
            )
            self.assertEqual(r.status_code, 500)

        executor = TestThreadExecutor(THREAD_COUNT, test_power)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)
示例#11
0
    def test_008_bad_multi_read_results(self):
        """
            Threaded test against reading from different devices which should not return good results
        """

        def test_read():
            # thermistor request
            r = requests.get(PREFIX + "/read/thermistor/0000000B/01FF", verify=SSL_CERT)
            self.assertEqual(r.status_code, 500)

            # humidity request
            r = requests.get(PREFIX + "/read/humidity/0000000B/0CFF", verify=SSL_CERT)
            self.assertEqual(r.status_code, 500)

        executor = TestThreadExecutor(THREAD_COUNT, test_read)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)
示例#12
0
    def test_008_bad_multi_read_results(self):
        """
            Threaded test against reading from different devices which should not return good results
        """
        def test_read():
            # thermistor request
            r = requests.get(PREFIX + '/read/thermistor/0000000B/01FF',
                             verify=SSL_CERT)
            self.assertEqual(r.status_code, 500)

            # humidity request
            r = requests.get(PREFIX + '/read/humidity/0000000B/0CFF',
                             verify=SSL_CERT)
            self.assertEqual(r.status_code, 500)

        executor = TestThreadExecutor(THREAD_COUNT, test_read)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)
示例#13
0
    def test_009_good_power_results(self):
        """
            Threaded test against a power status request which should return good results
        """
        def test_power():
            r = requests.get(PREFIX + "/power/status/0000000A/02FF",
                             auth=HTTPBasicAuth(TEST_USERNAME, TEST_PASSWORD),
                             verify=SSL_CERT)
            self.assertEqual(r.status_code, 200)
            response = json.loads(r.text)
            self.assertEqual(response["pmbus_raw"], "64,0,0,0")
            self.assertEqual(response["power_status"], "off")
            self.assertEqual(response["power_ok"], True)
            self.assertEqual(response["over_current"], False)
            self.assertEqual(response["under_voltage"], False)

        executor = TestThreadExecutor(THREAD_COUNT, test_power)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)
示例#14
0
    def test_006_bad_read_results(self):
        """
            Threaded test against a read request which should not return good results
        """

        def test_read_thermistor():
            r = requests.get(PREFIX + "/read/thermistor/0000000B/01FF", verify=SSL_CERT)
            self.assertEqual(r.status_code, 500)

        def test_read_humidity():
            r = requests.get(PREFIX + "/read/humidity/0000000B/0CFF", verify=SSL_CERT)
            self.assertEqual(r.status_code, 500)

        executor = TestThreadExecutor(THREAD_COUNT, test_read_thermistor)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)

        executor = TestThreadExecutor(THREAD_COUNT, test_read_humidity)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)
示例#15
0
    def test_009_good_power_results(self):
        """
            Threaded test against a power status request which should return good results
        """

        def test_power():
            r = requests.get(
                PREFIX + "/power/status/0000000A/02FF",
                auth=HTTPBasicAuth(TEST_USERNAME, TEST_PASSWORD),
                verify=SSL_CERT,
            )
            self.assertEqual(r.status_code, 200)
            response = json.loads(r.text)
            self.assertEqual(response["pmbus_raw"], "64,0,0,0")
            self.assertEqual(response["power_status"], "off")
            self.assertEqual(response["power_ok"], True)
            self.assertEqual(response["over_current"], False)
            self.assertEqual(response["under_voltage"], False)

        executor = TestThreadExecutor(THREAD_COUNT, test_power)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)
示例#16
0
    def test_006_bad_read_results(self):
        """
            Threaded test against a read request which should not return good results
        """
        def test_read_thermistor():
            r = requests.get(PREFIX + '/read/thermistor/0000000B/01FF',
                             verify=SSL_CERT)
            self.assertEqual(r.status_code, 500)

        def test_read_humidity():
            r = requests.get(PREFIX + '/read/humidity/0000000B/0CFF',
                             verify=SSL_CERT)
            self.assertEqual(r.status_code, 500)

        executor = TestThreadExecutor(THREAD_COUNT, test_read_thermistor)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)

        executor = TestThreadExecutor(THREAD_COUNT, test_read_humidity)
        results = executor.execute()
        for result in results:
            self.assertEqual(result, True)