def test_model_not_set(self): """Test handling of no model""" view = ElasticListAPIView() view.Meta.model = None with self.assertRaises(AssertionError): view.get_queryset()
def test_model_not_set(self): """Test handling of no model""" view = ElasticListAPIView() view.Meta.model = None with self.assertRaises(AssertionError): view.get_queryset()
def test_model_set(self): """Test handling when model is set""" expectation = Search().query("match", field="value") view = ElasticListAPIView() view.Meta.model = MagicMock() view.Meta.model.return_value = "Some" view.Meta.model.search.return_value = expectation self.assertEqual(view.get_queryset(), expectation)
def test_model_set(self): """Test handling when model is set""" expectation = Search().query('match', field='value') view = ElasticListAPIView() view.Meta.model = MagicMock() view.Meta.model.return_value = 'Some' view.Meta.model.search.return_value = expectation self.assertEqual(view.get_queryset(), expectation)