def test_location_includes_mutation(self):
        """ Confirm that get_filter_results with a query of location_includes 
        does not mutate the list it's given."""

        twitter_dict = {'a':{'name':'', 'location':'China', \
                             'web':'', 'bio':'', 'following':[]}, \
                        'b':{'name':'', 'location':'kansas, uSa', 'web':'', \
                             'bio':'', 'following':[]}, \
                        'c':{'name':'', 'location':'Musala, Bulgaria', \
                             'web':'', 'bio':'', 'following':[]}}
        list_of_usernames = ['a', 'b', 'c']
        filter_dict = {'location-includes': 'USA'}
        tf.get_filter_results(twitter_dict, list_of_usernames, filter_dict)

        twitter_dict_expected = {'a':{'name':'', 'location':'China', \
                             'web':'', 'bio':'', 'following':[]}, \
                        'b':{'name':'', 'location':'kansas, uSa', 'web':'', \
                             'bio':'', 'following':[]}, \
                        'c':{'name':'', 'location':'Musala, Bulgaria', \
                             'web':'', 'bio':'', 'following':[]}}
        list_of_usernames_expected = ['a', 'b', 'c']
        filter_dict_expected = {'location-includes': 'USA'}

        self.assertEqual(twitter_dict, twitter_dict_expected)
        self.assertEqual(list_of_usernames, list_of_usernames_expected)
        self.assertEqual(filter_dict, filter_dict_expected)
Beispiel #2
0
    def test_get_filter_results_mutation(self):
        """ Confirm get_filter_results does not mutate the parameters it is
        given."""

        twitterverse = {'tomCruise': {'following': ['katieH'],\
                                      'web': 'http://www.tomcruise.com', \
                                      'location': 'Los Angeles, CA', \
                                      'bio': 'Official TomCruise.com', \
                                      'name': 'Tom Cruise'}, \
                        'katieH': {'following': ['tomCruise'],\
                                   'web': 'www.tomkat.com', 'location': '',\
                                   'bio': '', 'name': 'Katie Holmes'}, \
                        'benR': {'following': ['katieH', 'tomCruise'], \
                                 'web': 'www.benr.com', 'location': '',\
                                 'bio': '', 'name': 'Ben Rudolph'}}
        usernames = ['benR', 'tomCruise']
        filter_dict = {'following': 'katieH'}

        expected = (id(twitterverse), id(usernames), id(filter_dict))

        tf.get_filter_results(twitterverse, usernames, filter_dict)

        actual = (id(twitterverse), id(usernames), id(filter_dict))

        self.assertEqual(actual, expected)
    def test_following_mutation(self):
        """ Confirm that get_filter_results with a query of following 
        does not mutate the list it's given."""

        twitter_dict = {'a':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':['b']}, \
                        'b':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':['c']}, \
                        'c':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':[]}}
        list_of_usernames = ['a', 'b', 'c']
        filter_dict = {'following': 'c'}
        tf.get_filter_results(twitter_dict, list_of_usernames, filter_dict)

        twitter_dict_expected = {'a':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':['b']}, \
                        'b':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':['c']}, \
                        'c':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':[]}}
        list_of_usernames_expected = ['a', 'b', 'c']
        filter_dict_expected = {'following': 'c'}

        self.assertEqual(twitter_dict, twitter_dict_expected)
        self.assertEqual(list_of_usernames, list_of_usernames_expected)
        self.assertEqual(filter_dict, filter_dict_expected)
    def test_get_filter_results_example_7(self):
        """Test tf.get_filter_results for users who have a location which
        includes the sub-string 'NA', a name which includes the sub-string
        'Burgundy', are following a user named 'Andrew' and are being followed
        by the user 'Chuck'"""

        data = {'Tommy': {'bio': '', 'web': '', 'location': 'Ohama, NA',
                'following': ['Ron', 'Andrew'], 'name': 'Thomas Burgundy'},
                'Ron': {'bio': '', 'web': '', 'location': 'NY, Usa NA',
                'following': ['Tommy', 'Jessica'], 'name': 'Ronald BURGUNDY'},
                'Jessica': {'bio': '', 'web': '', 'location':
                'Denver Co, (na)', 'following': ['Tommy', 'Andrew'], 'name':
                'Jessica Burgundy'}, 'Andrew': {'bio': '', 'web': '',
                'location': 'North-America', 'following': ['Jessica'],
                'name': 'Andrew Scott BurGundy'}, 'Chuck': {'bio': '',
                'web': '', 'location': 'Na Texas', 'following': ['Tommy',
                'Jessica', 'Ron'], 'name': ''}}
        list_usernames = ['Tommy', 'Chuck', 'Ron', 'Jessica', 'Andrew']
        filter_spec = {'location-includes': 'NA', 'name-includes':
                       'Burgundy', 'following': 'Andrew', 'follower':
                       'Chuck'}
        
        expected = ['Tommy', 'Jessica']
        actual = tf.get_filter_results(data, list_usernames, filter_spec)
        self.assertEqual(expected, actual, "Tommy and Jessica are the only "
                         "users who have a location which includes 'NA', "
                         "a name which includes 'Burgundy', a follower "
                         "with the username 'Chuck' and are following a "
                         "user named 'Andrew'")
