Example #1
0
class TestUriSetters:
    def setup(self):
        self.uri = URI(
            'http://*****:*****@example.com:8080/foo?bar=baz#anchor'
        )

    def test_set_protocol(self):
        assert str(
            self.uri.protocol(value='https')
        ) == 'https://*****:*****@example.com:8080/foo?bar=baz#anchor'

    def test_set_username(self):
        assert str(
            self.uri.username(value='eggsample')
        ) == 'http://*****:*****@example.com:8080/foo?bar=baz#anchor'

    def test_set_password(self):
        assert str(
            self.uri.password(value='secret')
        ) == 'http://*****:*****@example.com:8080/foo?bar=baz#anchor'

    def test_set_hostname(self):
        assert str(
            self.uri.hostname(value='example.net')
        ) == 'http://*****:*****@example.net:8080/foo?bar=baz#anchor'

    def test_set_port(self):
        assert str(
            self.uri.port(value='7070')
        ) == 'http://*****:*****@example.com:7070/foo?bar=baz#anchor'
Example #2
0
class TestUriSetters:
  def setup(self):
    self.uri = URI('http://*****:*****@example.com:8080/foo?bar=baz#anchor')

  def test_set_protocol(self):
    assert str(self.uri.protocol(value='https')) == 'https://*****:*****@example.com:8080/foo?bar=baz#anchor'

  def test_set_username(self):
    assert str(self.uri.username(value='eggsample')) == 'http://*****:*****@example.com:8080/foo?bar=baz#anchor'

  def test_set_password(self):
    assert str(self.uri.password(value='secret')) == 'http://*****:*****@example.com:8080/foo?bar=baz#anchor'

  def test_set_hostname(self):
    assert str(self.uri.hostname(value='example.net')) == 'http://*****:*****@example.net:8080/foo?bar=baz#anchor'

  def test_set_port(self):
    assert str(self.uri.port(value='7070')) == 'http://*****:*****@example.com:7070/foo?bar=baz#anchor'