def testB():
    """
    Test procedure for Part B
    """
    introcs.assert_equals('B C', a1.first_inside_quotes('A "B C" D'))
    introcs.assert_equals('A', a1.first_inside_quotes('"A" "B" C "D"'))
    introcs.assert_equals(' ', a1.first_inside_quotes('" "'))
Exemple #2
0
def testB():
    """
    Test functions get_src(), get_dst()
    """

    #testing one occurrence of double quotes
    btest1 = a1.first_inside_quotes('A "BD" D')
    introcs.assert_equals("BD", btest1)

    #testing multiple occurrence of double quotes
    btest2 = a1.first_inside_quotes('A b "cde" fg "hi" jk ')
    introcs.assert_equals("cde", btest2)

    #testing nothing in the double quote
    btest3 = a1.first_inside_quotes('""')
    introcs.assert_equals("", btest3)

    #testing a string with only double quotes
    btest4 = a1.first_inside_quotes('"ab"')
    introcs.assert_equals("ab", btest4)

    #testing a valid input
    btest5 = a1.get_lhs('{ "ok":true, "lhs":"1 Bitcoin", "rhs":"9916.0137 ' +
                        'Euros","err":"" }')
    introcs.assert_equals('1 Bitcoin', btest5)

    #testing an invalid input
    btest7 = a1.get_lhs('{ "ok":false, "lhs":"", "rhs":"", "err":"Source ' +
                        'currency code is invalid." }')
    introcs.assert_equals('', btest7)

    #testing an invalid input
    btest8 = a1.get_rhs('{ "ok":false, "lhs":"", "rhs":"", "err":"Source ' +
                        'currency code is invalid." }')
    introcs.assert_equals('', btest8)

    #testing a valid input
    btest9 = a1.get_rhs('{ "ok":true, "lhs":"1 Bitcoin", "rhs":"9916.0137 ' +
                        'Euros","err":"" }')
    introcs.assert_equals('9916.0137 Euros', btest9)

    #testing an invalid query
    btest10 = a1.has_error('{ "ok":false, "lhs":"", "rhs":"", "err":"" }')
    introcs.assert_equals(True, btest10)

    #testing a valid query
    btest11 = a1.has_error(
        '{ "ok":true, "lhs":"1 Bitcoin", "rhs":"9916.0137 ' +
        'Euros", "err":"" }')
    introcs.assert_equals(False, btest11)

    #testing an invalid currency
    btest11 = a1.has_error('{ "ok":false, "lhs":"", "rhs":"", ' +
                           '"err":"Exchange currency code is invalid." }')
    introcs.assert_equals(True, btest11)
Exemple #3
0
def testB():
    "test procedure for part B"

    #Test for first_inside_quotes
    cornell.assert_equals('C', a1.first_inside_quotes('A   B   "C"    D'))
    cornell.assert_equals('D   E   F',
                          a1.first_inside_quotes('A    B    C    "D   E   F"'))
    cornell.assert_equals('   ', a1.first_inside_quotes('ABC "   " DEF'))

    #Test for get_lhs
    cornell.assert_equals(
        '2 United States Dollars',
        a1.get_lhs(
            '{"success":true, "lhs":"2 United States Dollars", "rhs":"1.825936 Euros", "error":""}'
        ))
    cornell.assert_equals(
        '2.5 United States Dollars',
        a1.get_lhs(
            '{ "success" : true, "lhs" : "2.5 United States Dollars", "rhs" : "2.0952375 Euros", "error" : "" }'
        ))
    cornell.assert_equals(
        '30000 United States Dollars',
        a1.get_lhs(
            '{ "success" : true, "lhs" : "30000 United States Dollars", "rhs" : "6.5237409 Bitcoins", "error" : "" }'
        ))

    #Test for get_rhs
    cornell.assert_equals(
        '112518 Saudi Riyals',
        a1.get_rhs(
            '{ "success" : true, "lhs" : "30000 United States Dollars", "rhs" : "112518 Saudi Riyals", "error" : "" }'
        ))
    cornell.assert_equals(
        '2384.8473112096 Saudi Riyals',
        a1.get_rhs(
            '{ "success" : true, "lhs" : "30000 Dominican Pesos", "rhs" : "2384.8473112096 Saudi Riyals", "error" : "" }'
        ))
    cornell.assert_equals(
        '4975.8459973372 Hong Kong Dollars',
        a1.get_rhs(
            '{ "success" : true, "lhs" : "30000 Dominican Pesos", "rhs" : "4975.8459973372 Hong Kong Dollars", "error" : "" }'
        ))

    #Test for has_error
    cornell.assert_equals(
        True,
        a1.has_error(
            '{"success":false, "lhs":"", "rhs":"", "error":"Source currency code is invalid."}'
        ))
    cornell.assert_equals(
        False,
        a1.has_error(
            '{"success":true, "lhs":"2 United States Dollars", "rhs":"1.825936 Euros", "error":""}'
        ))
