def tets_does_list_exists(self): """Test list existings.""" lst_exist = List(tst_db.TEST_LIST[0]) lst_not_exist = List("Some title.") res_1 = lst_exist.exists() res_2 = lst_not_exist.exists() self.assertTrue(res_1) self.assertFalse(res_2)
def test_get_list_with_tasks_as_python_list(self): """Test returning the list with tasks as Python list.""" lst_with_tsks = List(tst_db.TEST_LIST[1]) lst_with_tsk = List(tst_db.TEST_LIST[0]) lst_1 = lst_with_tsks.get_as_list() lst_2 = lst_with_tsk.get_as_list() self.assertIsInstance(lst_1, list) self.assertEqual(lst_1, tst_db.TEST_LIST_WITH_TASKS) self.assertIsInstance(lst_2, list) self.assertEqual(lst_2, tst_db.TEST_LIST_WITH_TASK)
def get_list(request, title): if request.method == "GET": try: data = List(title).get_as_list() except AttributeError: return HttpResponse("There are no '%s'" % title) return Response(data, status=status.HTTP_200_OK)
def test_update_list(self): """Test updating an existing list.""" mngr = UpdateManager() mngr.update(NEW_LIST) updated = List(tst_db.TEST_LIST[0]).get_as_list() self.assertEqual(NEW_LIST, updated)
def test_delete_list(self): """Deletion list with tasks.""" list_to_del = {"title": TEST_LIST_DATA[0][0]} mngr = DeleteManager() mngr.delete(list_to_del) exists = List(tst_db.TEST_LIST[0]).exists() self.assertFalse(exists)
def test_update_list(self): request = self.factory.post( "/update", json.dumps(UPDATE_TEST_DATA), content_type="application/json" ) response = update_list(request) lst = List(UPDATE_TEST_DATA[0]["title"]).get_as_list() self.assertEqual(response.status_code, 200) self.assertEqual(UPDATE_TEST_DATA, lst)
def test_insert_list(self): request = self.factory.post( "/insert", json.dumps(INSERT_TEST_DATA), content_type="application/json" ) response = insert_list(request) lst = List(INSERT_TEST_DATA[0]["title"]).get_as_list() self.assertEqual(response.status_code, 201) self.assertEqual(INSERT_TEST_DATA, lst)
def test_insert_list_with_tasks(self): """Insert list with tasks.""" InsertManager().insert(tst_db.TEST_LIST_WITH_TASKS) lst = List(tst_db.TEST_LIST_WITH_TASKS[0]["title"]) self.assertEqual(tst_db.TEST_LIST_WITH_TASKS, lst.get_as_list())