Esempio n. 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'
Esempio n. 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'
Esempio n. 3
0
def test_create_uri():
  simple_uri = URI('http://example.com/foo?bar=baz')
  assert simple_uri.toString() == 'http://example.com/foo?bar=baz'
Esempio n. 4
0
 def setup(self):
   self.uri = URI('http://*****:*****@example.com:8080/foo?bar=baz#anchor')
Esempio n. 5
0
def test_removeQuery_is_same_as_removeSearch():
  uri = URI('http://example.com/foo?bar=baz')
  assert uri.removeQuery(['bar']).toString() == uri.removeSearch(['bar']).toString()
Esempio n. 6
0
def test_removing_only_keys_with_given_value_from_uri():
  uri = URI("http://example.com/foo?bar=baz&name=sue")
  assert uri.removeSearch(['bar'], 'baz').toString() == "http://example.com/foo?name=sue"
Esempio n. 7
0
def test_removing_multiple_search_keys_and_values_from_uri_given_keys():
  uri = URI('http://example.com/foo?bar=baz&sam=sue')
  assert uri.removeSearch(['bar', 'sam']).toString() == 'http://example.com/foo'
Esempio n. 8
0
def test_removing_search_value_and_key_from_uri_given_key():
  uri = URI('http://example.com/foo?bar=baz')
  assert uri.removeSearch(['bar']).toString() == 'http://example.com/foo'
Esempio n. 9
0
 def setup(self):
     self.uri = URI(
         'http://*****:*****@example.com:8080/foo?bar=baz#anchor'
     )
Esempio n. 10
0
def test_removing_only_keys_with_given_value_from_uri():
    uri = URI("http://example.com/foo?bar=baz&name=sue")
    assert uri.removeSearch(
        ['bar'], 'baz').toString() == "http://example.com/foo?name=sue"
Esempio n. 11
0
def test_removeQuery_is_same_as_removeSearch():
    uri = URI('http://example.com/foo?bar=baz')
    assert uri.removeQuery(['bar'
                            ]).toString() == uri.removeSearch(['bar'
                                                               ]).toString()
Esempio n. 12
0
def test_removing_multiple_search_keys_and_values_from_uri_given_keys():
    uri = URI('http://example.com/foo?bar=baz&sam=sue')
    assert uri.removeSearch(['bar',
                             'sam']).toString() == 'http://example.com/foo'
Esempio n. 13
0
def test_removing_search_value_and_key_from_uri_given_key():
    uri = URI('http://example.com/foo?bar=baz')
    assert uri.removeSearch(['bar']).toString() == 'http://example.com/foo'
Esempio n. 14
0
def test_fragment_parsed():
    # Not sure if this is a good uri w/ both query and fragment...
    fragment_uri = URI('http://example.com/foo?bar=baz#anchor')
    assert fragment_uri._fragment == 'anchor'
Esempio n. 15
0
def test_create_uri():
    simple_uri = URI('http://example.com/foo?bar=baz')
    assert simple_uri.toString() == 'http://example.com/foo?bar=baz'
Esempio n. 16
0
# Copyright (c) 2013, 2018 National Technology and Engineering Solutions of Sandia, LLC . Under the terms of Contract
# DE-NA0003525 with National Technology and Engineering Solutions of Sandia, LLC, the U.S. Government
# retains certain rights in this software.

import pytest
from slycat.uri import URI

auth_uri = URI('http://*****:*****@example.com:8080/foo?bar=baz')


def test_create_uri():
    simple_uri = URI('http://example.com/foo?bar=baz')
    assert simple_uri.toString() == 'http://example.com/foo?bar=baz'


def test_toString_same_as_valueOf():
    assert auth_uri.toString(
    ) == 'http://*****:*****@example.com:8080/foo?bar=baz'


def test_valueOf_returns_same_as_toString():
    assert auth_uri.valueOf() == auth_uri.toString()


def test_protocol_parsed():
    assert auth_uri.protocol() == 'http'


def test_scheme_is_same_as_protocol():
    assert auth_uri.scheme() == auth_uri.protocol()