Exemplo n.º 1
0
 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"
Exemplo n.º 2
0
def test___getitem__item_exists():
    cs = ConnectionString(
        "HostName=my.host.name;SharedAccessKeyName=mykeyname;SharedAccessKey=Zm9vYmFy"
    )
    assert cs["HostName"] == "my.host.name"
    assert cs["SharedAccessKeyName"] == "mykeyname"
    assert cs["SharedAccessKey"] == "Zm9vYmFy"
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 def test_raises_value_error_on_bad_input(self, input_string):
     with pytest.raises(ValueError):
         ConnectionString(input_string)
Exemplo n.º 5
0
 def test_instantiates_correctly_from_string(self, input_string):
     cs = ConnectionString(input_string)
     assert isinstance(cs, ConnectionString)
Exemplo n.º 6
0
def test_get_item_does_not_exist_no_given_default():
    cs = ConnectionString(
        "HostName=my.host.name;SharedAccessKeyName=mykeyname;SharedAccessKey=Zm9vYmFy"
    )
    assert cs.get("invalidkey") == None
Exemplo n.º 7
0
def test_get_item_exists():
    cs = ConnectionString(
        "HostName=my.host.name;SharedAccessKeyName=mykeyname;SharedAccessKey=Zm9vYmFy"
    )
    assert cs.get("HostName") == "my.host.name"
Exemplo n.º 8
0
 def test_garbage_input(self):
     with pytest.raises(ValueError):
         ConnectionString("garbage")
Exemplo n.º 9
0
 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"
Exemplo n.º 10
0
def test___repr__():
    string = "HostName=my.host.name;SharedAccessKeyName=mykeyname;SharedAccessKey=Zm9vYmFy"
    cs = ConnectionString(string)
    assert str(cs) == string
Exemplo n.º 11
0
 def test_module_string_with_gateway_hostname(self):
     ConnectionString(
         "HostName=my.host.name;DeviceId=my-device;ModuleId=my-module;SharedAccessKey=Zm9vYmFy;GatewayHostName=mygateway"
     )
Exemplo n.º 12
0
 def test_module_string(self):
     ConnectionString(
         "HostName=my.host.name;DeviceId=my-device;ModuleId=my-module;SharedAccessKey=Zm9vYmFy"
     )
Exemplo n.º 13
0
 def test_service_string(self):
     ConnectionString(
         "HostName=my.host.name;SharedAccessKeyName=mykeyname;SharedAccessKey=Zm9vYmFy"
     )
Exemplo n.º 14
0
 def test_duplicate_key(self):
     with pytest.raises(ValueError):
         ConnectionString(
             "HostName=my.host.name;HostName=my.host.name;SharedAccessKey=mykeyname;SharedAccessKey=Zm9vYmFy"
         )
Exemplo n.º 15
0
 def test_invalid_key(self):
     with pytest.raises(ValueError):
         ConnectionString(
             "InvalidKey=my.host.name;SharedAccessKeyName=mykeyname;SharedAccessKey=Zm9vYmFy"
         )
Exemplo n.º 16
0
 def test_incomplete_input(self):
     with pytest.raises(ValueError):
         ConnectionString("HostName=my.host.name")
Exemplo n.º 17
0
 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"]
Exemplo n.º 18
0
def test___getitem__item_does_not_exist():
    with pytest.raises(KeyError):
        cs = ConnectionString(
            "HostName=my.host.name;SharedAccessKeyName=mykeyname;SharedAccessKey=Zm9vYmFy"
        )
        cs["SharedAccessSignature"]
Exemplo n.º 19
0
 def test_calling_get_with_invalid_key_and_no_default_value_returns_none(
         self):
     cs = ConnectionString(
         "HostName=my.host.name;SharedAccessKeyName=mykeyname;SharedAccessKey=Zm9vYmFy"
     )
     assert cs.get("invalidkey") is None
Exemplo n.º 20
0
 def test_empty_input(self):
     with pytest.raises(ValueError):
         ConnectionString("")