Exemple #1
0
    def test_creates_the_data_directory_if_it_doesnt_exist(self):
        self.os.path.exists.return_value = False

        install(self.session, self.log)
        self.os.makedirs.assert_called_with(
            os.path.join(self.homedir, '.local/share/pydo'))
        assert call('Data directory created') in self.log_info.mock_calls
Exemple #2
0
def main(argv=sys.argv[1:]):
    parser = load_parser()
    args = parser.parse_args(argv)

    connection = models.engine.connect()
    session = sessionmaker()(bind=connection)

    if args.subcommand == 'install':
        install(session, logging.getLogger('main'))
    elif args.subcommand in [
        'add',
        'del',
        'done',
        'freeze',
        'mod',
        'unfreeze',
    ]:
        task_modify_commands(session, args)
    elif args.subcommand in ['open', None]:
        open_tasks = session.query(models.Task).filter_by(
            state='open',
            type='task',
        )
        TaskReport(session).print(
            tasks=open_tasks,
            columns=config.get('report.open.columns'),
            labels=config.get('report.open.labels'),
        )
    elif args.subcommand in ['repeating', 'recurring']:
        open_recurring_tasks = session.query(models.RecurrentTask).filter_by(
            state='open',
            recurrence_type=args.subcommand,
        )
        TaskReport(session, models.RecurrentTask).print(
            tasks=open_recurring_tasks,
            columns=config.get('report.{}.columns'.format(args.subcommand)),
            labels=config.get('report.{}.labels'.format(args.subcommand)),
        )
    elif args.subcommand == 'frozen':
        TaskReport(session, models.RecurrentTask).print(
            tasks=session.query(models.Task).filter_by(
                state='frozen',
            ),
            columns=config.get('report.frozen.columns'),
            labels=config.get('report.frozen.labels'),
        )
    elif args.subcommand == 'projects':
        Projects(session).print(
            columns=config.get('report.projects.columns'),
            labels=config.get('report.projects.labels'),
        )
    elif args.subcommand == 'tags':
        Tags(session).print(
            columns=config.get('report.tags.columns'),
            labels=config.get('report.tags.labels'),
        )
    elif args.subcommand == 'export':
        export(logging.getLogger('main'))
Exemple #3
0
    def test_initializes_database(self):
        alembic_args = [
            '-c',
            '/home/test/.venv/pydo/pydo/migrations/alembic.ini',
            'upgrade',
            'head',
        ]

        install(self.session, self.log)

        self.alembic.config.main.assert_called_with(argv=alembic_args)
        assert call('Database initialized') in self.log_info.mock_calls
Exemple #4
0
def main():
    parser = load_parser()
    args = parser.parse_args()
    load_logger()

    connection = engine.connect()
    session = sessionmaker()(bind=connection)
    config = ConfigManager(session)

    if args.subcommand == 'install':
        install(session, logging.getLogger('main'))
    elif args.subcommand in ['add', 'del', 'done']:
        task_manager = TaskManager(session)

        if args.subcommand == 'add':
            attributes = task_manager._parse_arguments(args.add_argument)
            task_manager.add(
                **attributes
            )
        elif args.subcommand == 'del':
            task_manager.delete(id=args.ulid)
        elif args.subcommand == 'done':
            task_manager.complete(id=args.ulid)
    elif args.subcommand in ['list', None]:
        List(session).print(
            columns=config.get('report.list.columns').split(', '),
            labels=config.get('report.list.labels').split(', ')
        )
    elif args.subcommand == 'projects':
        Projects(session).print(
            columns=config.get('report.projects.columns').split(', '),
            labels=config.get('report.projects.labels').split(', ')
        )
    elif args.subcommand == 'tags':
        Tags(session).print(
            columns=config.get('report.tags.columns').split(', '),
            labels=config.get('report.tags.labels').split(', ')
        )
Exemple #5
0
    def test_seed_config_table(self):
        install(self.session, self.log)

        assert self.config.return_value.seed.called
        assert call('Configuration initialized') in self.log_info.mock_calls
Exemple #6
0
    def test_doesnt_create_data_directory_if_exist(self):
        self.os.path.exists.return_value = True

        install(self.session, self.log)
        assert self.os.makedirs.called is False