def test_indexing_key_returns_corresponding_value(self): cs = ConnectionString( "HostName=my.host.name;SharedAccessKeyName=mykeyname;SharedAccessKey=Zm9vYmFy" ) assert cs["HostName"] == "my.host.name" assert cs["SharedAccessKeyName"] == "mykeyname" assert cs["SharedAccessKey"] == "Zm9vYmFy"
def test_calling_get_with_key_returns_corresponding_value(self): cs = ConnectionString( "HostName=my.host.name;SharedAccessKeyName=mykeyname;SharedAccessKey=Zm9vYmFy" ) assert cs.get("HostName") == "my.host.name"
def test_indexing_key_raises_key_error_if_key_not_in_string(self): with pytest.raises(KeyError): cs = ConnectionString( "HostName=my.host.name;SharedAccessKeyName=mykeyname;SharedAccessKey=Zm9vYmFy" ) cs["SharedAccessSignature"]
def test_string_representation_of_object_is_the_input_string(self): string = "HostName=my.host.name;SharedAccessKeyName=mykeyname;SharedAccessKey=Zm9vYmFy" cs = ConnectionString(string) assert str(cs) == string
def test_raises_value_error_on_bad_input(self, input_string): with pytest.raises(ValueError): ConnectionString(input_string)
def test_instantiates_correctly_from_string(self, input_string): cs = ConnectionString(input_string) assert isinstance(cs, ConnectionString)
def test_calling_get_with_invalid_key_and_a_default_value_returns_default_value(self): cs = ConnectionString( "HostName=my.host.name;SharedAccessKeyName=mykeyname;SharedAccessKey=Zm9vYmFy" ) assert cs.get("invalidkey", "defaultval") == "defaultval"