Beispiel #5
0
    def test_empty_element_parameters(self):
        """ Test get_filter_results with all empty parameters \
        (twitterverse_dict, usernames, and filter_spec_dict)."""

        expected_list = []
        obtained_list = tf.get_filter_results({}, [], {})
        self.assertEqual(expected_list, obtained_list)
    def test_get_filter_results_example_2(self):
        """ Test get_filter_results with td, ['tomCruise', 'a'], {} """

        ul = ['tomCruise', 'a']
        fs = {}
        actual = tf.get_filter_results(td, ul, fs)
        expected = ['tomCruise', 'a']
        self.assertEqual(actual, expected)
    def test_get_filter_results_example_1(self):
        """ Test get_filter_results with {}, [], {} """

        td = {}
        ul = []
        fs = {}
        actual = tf.get_filter_results(td, ul, fs)
        expected = []
        self.assertEqual(actual, expected)
    def test_filter_1(self):
        """Test get_filter_results with usernames = ['Kinder', 'Ken', 'Alan', \
        'Tracy'] and filter_dict = {}
        """
        usernames = ['Kinder', 'Ken', 'Alan', 'Tracy']
        filter_dict = {}

        actual = tf.get_filter_results(twitter_dict, usernames, filter_dict)
        expected = ['Kinder', 'Ken', 'Alan', 'Tracy']
        self.assertEqual(actual, expected)
    def test_filter_6(self):
        """Test get_filter_results with usernames = ['Kinder', 'Ken', 'Alan', \
        'Tracy'] and {'location-includes': 'Spadina'}
        """

        usernames = ['Kinder', 'Ken', 'Alan', 'Tracy']
        filter_dict = {'location-includes': 'Spadina'}

        actual = tf.get_filter_results(twitter_dict, usernames, filter_dict)
        expected = ['Kinder', 'Ken', 'Alan']
        self.assertEqual(actual, expected)
    def test_filter_follower(self):
        """ Test get_filter_results with only follower filter """

        twitter_dic = {'Sheldon': {'name': 'Shuai Shao', 'location': '', \
                                   'web': '', 'bio': '', 'following': ['zoe']}}
        username_list = ['Sheldon']
        filter_dic = {'follower': 'mark'}
        expected_result = []
        result = twitterverse_functions.get_filter_results(twitter_dic, \
                                                  username_list, filter_dic)
        self.assertEqual(expected_result, result)
    def test_two_filter(self):
        """ Test get_filter_results with only two filter conditions"""

        twitter_dic = {'Sheldon': {'name': 'Shuai Shao', 'location': 'usa', \
                                   'web': '', 'bio': '', 'following': ['zoe']}}
        username_list = ['Sheldon']
        filter_dic = {'name-includes': 'Don', 'location-includes': 'US'}
        expected_result = ['Sheldon']
        result = twitterverse_functions.get_filter_results(twitter_dic, \
                                                  username_list, filter_dic)
        self.assertEqual(expected_result, result)
    def test_get_filter_results_example_6(self):
        """
        Test get_filter_results with td, ['tomCruise', 'a', 'c', 'x', 'katieH'],
        {'follower' : 'tomCruise'}
        """

        ul = ['tomCruise', 'a', 'c', 'x', 'katieH']
        fs = {'follower': 'tomCruise'}
        actual = tf.get_filter_results(td, ul, fs)
        expected = ['katieH']
        self.assertEqual(actual, expected)
    def test_get_filter_results_example_5(self):
        """
        Test get_filter_results with td, ['tomCruise', 'PerezHilton', 'a',
        'c', 'x', 'katieH'], {'name-includes' : 'a'}
        """

        ul = ['tomCruise', 'PerezHilton', 'a', 'c', 'x', 'katieH']
        fs = {'name-includes': 'a'}
        actual = tf.get_filter_results(td, ul, fs)
        expected = ['a', 'c', 'x', 'katieH']
        self.assertEqual(actual, expected)
    def test_username_list_is_empty(self):
        """ Test get_filter_results with empty username-list """

        twitter_dic = {'Sheldon': {'name': 'Shuai Shao', 'location': '', \
                                   'web': '', 'bio': '', 'following': []}}
        username_list = []
        filter_dic = {'name-includes': 'don'}
        expected_result = []
        result = twitterverse_functions.get_filter_results(twitter_dic, \
                                                  username_list, filter_dic)
        self.assertEqual(expected_result, result)
    def test_get_filter_results_location_includes(self):
        """ Test get_filter_results using the following filter in filter_dict.
        """

        data_file = open('data.txt', 'r')
        twitter_dict = tf.process_data(data_file)
        data_file.close()

        actual = tf.get_filter_results(twitter_dict, ['tomCruise', \
        'PerezHilton', 'tomfan'], {'follower': 'katieH'})
        expected = ['tomCruise', 'PerezHilton']
        self.assertEqual(actual, expected)
    def test_get_filter_results_name_includes(self):
        """ Test get_filter_results using the name_includes filter in
        filter_dict. """

        data_file = open('data.txt', 'r')
        twitter_dict = tf.process_data(data_file)
        data_file.close()

        actual = tf.get_filter_results(twitter_dict, ['tomCruise', \
        'PerezHilton'], {'name_includes': 'tomCruise'})
        expected = ['tomCruise']
        self.assertEqual(actual, expected)
    def test_name_includes_one(self):
        """ Test get_filter_results with a query of name-includes and a 
        twitter_dict and list_of_usernames of length 1 """

        twitter_dict = {'a':{'name':'aapple', 'location':'', 'web':'', \
                             'bio':'', 'following':[]}}
        list_of_usernames = ['a']
        filter_dict = {'name-includes': 'apple'}
        actual = tf.get_filter_results(twitter_dict, \
                                       list_of_usernames, filter_dict)
        expected = ['a']
        self.assertEqual(actual, expected)
    def test_location_includes_one(self):
        """ Test get_filter_results with a query of location_includes and a 
        twitter_dict and list_of_usernames of length 1 """

        twitter_dict = {'a':{'name':'', 'location':'Modesto, California, USA', \
                             'web':'', 'bio':'', 'following':[]}}
        list_of_usernames = ['a']
        filter_dict = {'location-includes': 'UsA'}
        actual = tf.get_filter_results(twitter_dict, \
                                       list_of_usernames, filter_dict)
        expected = ['a']
        self.assertEqual(actual, expected)
    def test_filter_4(self):
        """Test get_filter_results with usernames = ['Kinder', 'Ken', 'Alan', \
        'Tracy'] and filter_dict = {'location-includes': 'i','following': 'K', \
        'follower': 'Ken'}
        """

        usernames = ['Kinder', 'Ken', 'Alan', 'Tracy']
        filter_dict = {'location-includes': 'i',
                       'following': 'K', 'follower': 'Ken'}

        actual = tf.get_filter_results(twitter_dict, usernames, filter_dict)
        expected = []
        self.assertEqual(actual, expected)
    def test_location_includes_normal(self):
        """ Test get_filter_results with normal query of location-includes """

        twitter_dict = {'a':{'name':'', 'location':'China', \
                             'web':'', 'bio':'', 'following':[]}, \
                        'b':{'name':'', 'location':'kansas, uSa', 'web':'', \
                             'bio':'', 'following':[]}, \
                        'c':{'name':'', 'location':'Musala, Bulgaria', \
                             'web':'', 'bio':'', 'following':[]}}
        list_of_usernames = ['a', 'b', 'c']
        filter_dict = {'location-includes': 'USA'}
        actual = tf.get_filter_results(twitter_dict, \
                                       list_of_usernames, filter_dict)
        expected = ['b', 'c']
        self.assertEqual(actual, expected)
    def test_following_normal_case(self):
        """ Test get_filter_results with normal query of following """

        twitter_dict = {'a':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':['b']}, \
                        'b':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':['c']}, \
                        'c':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':[]}}
        list_of_usernames = ['a', 'b', 'c']
        filter_dict = {'following': 'c'}
        actual = tf.get_filter_results(twitter_dict, \
                                       list_of_usernames, filter_dict)
        expected = ['b']
        self.assertEqual(actual, expected)
