Exemplo n.º 1
0
    def add(self, text, label, project, date_expression) -> List[Task]:
        assert type(text) and type(label) and type(project)\
               and type(date_expression) is str
        task_list = list()
        if self.__date_generator.validate_input(date_expression):
            for due_date in self.__date_generator.get_due_dates(
                    date_expression):
                task = Task(text)
                task.label = label
                task.project = project
                task.date_expression = date_expression
                task.due_date = due_date
                self.append(task)
                task_list.append(task)
        else:
            raise AttributeError(
                f"Provided date expression {date_expression} is invalid")

        return task_list
Exemplo n.º 2
0
    def test_save_object(self):
        self.redis_db.initialize(Snapshot())
        self.assertIsNotNone(self.redis_db.db)

        snapshot = Snapshot()
        snapshot.count = 22
        self.redis_db.set([snapshot])

        snapshot_list = self.redis_db.get()
        self.assertTrue(len(snapshot_list) == 1)
        snapshot_dict = snapshot_list[0]
        self.assertTrue(snapshot_dict["count"] == 22)

        self.redis_db.initialize(Task())
        self.assertIsNotNone(self.redis_db.db)

        task = Task()
        task.project = "work"
        self.redis_db.set([task])

        task_list = self.redis_db.get()
        self.assertTrue(len(task_list) == 1)
        task_dict = task_list[0]
        self.assertTrue(task_dict["project"] == "work")