Exemple #4
0
def testB():
    """Test procedure for functions first_inside_quotes, get_lhs(json), get_rhs(json), and has_error(json)"""
    #Test case for general string with only one set of double quotes
    result9 = a1.first_inside_quotes('A "B C" D')
    cornell.assert_equals = ('B C', result9)
    
    #Test case for nothing inside the double quotes
    result10 = a1.first_inside_quotes('A "" C')
    cornell.assert_equals = ('', result10)
    
    #Test case for two sets of double quotes in the string
    result11 = a1.first_inside_quotes('A "B" "C" D')
    cornell.assert_equals = ('B', result11)
    
    #Test case for whole string inside double quotes
    result34 = a1.first_inside_quotes('"B"')
    cornell.assert_equals = ('B', result34)
    
    #Test case for given a general lhs currency query
    result12 = a1.get_lhs('{"success" : true, "lhs" : "2 United States Dollars", "rhs" : "1.825936 Euros", "error":""}')
    cornell.assert_equals = ('2 United States Dollars', result12)
    
    #Test Case for an invalid lhs currency query
    result13 = a1.get_lhs('{"success" : false, "lhs" : "2 AAA", "rhs" : "3 BBB", "error" : "Currency amount is invalid." }')
    cornell.assert_equals = ('', result13)
    
    #Test case for given a general rhs currency query
    result14 = a1.get_rhs('{"success" : true, "lhs" : "2 United States Dollars", "rhs" : "1.825936 Euros", "error":""}')
    cornell.assert_equals = ('1.825936 Euros', result14)
    
    #Test Case for an invalid rhs currency query
    result15 = a1.get_rhs('{"success" : false, "lhs" : "2 AAA", "rhs" : "3 BBB", "error" : "Currency amount is invalid." }')
    cornell.assert_equals = ('', result15)
    
    #Test case for a valid currency query
    result16 = a1.has_error('{"success" : true, "lhs" : "2 United States Dollars", "rhs" : "1.825936 Euros", "error":""}')
    cornell.assert_equals = (False, result16)
    
    #Test case for an invalid currency query
    result17 = a1.has_error('{"success" : false, "lhs" : "", "rhs" : "", "error":"Source currency code is invalid."}')
    cornell.assert_equals = (True, result17)
Exemple #5
0
def testA():
    """Test procedure for Part A"""
    result = a1.before_space('0.12345 Bitcoins')
    cornell.assert_equals('0.12345', result)
    result = a1.before_space('1799.3186929883  Lebanese Pounds')
    cornell.assert_equals('1799.3186929883', result)
    result = a1.before_space('7.725799   Solomon Islands Dollars')
    cornell.assert_equals('7.725799', result)
    result = a1.before_space('1 United States Dollar')
    cornell.assert_equals('1', result)
    result = a1.before_space(' 1 United States Dollar')
    cornell.assert_equals('', result)

    result = a1.after_space('0.12345 Bitcoins')
    cornell.assert_equals('Bitcoins', result)
    result = a1.after_space('1799.3186929883 Lebanese Pounds')
    cornell.assert_equals('Lebanese Pounds', result)
    result = a1.after_space('7.725799 Solomon Islands Dollars')
    cornell.assert_equals('Solomon Islands Dollars', result)
    result = a1.after_space('73.8118685829172 Papua New Guinean Kina')
    cornell.assert_equals('Papua New Guinean Kina', result)
    result = a1.after_space('8.0307256337289 Trinidad and Tobago Dollars')
    cornell.assert_equals('Trinidad and Tobago Dollars', result)
    result = a1.after_space('124 Euros ')
    cornell.assert_equals('Euros ', result)
    result = a1.after_space(' 34.5827 Namibian Dollars')
    cornell.assert_equals('34.5827 Namibian Dollars', result)
    result = a1.after_space('17.8686  Mexican Pesos')
    cornell.assert_equals(' Mexican Pesos', result)

    #Test for first_inside_quotes
    result = a1.first_inside_quotes('ab"cd"ef')
    cornell.assert_equals('cd', result)
    result = a1.first_inside_quotes('""')
    cornell.assert_equals('', result)
    result = a1.first_inside_quotes('"This is assignment 1"')
    cornell.assert_equals('This is assignment 1', result)
    result = a1.first_inside_quotes('ab"cd"ef"gh"')
    cornell.assert_equals('cd', result)
