예제 #1
0
def search(search_type, term, value):
    data = search_data(search_type, term, value)
    map_search_type = {
        SearchType.USER.value: 'users',
        SearchType.ORGANIZATION.value: 'organizations',
        SearchType.TICKET.value: 'tickets'
    }
    click.echo('Searching %s for "%s" with a value of "%s"\n' %
               (map_search_type.get(search_type), term, value))
    for item in data:
        click.echo(item)
    if not data:
        click.echo('No results found')
 def test_search_organizations_tags(self):
     result = search_data(SearchType.ORGANIZATION.value,
                          'tags',
                          '["Erickson", "Mccoy", "Wiggins", "Brooks"]',
                          pretty_print=False)
     self.assertEqual(len(result), 1)
 def test_search_organizations_string(self):
     result = search_data(SearchType.ORGANIZATION.value,
                          'name',
                          "Qualitern",
                          pretty_print=False)
     self.assertEqual(len(result), 1)
 def test_search_organizations_boolean(self):
     result = search_data(SearchType.ORGANIZATION.value,
                          'shared_tickets',
                          False,
                          pretty_print=False)
     self.assertEqual(len(result), 2)
 def test_search_organizations_not_found(self):
     result = search_data(SearchType.ORGANIZATION.value, '_id', 1000)
     self.assertEqual(len(result), 0)
 def test_search_organizations_exist(self):
     result = search_data(SearchType.ORGANIZATION.value, '_id', 106)
     self.assertEqual(len(result), 1)
예제 #7
0
 def test_search_tickets_empty_string(self):
     result = search_data(SearchType.TICKET.value, 'description', "")
     self.assertEqual(len(result), 1)
예제 #8
0
 def test_search_users_not_found(self):
     result = search_data(SearchType.USER.value, '_id', 2000)
     self.assertEqual(len(result), 0)
예제 #9
0
 def test_search_tickets_boolean(self):
     result = search_data(SearchType.TICKET.value, 'has_incidents', True)
     self.assertEqual(len(result), 1)
예제 #10
0
 def test_search_tickets_not_found(self):
     result = search_data(SearchType.TICKET.value, '_id', "abc")
     self.assertEqual(len(result), 0)
예제 #11
0
 def test_search_tickets_exist(self):
     result = search_data(SearchType.TICKET.value, '_id',
                          "fc5a8a70-3814-4b17-a6e9-583936fca909")
     self.assertEqual(len(result), 1)
예제 #12
0
 def test_search_users_empty_string(self):
     result = search_data(SearchType.USER.value, 'alias', "")
     self.assertEqual(len(result), 1)
예제 #13
0
 def test_search_users_string(self):
     result = search_data(SearchType.USER.value, 'locale', "en-AU")
     self.assertEqual(len(result), 1)
예제 #14
0
 def test_search_users_boolean(self):
     result = search_data(SearchType.USER.value, 'suspended', False)
     self.assertEqual(len(result), 3)
 def test_search_organizations_empty_string(self):
     result = search_data(SearchType.ORGANIZATION.value,
                          'details',
                          '',
                          pretty_print=False)
     self.assertEqual(len(result), 1)
예제 #16
0
 def test_search_tickets_string(self):
     result = search_data(SearchType.TICKET.value, 'type', "problem")
     self.assertEqual(len(result), 1)
예제 #17
0
 def test_search_users_exist(self):
     result = search_data(SearchType.USER.value, '_id', 75)
     self.assertEqual(len(result), 0)