示例#1
0
    def test_list(self, mock_backend, mock_list):
        """ Test if list args are parsed correctly """

        # Not enough args
        argv = ["", "list"]
        self.assertRaises(SystemExit, shell.main, argv)

        argv = ["", "list", "src"]
        shell.main(argv)
        mock_list.assert_called_once()
        self.assertEqual("src", mock_list.call_args[0][1])
        print mock_list.call_args

        argv = ["", "list", "src", "--backup-id", "b-dummy"]
        shell.main(argv)
        mock_list.assert_called_once()
        self.assertEqual("b-dummy", mock_list.call_args[0][2])
示例#2
0
    def test_restore(self, mock_backend, mock_restore):
        """ Test if restore args are parsed correctly """

        # Not enough args
        argv = ["", "restore"]
        self.assertRaises(SystemExit, shell.main, argv)

        argv = ["", "restore", "src"]
        self.assertRaises(SystemExit, shell.main, argv)

        argv = ["", "restore", "src", "dst"]
        self.assertRaises(SystemExit, shell.main, argv)

        argv = ["", "restore", "src", "dst", "backup_id"]
        shell.main(argv)
        mock_restore.assert_called_once()
        self.assertEqual("dst", mock_restore.call_args[0][1])
        self.assertEqual("backup_id", mock_restore.call_args[0][2])
        self.assertEqual("src", mock_backend.call_args[0][0])
示例#3
0
    def test_backup(self, mock_backend, mock_backup):
        """ Test if backup args are parsed correctly """

        # Not enough args
        argv = ["", "backup"]
        self.assertRaises(SystemExit, shell.main, argv)

        argv = ["", "backup", "src"]
        self.assertRaises(SystemExit, shell.main, argv)

        argv = ["", "backup", "src", "dst"]
        shell.main(argv)
        mock_backup.assert_called_once()
        self.assertEqual("src", mock_backup.call_args[0][1])
        self.assertEqual("default", mock_backup.call_args[0][2])
        self.assertEqual("dst", mock_backend.call_args[0][0])

        argv = ["", "--tag", "something", "backup", "src", "dst"]
        shell.main(argv)
        self.assertEqual("src", mock_backup.call_args[0][1])
        self.assertEqual("something", mock_backup.call_args[0][2])
        self.assertEqual("dst", mock_backend.call_args[0][0])