Exemple #6
0
def testB():
    """Test procedure for first_inside_quotes(s). Will extract substrings."""
    #Test case 1
    result = a1.first_inside_quotes('Johnny"apple"seed')
    cornelltest.assert_equals('apple', result)
    #Test case 2
    result = a1.first_inside_quotes('Harvard" sucks "poo')
    cornelltest.assert_equals(' sucks ', result)
    #Test case 2
    result = a1.first_inside_quotes('Harvard"  "poo')
    cornelltest.assert_equals('  ', result)
    #Test case 2
    result = a1.first_inside_quotes('Harvard""poo')
    cornelltest.assert_equals('', result)
    result = a1.first_inside_quotes('Jeffrey, "Don\'t panic!" about assign. 1')
    cornelltest.assert_equals('Don\'t panic!', result)
    result = a1.first_inside_quotes(
        'Jeffrey, "Don\'t panic!" you will "be" ok')
    cornelltest.assert_equals('Don\'t panic!', result)
    """Test procedure for get_from(json)."""
    #Test case 1a
    result = a1.get_from(
        '"from" : "2.5 United States Dollars",' +
        '"to" : "2.24075 Euros", "success" : true, "error" : ""')
    cornelltest.assert_equals('2.5 United States Dollars', result)
    result = a1.get_from('{"from":"2 United States Dollars",' +
                         '"to":"1.825936 Euros","success":true,"error":""}')
    cornelltest.assert_equals('2 United States Dollars', result)
    result = a1.get_from(
        '{ "from" : "", "to" : "", "success" : false, "error"' +
        ' : "Exchange currency code is invalid." }')
    cornelltest.assert_equals('', result)

    #Test case 2b
    result = a1.get_to('"from" : "2 United States Dollars","to"' +
                       ' : "1.825936 Euros","success":true,"error":""')
    cornelltest.assert_equals('1.825936 Euros', result)
    result = a1.get_to('{ "from" : "", "to" : "", "success" : false, "error"' +
                       ' : "Exchange currency code is invalid." }')
    cornelltest.assert_equals('', result)

    #Test case 1c
    result = a1.has_error('"from" : "2 United States Dollars","to"' +
                          ' : "1.825936 Euros","success":true,"error":""')
    cornelltest.assert_equals(False, result)
    #Test case 2c
    result = a1.has_error(
        '"from" : "", "to" : "", "success"' +
        ' : false, "error" : "Source currency code is invalid."')
    cornelltest.assert_equals(True, result)
