Esempio n. 1
0
    def test_verify_args_general(self):
        parser = yt_script.setup_arg_parser()

        try:
            yt_script.verify_arguments(
                parser, [self.TESTING_CHANNEL_ID, self.API_KEY,
                         '-d', '1', '-f', self.TESTING_FILENAME + '.' + self.TESTING_EXT])
            yt_script.verify_arguments(
                parser, [self.TESTING_CHANNEL_ID, self.API_KEY,
                         '-d', '99999', '-f', '.' + self.TESTING_FILENAME + '.' + self.TESTING_EXT])
            yt_script.verify_arguments(
                parser, [self.TESTING_CHANNEL_ID, self.API_KEY,
                         '-d', '99999', '-f', self.TESTING_FILENAME + '.' + self.TESTING_EXT + '.'])
            yt_script.verify_arguments(
                parser, [self.TESTING_CHANNEL_ID, self.API_KEY,
                         '-d', '99999', '-f', self.TESTING_FILENAME])
        except AssertionError as e:
            self.fail(str(e.message))

        self.assertRaises(AttributeError, yt_script.verify_arguments,
                          parser, [self.TESTING_CHANNEL_ID, self.API_KEY,
                                   '-d', '0', '-f', self.TESTING_FILENAME])
        self.assertRaises(AttributeError, yt_script.verify_arguments,
                          parser, [self.TESTING_CHANNEL_ID, self.API_KEY,
                                   '-d', '-1', '-f', self.TESTING_FILENAME])
        for char in self.BAD_CHARS:
            self.assertRaises(Exception, yt_script.verify_arguments,
                              [self.TESTING_CHANNEL_ID, self.API_KEY,
                               '-f', self.TESTING_FILENAME + char])
Esempio n. 2
0
 def test_args_output(self):
     testing_outputs = ['text', 'graphml', 'gml', 'gexf', 'yaml']
     parser = yt_script.setup_arg_parser()
     for option in testing_outputs:
         response = parser.parse_args([self.TESTING_CHANNEL_ARG,
                                       self.TESTING_API_KEY, '-o', option])
         self.assertEqual(response.output, option)
Esempio n. 3
0
 def test_args_verbose(self):
     testing_verbosity = [1, 2, 3]
     parser = yt_script.setup_arg_parser()
     for option in testing_verbosity:
         response = parser.parse_args([self.TESTING_CHANNEL_ARG,
                                       self.TESTING_API_KEY, '-v', str(option)])
         self.assertEqual(int(response.verbose), option)
Esempio n. 4
0
 def test_args_degrees(self):
     parser = yt_script.setup_arg_parser()
     testing_degrees = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
     for test_degree in testing_degrees:
         response = parser.parse_args([self.TESTING_CHANNEL_ARG,
                                       self.TESTING_API_KEY, '-d', test_degree])
         self.assertTrue(response.degree, int(test_degree))
Esempio n. 5
0
    def test_args_filename(self):
        filename = 'mock_filename'
        parser = yt_script.setup_arg_parser()
        response = parser.parse_args([self.TESTING_CHANNEL_ARG,
                                      self.TESTING_API_KEY, '-f', filename])

        self.assertEqual(response.filename, filename)
 def test_args_output(self):
     testing_outputs = ['text', 'graphml', 'gml', 'gexf', 'yaml']
     parser = yt_script.setup_arg_parser()
     for option in testing_outputs:
         response = parser.parse_args(
             [self.TESTING_CHANNEL_ARG, self.TESTING_API_KEY, '-o', option])
         self.assertEqual(response.output, option)
    def test_args_filename(self):
        filename = 'mock_filename'
        parser = yt_script.setup_arg_parser()
        response = parser.parse_args(
            [self.TESTING_CHANNEL_ARG, self.TESTING_API_KEY, '-f', filename])

        self.assertEqual(response.filename, filename)
 def test_args_verbose(self):
     testing_verbosity = [1, 2, 3]
     parser = yt_script.setup_arg_parser()
     for option in testing_verbosity:
         response = parser.parse_args([
             self.TESTING_CHANNEL_ARG, self.TESTING_API_KEY, '-v',
             str(option)
         ])
         self.assertEqual(int(response.verbose), option)
 def test_args_degrees(self):
     parser = yt_script.setup_arg_parser()
     testing_degrees = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
     for test_degree in testing_degrees:
         response = parser.parse_args([
             self.TESTING_CHANNEL_ARG, self.TESTING_API_KEY, '-d',
             test_degree
         ])
         self.assertTrue(response.degree, int(test_degree))
Esempio n. 10
0
    def test_args_defaults(self):

        expected_defaults = "Namespace(api_key=" + repr(self.TESTING_API_KEY) + \
                            ", degree=1, filename=" + repr(yt_script.DEFAULT_OUTPUT_FILENAME) \
                            + ", id=" + repr(self.TESTING_CHANNEL_ARG) + \
                            ", output=None, show_graph=False, verbose=0)"

        parser = yt_script.setup_arg_parser()
        response = parser.parse_args([self.TESTING_CHANNEL_ARG, self.TESTING_API_KEY])
        self.assertEqual(str(response), expected_defaults)
    def test_args_defaults(self):

        expected_defaults = "Namespace(api_key=" + repr(self.TESTING_API_KEY) + \
                            ", degree=1, filename=" + repr(yt_script.DEFAULT_OUTPUT_FILENAME) \
                            + ", id=" + repr(self.TESTING_CHANNEL_ARG) + \
                            ", output=None, show_graph=False, verbose=0)"

        parser = yt_script.setup_arg_parser()
        response = parser.parse_args(
            [self.TESTING_CHANNEL_ARG, self.TESTING_API_KEY])
        self.assertEqual(str(response), expected_defaults)
    def test_verify_args_general(self):
        parser = yt_script.setup_arg_parser()

        try:
            yt_script.verify_arguments(parser, [
                self.TESTING_CHANNEL_ID, self.API_KEY, '-d', '1', '-f',
                self.TESTING_FILENAME + '.' + self.TESTING_EXT
            ])
            yt_script.verify_arguments(parser, [
                self.TESTING_CHANNEL_ID, self.API_KEY, '-d', '99999', '-f',
                '.' + self.TESTING_FILENAME + '.' + self.TESTING_EXT
            ])
            yt_script.verify_arguments(parser, [
                self.TESTING_CHANNEL_ID, self.API_KEY, '-d', '99999', '-f',
                self.TESTING_FILENAME + '.' + self.TESTING_EXT + '.'
            ])
            yt_script.verify_arguments(parser, [
                self.TESTING_CHANNEL_ID, self.API_KEY, '-d', '99999', '-f',
                self.TESTING_FILENAME
            ])
        except AssertionError as e:
            self.fail(str(e.message))

        self.assertRaises(AttributeError, yt_script.verify_arguments, parser, [
            self.TESTING_CHANNEL_ID, self.API_KEY, '-d', '0', '-f',
            self.TESTING_FILENAME
        ])
        self.assertRaises(AttributeError, yt_script.verify_arguments, parser, [
            self.TESTING_CHANNEL_ID, self.API_KEY, '-d', '-1', '-f',
            self.TESTING_FILENAME
        ])
        for char in self.BAD_CHARS:
            self.assertRaises(Exception, yt_script.verify_arguments, [
                self.TESTING_CHANNEL_ID, self.API_KEY, '-f',
                self.TESTING_FILENAME + char
            ])