Example #1
0
 def test_parse_connection_strs_notmatch_device(self):
     """" Test an invalid invocation of API parse_connection_strs. Mismatch between the connection strings"""
     device_connstr = 'HostName=testhub.azure-devices.net;DeviceId=mylaptop2;SharedAccessKey=XXXXX'
     hub_connstr = 'HostName=hub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=XXXXX'
     with self.assertRaises(KeyError) as err:
         Utils.parse_connection_strs(device_connstr, hub_connstr)
     self.assertTrue('belongs to' in err.exception.args[0])
Example #2
0
 def test_parse_connection_strs_invalid(self):
     """" Test an invalid invocation of API parse_connection_strs"""
     device_connstr = 'HostName=testhub.azure-devices.net;DeviceId=mylaptop2;SharedAccessKey=XXXXX'
     hub_connstr = device_connstr
     with self.assertRaises(KeyError) as err:
         Utils.parse_connection_strs(device_connstr, hub_connstr)
     self.assertTrue('instead of an device' in err.exception.args[0])
def test_invalid_connectionstring():
    with pytest.raises(KeyError):
        connection_str_dict = Utils.parse_connection_strs(empty_string)
        assert not connection_str_dict
Example #4
0
 def test_parse_connection_strs_valid(self):
     """" Test a valid invocation of API parse_connection_strs"""
     device_connstr = 'HostName=testhub.azure-devices.net;DeviceId=mylaptop2;SharedAccessKey=XXXXX'
     hub_connstr = 'HostName=testhub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=XXXXX'
     data = Utils.parse_connection_strs(device_connstr, hub_connstr)
     self.assertEqual('iothubowner', data['SharedAccessKeyName'])
def test_valid_connectionstring():
    connection_str_dict = Utils.parse_connection_strs(valid_connectionstring)
    assert connection_str_dict[EC.HOSTNAME_KEY] == "testhub.azure-devices.net"
    assert connection_str_dict[EC.DEVICE_ID_KEY] == "testdevice"
    assert connection_str_dict[EC.DEVICE_ACCESS_KEY_KEY] == "othergibberish="