class TestClient(unittest.TestCase): def setUp(self): self.wl = Wunderlist() # not calling update_lists, because it sends requests inbox_info = { "title": "inbox", "id": "inbox", "created_on": None, "updated_on": None } self.inbox = TaskList(info=inbox_info) self.wl.lists.append(self.inbox) def test_list_filter(self): list_one = TaskList(info={"title": "one", "id": "one"}) self.wl.lists.append(list_one) list_two = TaskList(info={"title": "one", "id": "two"}) self.wl.lists.append(list_two) self.assertEqual(self.wl.list_with_title("inbox"), self.inbox) self.assertEqual(self.wl.lists_with_title("one"), [list_one, list_two]) self.wl.lists.remove(list_one) self.wl.lists.remove(list_two) def test_get_tasks(self): task = Task({"title": "title", "id": "id"}) self.inbox.add_task(task) self.assertEqual(self.wl.tasks_for_list("inbox"), [task]) self.assertEqual(self.wl.get_task("title", "inbox"), task) self.assertEqual(self.wl.id_for_task("title", "inbox"), "id") def test_lists(self): one = TaskList({"title": "one", "id": "one"}) self.wl.lists.append(one) two = TaskList({"title": "one", "id": "two"}) self.wl.lists.append(two) self.assertEqual(self.wl.list_with_title("inbox"), self.inbox) self.assertEqual(self.wl.lists_with_title("one"), [one, two]) self.assertEqual(self.wl.id_for_list("inbox"), "inbox") def test_due_before(self): one = TaskList({"title": "one", "id": "one"}) task_one = Task({ "title": "task1", "id": "one", "due_date": (date.today() - timedelta(days=1)).isoformat() }) one.add_task(task_one) self.wl.lists.append(one) two = TaskList({"title": "two", "id": "two"}) task_two = Task({ "title": "two", "id": "two", "due_date": (date.today() + timedelta(days=1)).isoformat() }) two.add_task(task_two) self.wl.lists.append(two) task_three = Task({ "title": "three", "id": "three", "due_date": (date.today() + timedelta(days=1)).isoformat() }) self.inbox.add_task(task_three) self.assertEqual(self.wl.tasks_due_before(date.today()), [task_one]) self.assertEqual( self.wl.tasks_due_before(date.today() + timedelta(days=2)), [task_one, task_two, task_three]) def test_due_on(self): one = TaskList({"title": "one", "id": "one"}) task_one = Task({ "title": "task1", "id": "one", "due_date": (date.today() - timedelta(days=1)).isoformat() }) one.add_task(task_one) self.wl.lists.append(one) two = TaskList({"title": "two", "id": "two"}) task_two = Task({ "title": "two", "id": "two", "due_date": (date.today().isoformat()) }) two.add_task(task_two) self.wl.lists.append(two) task_three = Task({ "title": "three", "id": "three", "due_date": (date.today() + timedelta(days=1)).isoformat() }) self.inbox.add_task(task_three) self.assertEqual(self.wl.tasks_due_on(date.today()), [task_two]) self.assertEqual( self.wl.tasks_due_on(date.today() + timedelta(days=1)), [task_three])
class TestClient(unittest.TestCase): def setUp(self): self.wl = Wunderlist() # not calling update_lists, because it sends requests inbox_info = {"title": "inbox", "id": "inbox", "created_on": None, "updated_on": None} self.inbox = TaskList(info=inbox_info) self.wl.lists.append(self.inbox) def test_list_filter(self): list_one = TaskList(info={"title": "one", "id": "one"}) self.wl.lists.append(list_one) list_two = TaskList(info={"title": "one", "id": "two"}) self.wl.lists.append(list_two) self.assertEqual(self.wl.list_with_title("inbox"), self.inbox) self.assertEqual(self.wl.lists_with_title("one"), [list_one, list_two]) self.wl.lists.remove(list_one) self.wl.lists.remove(list_two) def test_get_tasks(self): task = Task({"title": "title", "id": "id"}) self.inbox.add_task(task) self.assertEqual(self.wl.tasks_for_list("inbox"), [task]) self.assertEqual(self.wl.get_task("title", "inbox"), task) self.assertEqual(self.wl.id_for_task("title", "inbox"), "id") def test_lists(self): one = TaskList({"title": "one", "id": "one"}) self.wl.lists.append(one) two = TaskList({"title": "one", "id": "two"}) self.wl.lists.append(two) self.assertEqual(self.wl.list_with_title("inbox"), self.inbox) self.assertEqual(self.wl.lists_with_title("one"), [one, two]) self.assertEqual(self.wl.id_for_list("inbox"), "inbox") def test_due_before(self): one = TaskList({"title": "one", "id": "one"}) task_one = Task({"title": "task1", "id": "one", "due_date": (date.today() - timedelta(days=1)).isoformat()}) one.add_task(task_one) self.wl.lists.append(one) two = TaskList({"title": "two", "id": "two"}) task_two = Task({"title": "two", "id": "two", "due_date": (date.today() + timedelta(days=1)).isoformat()}) two.add_task(task_two) self.wl.lists.append(two) task_three = Task({"title": "three", "id": "three", "due_date": (date.today() + timedelta(days=1)).isoformat()}) self.inbox.add_task(task_three) self.assertEqual(self.wl.tasks_due_before(date.today()), [task_one]) self.assertEqual(self.wl.tasks_due_before(date.today() + timedelta(days=2)), [task_one, task_two, task_three]) def test_due_on(self): one = TaskList({"title": "one", "id": "one"}) task_one = Task({"title": "task1", "id": "one", "due_date": (date.today() - timedelta(days=1)).isoformat()}) one.add_task(task_one) self.wl.lists.append(one) two = TaskList({"title": "two", "id": "two"}) task_two = Task({"title": "two", "id": "two", "due_date": (date.today().isoformat())}) two.add_task(task_two) self.wl.lists.append(two) task_three = Task({"title": "three", "id": "three", "due_date": (date.today() + timedelta(days=1)).isoformat()}) self.inbox.add_task(task_three) self.assertEqual(self.wl.tasks_due_on(date.today()), [task_two]) self.assertEqual(self.wl.tasks_due_on(date.today() + timedelta(days=1)), [task_three])