Beispiel #1
0
def test_replace_param_type_inference():
    param = replace_param('1234')
    assert param == 1234
    param = replace_param('0.5')
    assert param == 0.5
    param = replace_param("{'a':'test1','b':'test2','c':'test3'}")
    assert param == {'a': 'test1', 'b': 'test2', 'c': 'test3'}
    param = replace_param("['1','2','3']")
    assert param == ['1', '2', '3']
Beispiel #2
0
def test_replace_param_type_inference_disabled():
    param = replace_param('1234', infer_param_type=False)
    assert param == '1234'
    param = replace_param('0.5', infer_param_type=False)
    assert param == '0.5'
    param = replace_param("{'a':'test1','b':'test2','c':'test3'}",
                          infer_param_type=False)
    assert param == "{'a':'test1','b':'test2','c':'test3'}"
    param = replace_param("['1','2','3']", infer_param_type=False)
    assert param == "['1','2','3']"
Beispiel #3
0
def test_replace_param_type_inference():
    param = replace_param('1234')  # int
    assert param == 1234
    param = replace_param('0.5')  # float
    assert param == 0.5
    param = replace_param('True')  # boolean
    assert param is True
    param = replace_param('None')  # None
    assert param is None
    param = replace_param("{'a':'test1', 'b':True, 'c':None}")  # dict
    assert param == {'a': 'test1', 'b': True, 'c': None}
    param = replace_param("['1', True,None]")  # list
    assert param == ['1', True, None]
    param = replace_param('{"a":"test1", "b":true, "c":null}')  # JSON object
    assert param == {'a': 'test1', 'b': True, 'c': None}
    param = replace_param('["1", true, null]')  # JSON list
    assert param == ['1', True, None]
    param = replace_param('true')  # JSON boolean
    assert param == 'true'
    param = replace_param('null')  # JSON null
    assert param == 'null'
Beispiel #4
0
def test_replace_param_type_inference_disabled():
    param = replace_param('1234', infer_param_type=False)
    assert param == '1234'
    param = replace_param('0.5', infer_param_type=False)
    assert param == '0.5'
    param = replace_param('True', infer_param_type=False)
    assert param == 'True'
    param = replace_param('None', infer_param_type=False)
    assert param == 'None'
    param = replace_param("{'a':'test1', 'b':True, 'c':None}",
                          infer_param_type=False)
    assert param == "{'a':'test1', 'b':True, 'c':None}"
    param = replace_param("['1', True, None]", infer_param_type=False)
    assert param == "['1', True, None]"
    param = replace_param('{"a":"test1", "b":true, "c":null}',
                          infer_param_type=False)
    assert param == '{"a":"test1", "b":true, "c":null}'
    param = replace_param('["1", true, null]', infer_param_type=False)
    assert param == '["1", true, null]'
Beispiel #5
0
def test_replace_param_string_array_with_length():
    param = replace_param('[STRING_ARRAY_WITH_LENGTH_5]')
    assert param == ['a', 'a', 'a', 'a', 'a']
Beispiel #6
0
def test_replace_param_str():
    param = replace_param('[STR:abc]')
    assert type(param) == str
    assert param == 'abc'
Beispiel #7
0
def test_replace_param_string_with_length():
    param = replace_param('[STRING_WITH_LENGTH_5]')
    assert param == 'aaaaa'
Beispiel #8
0
def test_replace_param_null():
    param = replace_param('[NULL]')
    assert param is None
Beispiel #9
0
def test_replace_param_false():
    param = replace_param('[FALSE]')
    assert param is False
Beispiel #10
0
def test_replace_param_float_array_with_length():
    param = replace_param('[FLOAT_ARRAY_WITH_LENGTH_4]')
    assert param == '[FLOAT_ARRAY_WITH_LENGTH_4]'
Beispiel #11
0
def test_replace_param_incomplete_integer_with_length():
    param = replace_param('[INTEGER_WITH_LENGTH_4')
    assert param == '[INTEGER_WITH_LENGTH_4'
Beispiel #12
0
def test_replace_param_dict():
    param = replace_param("[DICT:{'a':'test1','b':'test2','c':'test3'}]")
    assert type(param) == dict
    assert param == {'a': 'test1', 'b': 'test2', 'c': 'test3'}
Beispiel #13
0
def test_replace_param_upper():
    param = replace_param('[UPPER:test]')
    assert param == 'TEST'
    param = replace_param('[UPPER:TeSt]')
    assert param == 'TEST'
Beispiel #14
0
def test_replace_param_no_string():
    param = replace_param(1234)
    assert param == 1234
Beispiel #15
0
def test_replace_param_list_strings():
    param = replace_param("[LIST:['1','2','3']]")
    assert type(param) == list
    assert param == ['1', '2', '3']
Beispiel #16
0
def test_replace_param_list_integers():
    param = replace_param('[LIST:[1,2,3]]')
    assert type(param) == list
    assert param == [1, 2, 3]
Beispiel #17
0
def test_replace_param_float():
    param = replace_param('[FLOAT:28]')
    assert type(param) == float
    assert param == 28.0
Beispiel #18
0
def test_replace_param_int():
    param = replace_param('[INT:28]')
    assert type(param) == int
    assert param == 28
Beispiel #19
0
def test_replace_param_integer_with_length():
    param = replace_param('[INTEGER_WITH_LENGTH_4]')
    assert param == 1111
Beispiel #20
0
def test_replace_param_lower():
    param = replace_param('[LOWER:TEST]')
    assert param == 'test'
    param = replace_param('[LOWER:TeSt]')
    assert param == 'test'
Beispiel #21
0
def test_replace_param_integer_array_with_length():
    param = replace_param('[INTEGER_ARRAY_WITH_LENGTH_4]')
    assert param == [1, 1, 1, 1]
Beispiel #22
0
def test_replace_param_now_offset():
    param = replace_param('[NOW + 5 MINUTES]', language='es')
    assert param == datetime.datetime.strftime(
        datetime.datetime.utcnow() + datetime.timedelta(minutes=5),
        '%d/%m/%Y %H:%M:%S')
Beispiel #23
0
def test_replace_param_json_with_length():
    param = replace_param('[JSON_WITH_LENGTH_3]')
    assert param == {'0': '0', '1': '1', '2': '2'}
Beispiel #24
0
def test_replace_param_now_not_spanish():
    param = replace_param('[NOW]', language='it')
    assert param == datetime.datetime.utcnow().strftime('%Y/%m/%d %H:%M:%S')
Beispiel #25
0
def test_replace_param_missing_param():
    param = replace_param('[MISSING_PARAM]')
    assert param is None
Beispiel #26
0
def test_replace_param_no_pattern():
    param = replace_param('my param')
    assert param == 'my param'
Beispiel #27
0
def test_replace_param_true():
    param = replace_param('[TRUE]')
    assert param is True
Beispiel #28
0
def test_replace_param_incomplete_pattern():
    param = replace_param('[INTEGER_WITH_LENGTH_4')
    assert param == '[INTEGER_WITH_LENGTH_4'
Beispiel #29
0
def test_replace_param_empty():
    param = replace_param('[EMPTY]')
    assert param == ''
Beispiel #30
0
def test_replace_param_str_int():
    param = replace_param('[STR:28]')
    assert type(param) == str
    assert param == '28'