def test_get_todoでToDoが取得できない時にエラーを返す(self, monkeypatch): with pytest.raises(NotFoundError): monkeypatch.setattr( "chalicelib.database.get_todo", lambda _: False ) app.get_todo(202)
def test_get_todoでToDoが取得できる(self, monkeypatch): monkeypatch.setattr( "chalicelib.database.get_todo", lambda _: self.expected_dic ) actual_dic = app.get_todo(201) assert actual_dic == self.expected_dic
def test_get_todo_not_found(self, monkeypatch): monkeypatch.setattr('chalicelib.db.get_todo', lambda u, t: {}) monkeypatch.setattr('app.get_user_id', lambda: '8cb2237d0679ca88db6464eac60da96345513964') actual_todo = app.get_todo('123') assert actual_todo.status_code == 404 assert actual_todo.body == self.expected_todo_not_found
def test_get_todo(self, monkeypatch): monkeypatch.setattr('chalicelib.db.get_todo', lambda u, t: {'Item': self.expected_todo}) monkeypatch.setattr('app.get_user_id', lambda: '8cb2237d0679ca88db6464eac60da96345513964') actual_todo = app.get_todo('999999') assert actual_todo.status_code == 200 assert actual_todo.body == self.expected_todo
def test_Return_todo_dict(self, monkeypatch, item): """get_todo: 取得に指定したuid、usernameのTodoを受け取ることができる""" self._monkeys(monkeypatch) monkeypatch.setattr(app, 'get_authorized_username', lambda *_, **__: item['username']) assert app.get_todo(uid=item['uid']) == item
def test_get_todo_missing(): with pytest.raises(NotFoundError): app.get_todo('999')
def test_get_todo(): assert {'item': 'buy milk'} == app.get_todo('1')
def test_get_todoでToDoがないときにエラーが返ること(self, monkeypatch): with pytest.raises(NotFoundError): monkeypatch.setattr('chalicelib.database.get_todo', lambda _: 0) app.get_todo(202)