Beispiel #22
0
    def test_no_filter_value(self):
        """ Test get_filter_results with multiple twitterverse_dict and \
        usernames entries, but empty filter_spec_dict."""

        twitter_data = {\
            'a':{'name':'Zed', 'location':'', 'web':'', 'bio':'', \
                 'following':[]},
            'b':{'name':'Lee', 'location':'', 'web':'', 'bio':'', \
                 'following':[]},
            'c':{'name':'anna', 'location':'', 'web':'', 'bio':'', \
                 'following':[]}}
        usernames = ['a', 'b', 'c']
        expected_list = ['a', 'b', 'c']
        obtained_list = tf.get_filter_results(twitter_data, usernames, {})
        self.assertEqual(expected_list, obtained_list)
    def test_name_includes_normal(self):
        """ Test get_filter_results with a normal query of name-includes """

        twitter_dict = {'a':{'name':'aapple', 'location':'', 'web':'', \
                             'bio':'', 'following':[]}, \
                        'b':{'name':'babpple', 'location':'', 'web':'', \
                             'bio':'', 'following':[]}, \
                        'c':{'name':'capple', 'location':'', 'web':'', \
                             'bio':'', 'following':[]}}
        list_of_usernames = ['a', 'b', 'c']
        filter_dict = {'name-includes': 'apple'}
        actual = tf.get_filter_results(twitter_dict, \
                                       list_of_usernames, filter_dict)
        expected = ['a', 'c']
        self.assertEqual(actual, expected)
    def test_location_includes_empty_list(self):
        """ Test get_filter_results with a query of location-includes and an 
        empty list of list_of_usernames """

        twitter_dict = {'a':{'name':'', 'location':'Modesto, California, USA', \
                             'web':'', 'bio':'', 'following':[]}, \
                        'b':{'name':'', 'location':'kansas, uSa', 'web':'', \
                             'bio':'', 'following':[]}, \
                        'c':{'name':'', 'location':'Musala, Bulgaria', \
                             'web':'', 'bio':'', 'following':[]}}
        list_of_usernames = []
        filter_dict = {'location-includes': 'apple'}
        actual = tf.get_filter_results(twitter_dict, \
                                       list_of_usernames, filter_dict)
        expected = []
        self.assertEqual(actual, expected)
    def test_get_filter_results_example_1(self):
        """Test tf.get_filter_results for users who follow 'Jessica'"""
        
        data = {'Tommy': {'bio': '', 'web': '', 'location': '',
                'following': ['Ron'], 'name': 'Thomas Burgundy'},
                'Ron': {'bio': '', 'web': '', 'location': '',
                'following': ['Jessica'], 'name': 'Ronald'},
                'Jessica': {'bio': '', 'web': '', 'location': '',
                'following': [], 'name': 'Jessica Pinkman'}}
        list_usernames = ['Tommy', 'Ron']
        filter_spec = {'following': 'Jessica'}

        expected = ['Ron']
        actual = tf.get_filter_results(data, list_usernames, filter_spec)
        self.assertEqual(expected, actual,
                         'Ron is the only person following Jessica')
    def test_location_includes_mixed(self):
        """ Test get_filter_results with a query of location-includes with mixed 
        upper case and lower case letters """

        twitter_dict = {'a':{'name':'', 'location':'Modesto, California, USA', \
                             'web':'', 'bio':'', 'following':[]}, \
                        'b':{'name':'', 'location':'kansas, uSa', 'web':'', \
                             'bio':'', 'following':[]}, \
                        'c':{'name':'', 'location':'Musala, Bulgaria', \
                             'web':'', 'bio':'', 'following':[]}}
        list_of_usernames = ['a', 'b', 'c']
        filter_dict = {'location-includes': 'UsA'}
        actual = tf.get_filter_results(twitter_dict, \
                                       list_of_usernames, filter_dict)
        expected = ['a', 'b', 'c']
        self.assertEqual(actual, expected)
    def test_following_worst_case(self):
        """ Test get_filter_results with the worst query of following, 
        which means that the result list is an empty list """

        twitter_dict = {'a':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':['c']}, \
                        'b':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':['c']}, \
                        'c':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':[]}}
        list_of_usernames = ['a', 'b', 'c']
        filter_dict = {'following': 'b'}
        actual = tf.get_filter_results(twitter_dict, \
                                       list_of_usernames, filter_dict)
        expected = []
        self.assertEqual(actual, expected)
    def test_name_includes_mixed(self):
        """ Test get_filter_results with a query of name-includes with mixed 
        lower case and upper case letters """

        twitter_dict = {'a':{'name':'aApplE', 'location':'', 'web':'', \
                             'bio':'', 'following':[]}, \
                        'b':{'name':'BaPple', 'location':'', 'web':'', \
                             'bio':'', 'following':[]}, \
                        'c':{'name':'CappLe', 'location':'', 'web':'', \
                             'bio':'', 'following':[]}}
        list_of_usernames = ['a', 'b', 'c']
        filter_dict = {'name-includes': 'ApPlE'}
        actual = tf.get_filter_results(twitter_dict, \
                                       list_of_usernames, filter_dict)
        expected = ['a', 'b', 'c']
        self.assertEqual(actual, expected)
    def test_follower_best_case(self):
        """ Test get_filter_results with the best query of follower, 
        which means that the result list includes the maximum elements """

        twitter_dict = {'a':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':['b', 'c']}, \
                        'b':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':['a', 'c']}, \
                        'c':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':['a', 'b']}}
        list_of_usernames = ['a', 'b', 'c']
        filter_dict = {'follower': 'a'}
        actual = tf.get_filter_results(twitter_dict, \
                                       list_of_usernames, filter_dict)
        expected = ['b', 'c']
        self.assertEqual(actual, expected)
    def test_following_empty_list(self):
        """ Test get_filter_results with a query of following and an 
        empty list of list_of_usernames """

        twitter_dict = {'a':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':['c']}, \
                        'b':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':['c']}, \
                        'c':{'name':'', 'location':'', 'web':'', \
                             'bio':'', 'following':[]}}
        list_of_usernames = []
        filter_dict = {'following': 'c'}
        actual = tf.get_filter_results(twitter_dict, \
                                       list_of_usernames, filter_dict)
        expected = []
        self.assertEqual(actual, expected)
    def test_location_includes_worst_case(self):
        """ Test get_filter_results with the worst query of location-includes, 
        which means that the result list is an empty list """

        twitter_dict = {'a':{'name':'', 'location':'Modesto, California, USA', \
                             'web':'', 'bio':'', 'following':[]}, \
                        'b':{'name':'', 'location':'kansas, uSa', 'web':'', \
                             'bio':'', 'following':[]}, \
                        'c':{'name':'', 'location':'Musala, Bulgaria', \
                             'web':'', 'bio':'', 'following':[]}}
        list_of_usernames = ['a', 'b', 'c']
        filter_dict = {'location-includes': 'China'}
        actual = tf.get_filter_results(twitter_dict, \
                                       list_of_usernames, filter_dict)
        expected = []
        self.assertEqual(actual, expected)
    def test_get_filter_results_example_2(self):
        """Test tf.get_filter_results for users who have a follower
        with the username 'Tommy'"""

        data = {'Tommy': {'bio': '', 'web': '', 'location': '',
                'following': ['Jessica'], 'name': 'Thomas Burgundy'},
                'Ron': {'bio': '', 'web': '', 'location': '',
                'following': ['Jessica'], 'name': 'Ronald'},
                'Jessica': {'bio': '', 'web': '', 'location': '',
                'following': [], 'name': 'Jessica Pinkman'}}
        list_usernames = ['Tommy', 'Jessica', 'Ron']
        filter_spec = {'follower': 'Tommy'}

        expected = ['Jessica']
        actual = tf.get_filter_results(data, list_usernames, filter_spec)
        self.assertEqual(expected, actual, "Jessica is the only user "
                         "who is being followd by a user 'Tommy'")
    def test_name_includes_best_case(self):
        """ Test get_filter_results with the best query of name-includes, 
        which means that the result list is exactly the same as 
        list_of_usernames """

        twitter_dict = {'a':{'name':'aapple', 'location':'', 'web':'', \
                             'bio':'', 'following':[]}, \
                        'b':{'name':'bapple', 'location':'', 'web':'', \
                             'bio':'', 'following':[]}, \
                        'c':{'name':'capple', 'location':'', 'web':'', \
                             'bio':'', 'following':[]}}
        list_of_usernames = ['a', 'b', 'c']
        filter_dict = {'name-includes': 'apple'}
        actual = tf.get_filter_results(twitter_dict, \
                                       list_of_usernames, filter_dict)
        expected = ['a', 'b', 'c']
        self.assertEqual(actual, expected)
    def test_get_filter_results_example_5(self):
        """Test tf.get_filter_results for users whose name contain the
        the sub-string 'Burgundy'"""

        data = {'Tommy': {'bio': '', 'web': '', 'location': 'Ohama, USA',
                'following': ['Ron'], 'name': 'Thomas Burgundy'},
                'Ron': {'bio': '', 'web': '', 'location': 'Toronto, CA',
                'following': ['Jessica'], 'name': 'Ronald BURGUNDY'},
                'Jessica': {'bio': '', 'web': '', 'location':
                'Denver Co, United States of America',
                'following': [], 'name': 'Jessica Pinkman'}}
        list_usernames = ['Tommy', 'Ron', 'Jessica']
        filter_spec = {'name-includes': 'Burgundy'}

        expected = ['Tommy', 'Ron']
        actual = tf.get_filter_results(data, list_usernames, filter_spec)
        self.assertEqual(expected, actual, "Tommy and Ron both have a name "
                         "which contains the string 'Burgundy'")
    def test_get_filter_results_example_4(self):
        """Test tf.get_filter_results for users whose locations contain
        the sub-string 'Mexico'"""

        data = {'Tommy': {'bio': '', 'web': '', 'location': 'Vancouver, CA',
                'following': ['Ron'], 'name': 'Thomas Burgundy'},
                'Ron': {'bio': '', 'web': '', 'location': 'Cedar Rapids',
                'following': ['Jessica'], 'name': 'Ronald'},
                'Jessica': {'bio': '', 'web': '', 'location':
                'Denver Co, United States of America',
                'following': [], 'name': 'Jessica Pinkman'}}
        list_usernames = ['Tommy', 'Ron', 'Jessica']
        filter_spec = {'location-includes': 'Mexico'}

        expected = []
        actual = tf.get_filter_results(data, list_usernames, filter_spec)
        self.assertEqual(expected, actual, "Empty list because no user has "
                         "a location which includes the string 'Mexico'")
    def test_get_filter_results_example_3(self):
        """Test tf.get_filter_results for users whose locations contain
        the sub-string 'USA'"""
        
        data = {'Tommy': {'bio': '', 'web': '', 'location': 'Ohama, USA',
                'following': ['Ron'], 'name': 'Thomas Burgundy'},
                'Ron': {'bio': '', 'web': '', 'location': 'Toronto, CA',
                'following': ['Jessica'], 'name': 'Ronald'},
                'Jessica': {'bio': '', 'web': '', 'location':
                'Denver Co, usa', 'following': [], 'name': 'Jessica Pinkman'}}
        list_usernames = ['Tommy', 'Ron', 'Jessica']
        filter_spec = {'location-includes': 'USA'}

        expected = ['Tommy', 'Jessica']
        actual = tf.get_filter_results(data, list_usernames, filter_spec)
        self.assertEqual(expected, actual,
                         "Tommy and Jessica are the only users whose location "
                         "includes the string 'USA'")
    def test_get_filter_results_example_6(self):
        """Test tf.get_filter_results for users who are following 'Tommy',
        have a location which includes the sub-string 'USA' and have a
        follower with the username 'Andrew'"""
        
        data = {'Tommy': {'bio': '', 'web': '', 'location': 'Ohama, USA',
                'following': ['Ron'], 'name': 'Thomas Burgundy'},
                'Ron': {'bio': '', 'web': '', 'location': 'NY, Usa',
                'following': ['Tommy'], 'name': 'Ronald BURGUNDY'},
                'Jessica': {'bio': '', 'web': '', 'location':
                'Denver Co, usa', 'following': ['Tommy', 'Andrew'], 'name':
                'Jessica Pinkman'}, 'Andrew': {'bio': '', 'web': '',
                'location': 'North-America', 'following': ['Jessica']}}
        list_usernames = ['Tommy', 'Ron', 'Jessica', 'Andrew']
        filter_spec = {'following': 'Tommy', 'location-includes': 'USA',
                       'follower': 'Andrew'}

        expected = ['Jessica']
        actual = tf.get_filter_results(data, list_usernames, filter_spec)
        self.assertEqual(expected, actual, "Jessica is the only user who is "
                         "following a user named 'Tommy', has a location "
                         "which includes 'USA' and has a follower with the "
                         "username 'Andrew'")
# Created by Professor/TA to test functions (created by me)

import twitterverse_functions as tf

if __name__ == '__main__':

    data_filename = input('Data file: ')
    data_file = open(data_filename, 'r')
    data = tf.process_data(data_file)
    data_file.close()

    query_filename = input('Query file: ')
    query_file = open(query_filename, 'r')
    query = tf.process_query(query_file)
    query_file.close()

    search_results = tf.get_search_results(data, query['search'])
    filtered_results = tf.get_filter_results(data, search_results,
                                             query['filter'])
    presented_results = tf.get_present_string(data, filtered_results,
                                              query['present'])

    print(presented_results, end="")