1
私はちょうどDjangoを使い始めています。私は本当に必要なものすべてをテストするうえで欲しいです。私のクラスのほとんどはクラスビューのジェネリックビュー(リストビューなど)です。ここにはそのようなものがあります:Djangoジェネリックビューのテスト
class CellView(ListView):
"""
Class that determines list view for all Cells
Inherits from Django GenericView ListView Class
Attributes:
model: Overrided attribute that indicates that
cell is the model to be displayed
template_name: Overrided attribute that indicates
which html template to use
queryset: Overrided attribute that indicates a python
queryset of all cell objects to be displated
context_object_name: Overrided attribute that indicates
string to name the context object in the template
"""
model = Cell
template_name = "CellView.html"
query_set = Cell.objects.all()
context_object_name = "Cells"
私はここで行うのは定義属性です。ここでこのコードをテストする必要がありますか?それとも、これは本当にDjangoが扱うものとして数えられるのですか?それがうまくいくと私は信じていますか?もし私がそれをテストしなければならない場合は、具体的に何をテストすべきですか?
ここでのユニットテストのようなものは、実際のロジックではなく、実装のテスト(またはコンフィグレーション?)でしょう。 FWIWでは、 'query_set'パラメータは余計です。 'self.model.objects.all()'はデフォルトの 'query_set'です – kevinharvey