Exemple #1
0
def run(argv):
    """This function is the core-function using all the other components to
       do the expected work.

       This includes parsing the commandline, reading "config.ini", parsing
       the input-file and actual downloading of all the files.

       Called by ```run.py``` in base-dir.

    """
    # Parse arguments
    arg_parser = CLI()
    input_path, verbose = arg_parser.parse(argv[1:])  # argv[0] = script-name

    # Read config-file
    output_path = read_config()

    # Create and use input-parser
    parser = InputParser(input_path, output_path, verbose)

    # Create downloader
    downloader = Downloader(output_path, verbose)

    # Use downloader
    for url, filename in parser.get_url_targetname_pairs():
        downloader.download(url, filename)
Exemple #2
0
    def test_delete(self):
        parser = CLI().parser

        args = parser.parse_args(["s", "rm", "-n", "sectionname", "-p", "projectname"])
        self.assertEqual(args.command, "s")
        self.assertEqual(args.option, "rm")
        self.assertEqual(args.project, "projectname")
    def test_listing(self):
        parser = CLI().parser

        list_all_args = parser.parse_args(["t", "ls", "-p", "projectname"])
        self.assertEqual(list_all_args.command, "t")
        self.assertEqual(list_all_args.option, "ls")
        self.assertEqual(list_all_args.project, "projectname")
Exemple #4
0
    def test_list(self):
        parser = CLI().parser

        args = parser.parse_args(["s", "ls", "-p", "projectname"])
        self.assertEqual(args.command, "s")
        self.assertEqual(args.option, "ls")
        self.assertEqual(args.project, "projectname")
Exemple #5
0
    def test_create(self):
        parser = CLI().parser

        args = parser.parse_args(["p", "mk", "-d", "description", "-n", "projectname"])
        self.assertEqual(args.command, "p")
        self.assertEqual(args.option, "mk")
        self.assertEqual(args.description, "description")
        self.assertEqual(args.name, "projectname")
Exemple #6
0
    def test_valid_verbose_on(self):
        """Test valid input-file with verbose=on.

        """
        arg_parser = CLI()
        parsed_args = arg_parser.parse(['-i', self.input_file.name, '-v'])
        self.assertEqual(parsed_args[0], self.input_file.name)
        self.assertEqual(parsed_args[1], True)
Exemple #7
0
    def test_valid_minimal(self):
        """Minimal call with valid input-file.

        """
        arg_parser = CLI()
        parsed_args = arg_parser.parse(['-i', self.input_file.name])
        self.assertEqual(parsed_args[0], self.input_file.name)
        self.assertEqual(parsed_args[1], False)
Exemple #8
0
 def test_display(self):
     parser = CLI().parser
     self.assertEqual(
         parser.parse_args(["p", "cat", "-n", "projectname"]).option, "cat"
     )
     self.assertEqual(
         parser.parse_args(["p", "cat", "-n", "projectname"]).name, ["projectname"]
     )
    def test_listing_with_task_status(self):
        parser = CLI().parser

        args = parser.parse_args(["t", "ls", "-p", "projectname"])
        self.assertEqual(args.status, "open")

        args = parser.parse_args(
            ["t", "ls", "--status", "completed", "-p", "projectname"])
        self.assertEqual(args.status, "completed")
    def test_moving(self):
        parser = CLI().parser

        args = parser.parse_args(
            ["t", "mv", "-n", "taskname", "-s", "open", "-p", "projectname"])
        self.assertEqual(args.option, "mv")
        self.assertEqual(args.section, "open")
        self.assertEqual(args.name, ["taskname"])
        self.assertEqual(args.project, "projectname")
    def test_complete(self):
        parser = CLI().parser
        args = parser.parse_args(
            ['t', 'shutdown', '-n', 'taskname', '-p', 'projectname'])

        self.assertEqual(args.name, ['taskname'])
        self.assertEqual(args.command, 't')
        self.assertEqual(args.option, 'shutdown')
        self.assertEqual(args.project, 'projectname')
Exemple #12
0
    def test_playing_with_lyrics_when_spotify_error(self,
                                                    print_mock,
                                                    gorrion_mock):
        gorrion_mock.return_value.playing_with_lyrics.side_effect = SpotifyApiError('spotify error')

        cli = CLI()
        cli.playing_with_lyrics(True, False)

        print_mock.assert_called()
    def test_listing_with_short_format(self):
        parser = CLI().parser

        args = parser.parse_args(["t", "ls", "--short", "-p", "projectname"])

        self.assertEqual(args.command, "t")
        self.assertEqual(args.option, "ls")
        self.assertEqual(args.format, "short")
        self.assertEqual(args.project, "projectname")
    def test_update(self):
        parser = CLI().parser

        args = parser.parse_args(
            ["t", "vi", "-n", "taskname", "-p", "projectname"])
        self.assertEqual(args.command, "t")
        self.assertEqual(args.option, "vi")
        self.assertEqual(args.name, "taskname")
        self.assertEqual(args.project, "projectname")