Exemple #7
0
def testB():
    """
    Test procedure for Part B
    """
    print("Testing function first_inside_quotes(s)")
    s = 'A "B C" D'
    answer = a1.first_inside_quotes(s)
    introcs.assert_equals('B C', answer)
    e = 'hello" " hi'
    result = a1.first_inside_quotes(e)
    introcs.assert_equals(" ", result)
    c = '"1"'
    result = a1.first_inside_quotes(c)
    introcs.assert_equals("1", result)
    t = '"hello" my "name is"'
    final = a1.first_inside_quotes(t)
    introcs.assert_equals("hello", final)
    e = '"" hi'
    result = a1.first_inside_quotes(e)
    introcs.assert_equals("", result)
    print('The module is working correctly')

    print("Testing function get_src(json)")
    s = '{ "src" : "     2 United States Dollars     ",\
     "dst" : "1.727138 Euros", "valid" : true, "error" : "" }'

    final = a1.get_src(s)
    introcs.assert_equals('     2 United States Dollars     ', final)
    s = '{ "src" : "2 United States Dollars     ",\
     "dst" : "1.727138 Euros", "valid" : true, "error" : "" }'

    final = a1.get_src(s)
    introcs.assert_equals('2 United States Dollars     ', final)
    s = '{ "src" : "     2 United States Dollars",\
     "dst" : "1.727138 Euros", "valid" : true, "error" : "" }'

    final = a1.get_src(s)
    introcs.assert_equals('     2 United States Dollars', final)
    s = '{ "src" : "2 United States Dollars",\
     "dst" : "1.727138 Euros", "valid" : true, "error" : "" }'

    final = a1.get_src(s)
    introcs.assert_equals('2 United States Dollars', final)
    s = '{ "src" : "",\
     "dst" : "1.727138 Euros", "valid" : true, "error" : "" }'

    final = a1.get_src(s)
    introcs.assert_equals("", final)
    q = '{ "src" : "", "dst" : "", "valid" : false, "error" :\
     "Exchange currency code is invalid." }'

    end = a1.get_src(q)
    introcs.assert_equals("", end)
    print('The module is working correctly')

    print("Testing function dst_src(json)")
    s = '{ "src" : "2 United States Dollars", "dst" :\
     "     1.727138 Euros      ", "valid" : true, "error" : "" }'

    end = a1.get_dst(s)
    introcs.assert_equals('     1.727138 Euros      ', end)
    s = '{ "src" : "2 United States Dollars", "dst" :\
     "1.727138 Euros      ", "valid" : true, "error" : "" }'

    end = a1.get_dst(s)
    introcs.assert_equals('1.727138 Euros      ', end)
    s = '{ "src" : "2 United States Dollars", "dst" :\
     "     1.727138 Euros", "valid" : true, "error" : "" }'

    end = a1.get_dst(s)
    introcs.assert_equals('     1.727138 Euros', end)
    s = '{ "src" : "2 United States Dollars", "dst" :\
     "1.727138 Euros", "valid" : true, "error" : "" }'

    end = a1.get_dst(s)
    introcs.assert_equals('1.727138 Euros', end)
    s = '{ "src" : "2 United States Dollars",\
     "dst" : "", "valid" : true, "error" : "" }'

    final = a1.get_dst(s)
    introcs.assert_equals("", final)
    s = '{ "src" : "", "dst" : "", "valid" : false, "error"\
     : "Source currency code is invalid." }'

    stop = a1.get_dst(s)
    introcs.assert_equals("", stop)
    print('The module is working correctly')

    print('Testing has_error(json)')
    t = '{ "src" : "<old-amt>", "dst" : "<new-amt>", "valid" : true,\
    "error" : "" }'

    final = a1.has_error(t)
    introcs.assert_equals(False, final)
    q = '{ "src" : "", "dst" : "", "valid" : false, "error" :\
     "Exchange currency code is invalid." }'

    end = a1.has_error(q)
    introcs.assert_equals(True, end)
    l = '{ "src" : "", "dst" : "", "valid" : false, "error" :\
     "Currency amount is invalid." }'

    done = a1.has_error(l)
    introcs.assert_equals(True, done)
    s = '{ "src" : "", "dst" : "", "valid" : false, "error"\
     : "Source currency code is invalid." }'

    stop = a1.has_error(s)
    introcs.assert_equals(True, stop)
    print('The module is working correctly')
