Esempio n. 1
0
def assign_handler(query, category):
	"""assign_handler(query, category) -- assign the user's query to a 
	particular category, and call the appropriate handler.
	"""
	if(category == 'count lines'):
		handler.lines(query)
	elif(category == 'count words'):
		handler.words(query)
	elif(category == 'weather'):
		web.weather(query)
	elif(category == 'no match'):
		web.generic(query)
	elif(category == 'file info'):
		handler.file_info(query)
	elif(category == 'executable'):
		handler.make_executable(query)
	elif(category == 'search'):
		handler.search(query)
	elif(category == 'path'):
		handler.add_to_path(query)
	elif(category == 'uname'):
		handler.system_info(query)
	else:
		print 'I\'m not able to understand your query'
Esempio n. 2
0
def test_failures_success(test_file: dict) -> None:
    """Integration tests for unsuccessful smart search functionality.

    Notes:
        - Mocks lambda context with None (null)
        - Uses a sample event with all the fluff from API Gateway

    Args:
        test_file (dict): Sample payloads that should not
    """
    with open(
            os.path.join(
                Path(__file__).parent, "test_handler_payloads", "failures",
                test_file)) as f:
        test_event = json.load(f)

    test_result = handler.search(test_event, None)
    assert isinstance(test_result, dict)
    assert test_result["statusCode"] == 500
    assert "error" in test_result
Esempio n. 3
0
def search():
    return handler.search()
Esempio n. 4
0
from __future__ import print_function

import pprint

import handler

for hit in handler.search("character", {"name": "Khal Drogo"}):
    pprint.pprint(hit)
Esempio n. 5
0
def search():
    return handler.search()