def test_extract_msg_dict_to_status(): msg = populate_instance( { "error": True, "code": 7, "message": "Actual Error" }, StatusMsg(error=False, code=42, message="Not an error")) data = extract_values(msg) assert_true(isinstance(data, StatusMsg)) assert_true(data.error) assert_true(data.code == 7) assert_true(data.message == "Actual Error")
def test_extract_msg_tuple_to_list(): msg = populate_instance((False, 42, 3.1415, r'fortytwo', u'forty two'), list()) data = extract_values(msg) assert_true(isinstance(msg, list)) assert_true(msg == [False, 42, 3.1415, r'fortytwo', u'forty two'])
def test_extract_msg_list(): msg = populate_instance([False, 42, 3.1415, r'fortytwo', u'forty two'], list()) data = extract_values(msg) assert_true(isinstance(data, list)) assert_true(data == [False, 42, 3.1415, r'fortytwo', u'forty two'])
def test_extract_msg_tuple_to_tuple(): msg = populate_instance((False, 42, 3.1415, r'fortytwo', u'forty two'), tuple()) data = extract_values(msg) assert_true(isinstance(data, tuple)) assert_true(data == (False, 42, 3.1415, r'fortytwo', u'forty two'))
def test_extract_msg_unicode_to_unicode(): msg = populate_instance(u'forty two', unicode()) data = extract_values(msg) assert_true(isinstance(data, unicode)) assert_true(data == u'forty two')
def test_extract_msg_str_to_str(): msg = populate_instance(r'forty two', str()) data = extract_values(msg) assert_true(isinstance(data, str)) assert_true(data == r'forty two')
def test_extract_msg_float(): msg = populate_instance(3.1415, float()) data = extract_values(msg) assert_true(isinstance(data, float)) assert_true(data == 3.1415)
def test_extract_msg_int_to_float(): msg = populate_instance(42, float()) data = extract_values(msg) assert_true(isinstance(data, float)) assert_true(data == 42.0)
def test_extract_msg_bool_false(): msg = populate_instance(False, bool()) data = extract_values(msg) assert_true(isinstance(data, bool)) assert_false(data)