Exemple #8
0
def testB():
    """
    Test procedure for Part B
    """
    #test procedures for a1.first_inside_quotes: the function a1.first_inside_quotes
    #returns the first substring of s between two double quote characters.
    #For example, if s is 'A "B C" D', the function first_inside_quotes returns 'B C'.
    #If s is '"A" "B" C "D"', the function first_inside_quotes returns 'A'.
    #If s is " ", the function first_inside_quotes returns ' '.
    introcs.assert_equals('B C', a1.first_inside_quotes('A "B C" D'))

    #Test multiple ""
    introcs.assert_equals('A', a1.first_inside_quotes('"A" "B" C "D"'))

    #Test empty space
    introcs.assert_equals(' ', a1.first_inside_quotes('" "'))

    #test procedure for a1.get_lhs: a1.get_src returns the string inside double quotes immediately following the keyword "lhs". If JSON is '{ "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros",  "err" : "" }', the function a1.get_lhs returns '2 United States Dollars' (not '"2 United States Dollars"').
    introcs.assert_equals(
        '2 United States Dollars',
        a1.get_lhs(
            '{ "ok": true, "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros", "err" : "" }'
        ))

    #test procedure for a1.get_rhs: a1.get_rhs returns the string inside double quotes immediately following the keyword "rhs". If JSON is '{ "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros",  "err" : "" }', the function returns '2 United States Dollars' (not '"2 United States Dollars"').
    introcs.assert_equals(
        '1.727138 Euros',
        a1.get_rhs(
            '{ "ok": true, "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros",  "err" : "" }'
        ))

    #test procedure for a1.has_error: a1.get_src returns True if the query has an error. Since the query is not valid, the function returns True (it does NOT return "Source currency code is invalid").
    introcs.assert_equals(
        True,
        a1.has_error(
            '{ "ok": true, "lhs" : "", "rhs" : "", "err" : "Source currency code is invalid." }'
        ))

    #test procedure for a1.get_lhs: a1.get_src returns the string inside double quotes immediately following the keyword "lhs". If JSON is '{ "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros",  "err" : "" }', the function returns "2 United States Dollars".
    introcs.assert_equals(
        "2 United States Dollars",
        a1.get_lhs(
            '{ "ok": true, "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros", "err" : "" }'
        ))

    #test procedure for a1.get_lhs: a1.get_src returns the string inside double quotes immediately following the keyword "lhs". If JSON is '{ "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros",  "err" : "" }', the function a1.get_lhs returns "2 United States Dollars".
    introcs.assert_equals(
        "1.727138 Euros",
        a1.get_rhs(
            '{ "ok": true, "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros",  "err" : "" }'
        ))

    #test procedure for a1.has_error: a1.has_error returns False since the query does not have an error and is thus "valid".
    introcs.assert_equals(
        False,
        a1.has_error(
            '{"ok": true, "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros", "err" : "" }'
        ))

    #test procedure for a1.has_error: a1.has_error returns True since the query has an error. The function does NOT return "Source currency code is invalid".
    introcs.assert_equals(
        True,
        a1.has_error(
            '{"ok": true, "lhs" : "", "rhs" : "", "err" : "Source currency code is invalid." }'
        ))

    #test procedure for a1.get_lhs: a1.get_lhs returns the string inside double quotes immediately following the keyword "lhs". If JSON is '{ "ok":true, "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros", "err" : "" }', the function a1.get_lhs returns '2 United States Dollars'.
    introcs.assert_equals(
        '2 United States Dollars',
        a1.get_lhs(
            '{ "ok":true, "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros", "err" : "" }'
        ))

    #test procedure for a1.get_rhs: a1.get_rhs returns the string inside double quotes immediately following the keyword "rhs". If JSON is '{ "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros",  "err" : "" }', the function a1.get_rhs returns '1.727138 Euros'.
    introcs.assert_equals(
        '1.727138 Euros',
        a1.get_rhs(
            '{"ok": true, "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros",  "err" : "" }'
        ))

    #test procedure for a1.has_error: a1.has_error returns True if the query has an error. If JSON is '{ "lhs" : "", "rhs" : "", , "err" : "Source currency code is invalid." }' the function a1.has_error returns True, since the query has an error (it does NOT return "Source currency code is invalid").
    introcs.assert_equals(
        True,
        a1.has_error(
            '{"ok": true, "lhs" : "", "rhs" : "", "err" : "Source currency code is invalid." }'
        ))

    #test procedure for a1.get_lhs: a1.get_lhs returns the string inside double quotes immediately following "lhs". If JSON is '{ "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros",  "err" : "" }' the function a1.get_lhs returns "2 United States Dollars".
    introcs.assert_equals(
        "2 United States Dollars",
        a1.get_lhs(
            '{"ok": true, "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros",  "err" : "" }'
        ))

    #test procedure for a1.get_rhs: a1.get_rhs returns the string inside double quotes immediately following "rhs". If JSON is '{ "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros",  "err" : "" }', the function a1.get_rhs returns "1.727138 Euros".
    introcs.assert_equals(
        "1.727138 Euros",
        a1.get_rhs(
            '{"ok": true, "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros",  "err" : "" }'
        ))

    #test procedure for a1.has_error: a1.has_error returns False if the query is "valid". It does NOT return "valid".
    introcs.assert_equals(
        False,
        a1.has_error(
            '{"ok": true, "lhs" : "2 United States Dollars", "rhs" : "1.727138 Euros", "err" : "" }'
        ))

    #test procedure for a1.has_error: a1.has_error returns True if the query has an error. It does NOT return "Source currency code is invalid".
    introcs.assert_equals(
        True,
        a1.has_error(
            '{ "ok":false, "lhs":"", "rhs":"", "err":"Exchange currency code is invalid." }'
        ))
