예제 #1
0
    def test_no_categories(self):
        """given a set of parameters without explicit categories extract them"""

        given = [
            sys.path,
            twitter_feed_batch._AcceptedArgumentKeys.screen_names.value,
            'name_1', 'name_2', 'name_3', 'name_4',
            twitter_feed_batch._AcceptedArgumentKeys.output_format.value,
            'csv',
            twitter_feed_batch._AcceptedArgumentKeys.weka_friendly.value,
            twitter_feed_batch._AcceptedArgumentKeys.include_retweets.value
        ]

        expect = {
            twitter_feed_batch._AcceptedArgumentKeys.screen_names.value:
            ['name_1', 'name_2', 'name_3', 'name_4'],
            twitter_feed_batch._AcceptedArgumentKeys.weka_friendly.value:
            True,
            twitter_feed_batch._AcceptedArgumentKeys.include_retweets.value:
            True,
            twitter_feed_batch._AcceptedArgumentKeys.output_format.value:
            'csv'
        }

        self.assertDictEqual(twitter_feed_batch.extract_arguments(argv=given),
                             expect)
예제 #2
0
    def test_extract_arguments(self):
        """given a set of parameters extract them"""

        given = [
            sys.path,
            twitter_feed_batch._AcceptedArgumentKeys.screen_names.value,
            'name_1', 'name_2', 'name_3', 'name_4',
            twitter_feed_batch._AcceptedArgumentKeys.output_format.value,
            'csv',
            twitter_feed_batch._AcceptedArgumentKeys.append_categories.value,
            'A', 'B', 'C', 'D',
            twitter_feed_batch._AcceptedArgumentKeys.weka_friendly.value,
            twitter_feed_batch._AcceptedArgumentKeys.include_retweets.value
        ]

        expect = {
            twitter_feed_batch._AcceptedArgumentKeys.screen_names.value:
            ['name_1', 'name_2', 'name_3', 'name_4'],
            twitter_feed_batch._AcceptedArgumentKeys.include_retweets.value:
            True,
            twitter_feed_batch._AcceptedArgumentKeys.weka_friendly.value:
            True,
            twitter_feed_batch._AcceptedArgumentKeys.append_categories.value:
            ['A', 'B', 'C', 'D'],
            twitter_feed_batch._AcceptedArgumentKeys.output_format.value:
            'csv'
        }

        self.assertDictContainsSubset(
            twitter_feed_batch.extract_arguments(argv=given), expect)
예제 #3
0
    def test_missing_names(self):
        """given a set of parameters missing the screen names expect an exception"""

        given = [
            sys.path,
            twitter_feed_batch._AcceptedArgumentKeys.output_format.value,
            'csv',
            twitter_feed_batch._AcceptedArgumentKeys.append_categories.value,
            'A', 'B', 'C',
            twitter_feed_batch._AcceptedArgumentKeys.weka_friendly.value,
            twitter_feed_batch._AcceptedArgumentKeys.include_retweets.value
        ]

        self.assertRaises(
            twitter_feed_batch.InvalidArgument,
            lambda: twitter_feed_batch.extract_arguments(argv=given))
예제 #4
0
    def test_unmatching_names(self):
        """given a set of scren names that don't match expect an exception"""

        given = [
            sys.path,
            twitter_feed_batch._AcceptedArgumentKeys.screen_names.value,
            'name_1', 'name_2', 'name_4',
            twitter_feed_batch._AcceptedArgumentKeys.output_format.value,
            'csv',
            twitter_feed_batch._AcceptedArgumentKeys.append_categories.value,
            'A', 'B', 'C', 'D',
            twitter_feed_batch._AcceptedArgumentKeys.weka_friendly.value,
            twitter_feed_batch._AcceptedArgumentKeys.include_retweets.value
        ]

        self.assertRaises(
            twitter_feed_batch.InvalidArgument,
            lambda: twitter_feed_batch.extract_arguments(argv=given))