def test_print_name():
    name = 'test'
    data = {'name': name}
    req = Mock(get_json=Mock(return_value=data), args=data)

    # Call tested function
    assert main.hello_http(req) == 'Hello {}!'.format(name)
def test_print_name():
    name = 'test'
    data = {'name': name}
    req = Mock(get_json=Mock(return_value=data), args=data)

    # Call tested function
    assert main.hello_http(req) == 'Hello {}!'.format(name)
Example #3
0
def test_hello_http_xss(app):
    with app.test_request_context(json={'name': '<script>alert(1)</script>'}):
        res = main.hello_http(flask.request)
        assert '<script>' not in res
Example #4
0
def test_hello_http_empty_json(app):
    with app.test_request_context(json=''):
        res = main.hello_http(flask.request)
        assert 'Hello World!' in res
Example #5
0
def test_hello_http_args(app):
    with app.test_request_context(json={'name': 'test'}):
        res = main.hello_http(flask.request)
        assert 'Hello test!' in res
Example #6
0
def test_hello_http_get(app):
    with app.test_request_context(query_string={'name': 'test'}):
        res = main.hello_http(flask.request)
        assert 'Hello test!' in res
Example #7
0
def test_hello_http_no_args(app):
    with app.test_request_context():
        res = main.hello_http(flask.request)
        assert 'Hello World!' in res
Example #8
0
def test_print_name():
    name = 'test'
    data={'message':name}
    req=Mock(get_json=Mock(return_value=data), args=data)

    assert main.hello_http(req) == 'Greetings from Linux Academy, {}!'.format(name)
Example #9
0
def test_print_hello_world():
    data={}
    req=Mock(get_json=Mock(return_value=data),args=data)

    #Call tested function
    assert main.hello_http(req) =='Greetings from Linux Academy, everyone!'
def test_print_hello_world():
    data = {}
    req = Mock(get_json=Mock(return_value=data), args=data)

    # Call tested function
    assert main.hello_http(req) == 'Hello World!'
Example #11
0
def test_print_hello_world():
    req = Mock(get_json=Mock(return_value={}))

    # Call tested function
    assert main.hello_http(req) == 'Hello, World!'
def test_print_hello_world():
    data = {}
    req = Mock(get_json=Mock(return_value=data), args=data)

    # Call tested function
    assert main.hello_http(req) == 'Hello World!'
    def test_print_name(self):
        name = 'test'
        req = Mock(get_json=Mock(return_value={'name': name}))

        # Call tested function
        assert main.hello_http(req) == 'Hello, {}!'.format(name)
Example #14
0
    that loads the json from the json file.
    Its object is passed to the hello_http in main.py.
    """
    args = None
    json_obj = ''
    def get_json(param, **kwargs):
        """
        Returns:
            The json object of the str in obj.json
        """
        silent = kwargs.get('silent', None)
        json_file = open("data/obj.json", "r")
        json_obj = json.loads(json_file.readline())
        return json_obj

obj = RequestClass()

result = hello_http(obj)

result = json.loads(result)

result_table = result['outputTable']
suggestions = result['suggestions']

column_names = result_table.pop(0)

result_table = pandas.DataFrame(result_table, columns=column_names)

print(result_table)
print(suggestions)