Ejemplo n.º 1
0
 def test_c_delete(self):
     delete_task(2)
     self.assertEqual(
         len(get_todos()), 2,
         'After deleting one tasks, the todo list length must be two')
     self.assertEqual(
         get_todos()[0], "Make the bed",
         'After deleting position 2 the first position must still be Make the bed'
     )
     self.assertEqual(
         get_todos()[1], "Clean kitchen",
         'After deleting position 2 the second position must be now Clean kitchen'
     )
Ejemplo n.º 2
0
 def test_b_add(self):
     add_one_task("Make the bed")
     add_one_task("Make lunch")
     add_one_task("Clean kitchen")
     self.assertEqual(
         len(get_todos()), 3,
         'After adding three tasks, the todo list length must be three')
Ejemplo n.º 3
0
    def test_get_todos_not_done(self, monkeypatch):
        self.set_monkeypatch_with_req_query(
            monkeypatch, {'done': '0'}, '0')

        actual_res = app.get_todos()
        assert actual_res.status_code == 200
        assert actual_res.body == self.not_done_todos
Ejemplo n.º 4
0
    def test_get_todos_keyword_not_match_content(self, monkeypatch):
        self.set_monkeypatch_with_req_query(
            monkeypatch, {'keyword': 'とぅ', 'target': 'title'}
        )

        actual_res = app.get_todos()
        assert actual_res.status_code == 200
        assert actual_res.body == []
Ejemplo n.º 5
0
    def test_get_todos_keyword_not_match_both(self, monkeypatch):
        self.set_monkeypatch_with_req_query(
            monkeypatch, {'keyword': 'abcdefg'}
        )

        actual_res = app.get_todos()
        assert actual_res.status_code == 200
        assert actual_res.body == []
Ejemplo n.º 6
0
    def test_get_todos_keyword_both(self, monkeypatch):
        self.set_monkeypatch_with_req_query(
            monkeypatch, {'keyword': 'todo'}
        )

        expected_todos = self.done_todos + self.not_done_todos

        actual_res = app.get_todos()
        assert actual_res.status_code == 200
        assert actual_res.body == expected_todos
Ejemplo n.º 7
0
    def test_get_todos_invalid_params(self, monkeypatch):
        self.set_monkeypatch_with_req_query(
            monkeypatch, {'somekey': 'とぅ', 'done': 'invlid value'}
        )

        expected_todos = self.done_todos + self.not_done_todos

        actual_res = app.get_todos()
        assert actual_res.status_code == 200
        assert actual_res.body == expected_todos
Ejemplo n.º 8
0
 def test_e_load(self):
     file = open(
         'todos.csv',
         'w+')  # open the file for writing 'w', create if it doesn't exists
     file.write('\n'.join(['jump', 'run', 'roll']))  # write the content
     file.close()  # close the file
     load_todos()
     self.assertEqual(
         get_todos(), ['jump', 'run', 'roll'],
         'The todos on the RAM memory have to be the same TODOs on the todos.csv'
     )
Ejemplo n.º 9
0
 def test_d_save(self):
     save_todos()
     file = open("todos.csv", "r")
     file_content = csv.reader(file)
     _todos = []
     for row in file_content:
         _todos.append(row[0])
     file.close()
     self.assertEqual(
         get_todos(), _todos,
         'The todos on the RAM memory have to be the same TODOs on the todos.csv'
     )
Ejemplo n.º 10
0
    def test_get_todos_keyword_title(self, monkeypatch):
        self.set_monkeypatch_with_req_query(
            monkeypatch, {'keyword': 'テスト', 'target': 'title'}
        )

        expected_todos = [
            self.done_todos[0],
            self.not_done_todos[0],
        ]

        actual_res = app.get_todos()
        assert actual_res.status_code == 200
        assert actual_res.body == expected_todos
Ejemplo n.º 11
0
 def test_a_initialize(self):
     self.assertEqual(len(get_todos()), 0,
                      'The todo list needs to start with cero todos')
Ejemplo n.º 12
0
 def test_Return_todos_list(self, client, monkeypatch):
     """get_todos: すべてのアイテムを取得することができる"""
     self._monkeys(client, monkeypatch)
     assert app.get_todos() == TESTDATA_DDB_ITEMS