Exemple #15
0
    def test_invalid_minimal(self):
        """Minimal call with non-existing input-file.

           This "non-existence" in this test is true with high-probability.

           Will raise UtilsFileDoesNotExistError.

        """
        arg_parser = CLI()
        with self.assertRaises(UtilsFileDoesNotExistError):
            parsed_args = arg_parser.parse(['-i', self.input_file.name + '1'])
Exemple #16
0
    def test_playing_album_when_spotify_error(self,
                                              print_mock,
                                              gorrion_mock):
        gorrion_mock.return_value.playing_album.side_effect = SpotifyApiError(
            'spotify error'
        )

        cli = CLI()
        cli.playing_album(True)

        print_mock.assert_called()
Exemple #17
0
    def test_playing_album(self, print_mock, gorrion_mock):
        gorrion_mock.return_value.playing_album.return_value = PublishedTweet(
            '123',
            'song',
            None
        )

        cli = CLI()
        cli.playing_album(True)

        print_mock.assert_any_call('[---------------------- Album ----------------------]')
        print_mock.assert_any_call('song')
Exemple #18
0
    def test_playing_with_lyrics(self, print_mock, gorrion_mock):
        gorrion_mock.return_value.playing_with_lyrics.return_value = [
            PublishedTweet('123', 'song', None),
            PublishedTweet('456', 'song-lyric1', None),
            PublishedTweet('789', 'song-lyric2', None),
        ]

        cli = CLI()
        cli.playing_with_lyrics(True, False)

        print_mock.assert_any_call('[---------------------- Song -----------------------]')
        print_mock.assert_any_call('song')
        print_mock.assert_any_call('[---------------------- Lyric ----------------------]')
        print_mock.assert_any_call('song-lyric1\n\nsong-lyric2')
    def test_listing_with_section(self):
        parser = CLI().parser

        args = parser.parse_args(
            ["t", "ls", "-s", "sectionname", "-p", "projectname"])
        self.assertEqual(args.command, "t")
        self.assertEqual(args.option, "ls")
        self.assertEqual(args.section, "sectionname")
        self.assertEqual(args.project, "projectname")

        args = parser.parse_args(["t", "ls", "-p", "projectname"])
        self.assertEqual(args.command, "t")
        self.assertEqual(args.option, "ls")
        self.assertEqual(args.section, "all")
        self.assertEqual(args.project, "projectname")
Exemple #20
0
def main():
    args = parser.parse_args()

    if args.verbose:
        logger.logger.setLevel(level=logging.DEBUG)
    else:
        logger.logger.setLevel(level=logging.ERROR)

    cli = CLI(
        executable_path=args.executable,
        type=args.type,
        input_path=args._input_path,
        input_template=args.input_template,
        test_result_path=args.test_result_path,
        count=args.count,
    )
    cli.run()
    def test_create(self):
        parser = CLI().parser

        args = parser.parse_args([
            "t",
            "mk",
            "-d",
            "description",
            "-n",
            "taskname",
            "-s",
            "sectionname",
            "-p",
            "projectname",
        ])
        self.assertEqual(args.command, "t")
        self.assertEqual(args.option, "mk")
        self.assertEqual(args.name, "taskname")
        self.assertEqual(args.section, "sectionname")
        self.assertEqual(args.project, "projectname")
        self.assertEqual(args.description, "description")
Exemple #22
0
    def test_listing(self):
        parser = CLI().parser

        self.assertEqual(parser.parse_args(["p", "ls"]).option, "ls")

        self.assertEqual(parser.parse_args(["p", "ls", "-a"]).type, "active")
        self.assertEqual(parser.parse_args(["p", "ls", "--active"]).type, "active")

        self.assertEqual(parser.parse_args(["p", "ls", "--all"]).type, "all")

        self.assertEqual(parser.parse_args(["p", "ls", "--archived"]).type, "archived")
Exemple #23
0
#!/usr/bin/python3.4

from src.cli import CLI

interface = CLI()
Exemple #24
0
# report-ng
# Copyright (c) 2014-2017 Marcin Woloszyn (@hvqzao)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.


if __name__ == '__main__':
    import sys
    if len(sys.argv) > 1:
        from src.cli import CLI
        CLI()
    else:
        from src.gui import GUI
        GUI()
Exemple #25
0
 def test_update(self):
     parser = CLI().parser
     self.assertEqual(
         parser.parse_args(["p", "vi", "-n", "projectname"]).option, "vi"
     )
Exemple #26
0
 def test_delete(self):
     parser = CLI().parser
     self.assertEqual(
         parser.parse_args(["p", "rm", "-n", "projectname"]).option, "rm"
     )