<filename>subcontractor/handler_test.py
import re
from subcontractor.handler import _hideify


def test_hideify():
  paramaters = { 'a': 'b' }
  assert _hideify( paramaters ) == { 'a': 'b' }
  assert paramaters == { 'a': 'b' }

  paramaters = { 'password': '<PASSWORD>' }
  assert _hideify( paramaters ) == { 'password': '<PASSWORD>' }
  assert paramaters == { 'password': '<PASSWORD>' }

  paramaters = [ { 'a': 'b', 'c': 'd' }, { 'z': 'x', 'y': 43 } ]
  assert _hideify( paramaters ) == [ { 'a': 'b', 'c': 'd' }, { 'z': 'x', 'y': 43 } ]
  assert paramaters == [ { 'a': 'b', 'c': 'd' }, { 'z': 'x', 'y': 43 } ]

  paramaters = [ { 'a': 'b', 'token': '<PASSWORD>', 'c': 'd' }, { 'z': 'x', 'y': 43, 'password': 'private' } ]
  assert _hideify( paramaters ) == [ { 'a': 'b', 'token': '<PASSWORD>', 'c': 'd' }, { 'z': 'x', 'y': 43, 'password': '<PASSWORD>' } ]
  assert paramaters == [ { 'a': 'b', 'token': '<PASSWORD>', 'c': 'd' }, { 'z': 'x', 'y': 43, 'password': '<PASSWORD>' } ]

  paramaters = 'asdf'
  assert _hideify( paramaters ) == 'asdf'
  assert paramaters == 'asdf'

  paramaters = 123
  assert _hideify( paramaters ) == 123
  assert paramaters == 123

  paramaters = {}
  assert _hideify( paramaters ) == {}
  assert paramaters == {}

  paramaters = []
  assert _hideify( paramaters ) == []
  assert paramaters == []

  tmp_obj = object()
  paramaters = { 'a': re.compile( '' ), 'password': '<PASSWORD>', 'b': tmp_obj }
  assert _hideify( paramaters ) == { 'a': re.compile( '' ), 'password': '<PASSWORD>', 'b': tmp_obj }
  assert paramaters == { 'a': re.compile( '' ), 'password': '<PASSWORD>', 'b': tmp_obj }

  paramaters = [ { 'a': 'b', 'c': 'd' }, { 'z': 'x', 'y': 43 }, [ { 'sdf': 'sdf', 'bob': [ 1, 23, 3, 4, { 'token': 'hi' } ] } ] ]
  assert _hideify( paramaters ) == [ { 'a': 'b', 'c': 'd' }, { 'z': 'x', 'y': 43 }, [ { 'sdf': 'sdf', 'bob': [ 1, 23, 3, 4, { 'token': '<PASSWORD>' } ] } ] ]
  assert paramaters == [ { 'a': 'b', 'c': 'd' }, { 'z': 'x', 'y': 43 }, [ { 'sdf': 'sdf', 'bob': [ 1, 23, 3, 4, { 'token': 'hi' } ] } ] ]