Exemple #9
0
def testB():
    """
    Test procedure for Part B
    """
    #testing first_inside_quotes for json
    result = a1.first_inside_quotes(
        '{ "ok":true, "lhs":"2.5 United States Dollars", '
        '"rhs":"64.375 Cuban Pesos", "err":"" }')
    introcs.assert_equals('ok', result)
    #testing first_inside_quotes for no quotes
    result = a1.first_inside_quotes('Quotes "" quotes')
    introcs.assert_equals('', result)
    #testing first_inside_quotes for two quotes
    result = a1.first_inside_quotes('two "of" these "quotes"')
    introcs.assert_equals('of', result)
    #testing first_inside_quotes for one quote in a string
    result = a1.first_inside_quotes('""')
    introcs.assert_equals('', result)
    #testing first_inside_quotes for two quotes
    result = a1.first_inside_quotes(' "" "" ')
    introcs.assert_equals('', result)
    #testing first_inside_quotes for a single quote in a double quote
    result = a1.first_inside_quotes(' " ' ' "')
    introcs.assert_equals('  ', result)
    #testing first_inside_quotes whole quote in quotes
    result = a1.first_inside_quotes('"this entire string"')
    introcs.assert_equals('this entire string', result)
    #testing get get_lhs
    result = a1.get_lhs('{ "ok":true, "lhs":"2.5 United States Dollars", '
                        '"rhs":"64.375 Cuban Pesos", "err":"" }')
    introcs.assert_equals('2.5 United States Dollars', result)
    #testing get_lhs on json with error
    result = a1.get_lhs('{ "ok":false, "lhs":"", "rhs":"", '
                        '"err":"Currency amount is invalid." }')
    introcs.assert_equals('', result)
    #testing get_lhs with longer json
    result = a1.get_lhs(
        '{ "ok":true, "lhs":"2.5 Trinidad and Tobago Dollars", '
        '"rhs":"77.304437834842 Guyanaese Dollars", "err":"" }')
    introcs.assert_equals('2.5 Trinidad and Tobago Dollars', result)
    #testing get_lhs
    result = a1.get_lhs('{ "ok":true, "lhs":"1 Bitcoin", '
                        '"rhs":"9916.0137 Euros", "err":"" }')
    introcs.assert_equals('1 Bitcoin', result)
    #testing get_rhs with regular json
    result = a1.get_rhs('{ "ok":true, "lhs":"1 Bitcoin", '
                        '"rhs":"9916.0137 Euros", "err":"" }')
    introcs.assert_equals('9916.0137 Euros', result)
    #testing get_rhs with json with an error
    result = a1.get_rhs('{ "ok":false, "lhs":"", "rhs":"", '
                        '"err":"Currency amount is invalid." }')
    introcs.assert_equals('', result)
    #testing get_rhs with longer json
    result = a1.get_rhs(
        '{ "ok":true, "lhs":"2.5 Trinidad and Tobago Dollars", '
        '"rhs":"77.304437834842 Guyanaese Dollars", "err":"" }')
    introcs.assert_equals('77.304437834842 Guyanaese Dollars', result)
    #testing has_error with an error
    result = a1.has_error('{ "ok":false, "lhs":"", "rhs":"", '
                          '"err":"Currency amount is invalid." }')
    introcs.assert_equals(True, result)
    #testing has_error without an error
    result = a1.has_error('{ "ok":true, "lhs":"1 Bitcoin", '
                          '"rhs":"9916.0137 Euros", "err":"" }')
    introcs.assert_equals(False, result)