def test_searchByorganization_wrong_column(self): conn = database.create_data_base( ["users.json", "organizations.json", "tickets.json"]) result_1, result_2, result_3 = search_engine.search_by_organization( conn, 'wrong column', '34') self.assertIsNotNone(conn) self.assertEqual(len(result_1), 0) self.assertEqual(len(result_2), 0) self.assertEqual(len(result_3), 0) conn.close()
def test_searchByOrganization_tags(self): conn = database.create_data_base( ["users.json", "organizations.json", "tickets.json"]) result_1, result_2, result_3 = search_engine.search_by_organization( conn, 'tags', ["Nolan", "Rivas", "Morse", "Conway"]) self.assertIsNotNone(conn) self.assertEqual(result_1[0]['_id'], '106') self.assertEqual(result_1[0]['name'], 'Qualitern') self.assertEqual(result_1[0]['external_id'], '2355f080-b37c-44f3-977e-53c341fde146') self.assertEqual(result_2[0][1], 'A Nuisance in Greece') self.assertEqual(result_3[0][1], 'Cross Barlow') conn.close()
def test_searchByOrganization_created_at(self): conn = database.create_data_base( ["users.json", "organizations.json", "tickets.json"]) result_1, result_2, result_3 = search_engine.search_by_organization( conn, 'created_at', '2016-07-23T09:48:02 -10:00') self.assertIsNotNone(conn) self.assertEqual(result_1[0]['_id'], '106') self.assertEqual(result_1[0]['name'], 'Qualitern') self.assertEqual(result_1[0]['external_id'], '2355f080-b37c-44f3-977e-53c341fde146') self.assertEqual(result_2[0][1], 'A Nuisance in Greece') self.assertEqual(result_3[0][1], 'Cross Barlow') conn.close()
def test_searchByOrganization_url(self): conn = database.create_data_base( ["users.json", "organizations.json", "tickets.json"]) result_1, result_2, result_3 = search_engine.search_by_organization( conn, 'url', 'http://initech.zendesk.com/api/v2' '/organizations/106.json') self.assertIsNotNone(conn) self.assertEqual(result_1[0]['_id'], '106') self.assertEqual(result_1[0]['name'], 'Qualitern') self.assertEqual(result_1[0]['external_id'], '2355f080-b37c-44f3-977e-53c341fde146') self.assertEqual(result_2[0][1], 'A Nuisance in Greece') self.assertEqual(result_3[0][1], 'Cross Barlow') conn.close()
def test_searchByOrganization_shared_tickets(self): conn = database.create_data_base( ["users.json", "organizations.json", "tickets.json"]) result_1, result_2, result_3 = search_engine.search_by_organization( conn, 'shared_tickets', False) self.assertIsNotNone(conn) self.assertEqual(result_1[0]['_id'], '101') self.assertEqual(result_1[0]['name'], 'Enthaze') self.assertEqual(result_1[0]['external_id'], '9270ed79-35eb-4a38-a46f-35725197ea8d') self.assertEqual(result_1[-1]['_id'], '125') self.assertEqual(result_1[-1]['name'], 'Strezzö') self.assertEqual(result_1[-1]['external_id'], '42a1a845-70cf-40ed-a762-acb27fd606cc') conn.close()
def test_searchByOrganization_details(self): conn = database.create_data_base( ["users.json", "organizations.json", "tickets.json"]) result_1, result_2, result_3 = search_engine.search_by_organization( conn, 'details', 'Artisân') self.assertIsNotNone(conn) self.assertEqual(result_1[0]['_id'], '106') self.assertEqual(result_1[0]['name'], 'Qualitern') self.assertEqual(result_1[0]['external_id'], '2355f080-b37c-44f3-977e-53c341fde146') self.assertEqual(result_1[-1]['_id'], '114') self.assertEqual(result_1[-1]['name'], 'Isotronic') self.assertEqual(result_1[-1]['external_id'], '49c97d6a-f1ec-422e-aabe-8a429e81e656') conn.close()
def run_application(): # Messages welcome = '\n\nWelcome to Zendesk Search' information_text_1 = 'Type "quit" to exit at any time, Press "Enter" to continue\n' information_text_2 = '\t\tSelect search options:\n\t\t* Press 1 to search\n\t\t* Press 2 to view a list of ' \ 'searchable field\n\t\t* Type "quit" to exit\n ' information_text_3 = '\t\tSelect table:\n\t\t* Select 1 users\n\t\t* Select 2 organizations\n\t\t* Select 3 ' \ 'tickets\n ' # Data base initialization json_files = ["users.json", "organizations.json", "tickets.json"] connection = create_data_base(json_files) # Start our application print(f'{welcome}') command = input(information_text_1) # Exit any time while not command == 'quit': # Client press "Enter" if command == '': # Exit any time while not command == 'quit': # Display options command = input(information_text_2) # Selected Search option if command == '1': # Exit any time while not command == 'quit': # Display table options command = input(information_text_3) # Selected users table if command == '1': # Enter search column search_attr = input('Enter search term\n') # Enter search value search_value = input('Enter search value\n') # Searching search_by_user(connection, search_attr, search_value) # Selected organizations table elif command == '2': # Enter search column search_attr = input('Enter search term\n') # Enter search value search_value = input('Enter search value\n') # Searching search_by_organization(connection, search_attr, search_value) # Selected tickets table elif command == '3': # Enter search column search_attr = input('Enter search term\n') # Enter search value search_value = input('Enter search value\n') # Searching search_by_tickets(connection, search_attr, search_value) # Selected Searchable field list option elif command == '2': searchable_fields(connection) else: command = input(information_text_1) # Close connection and free up the memory connection.close() print('Good Bye')