Esempio n. 1
0
    def test_model_not_set(self):
        """Test handling of no model"""

        view = ElasticListAPIView()
        view.Meta.model = None

        with self.assertRaises(AssertionError):
            view.get_queryset()
Esempio n. 2
0
    def test_model_not_set(self):
        """Test handling of no model"""

        view = ElasticListAPIView()
        view.Meta.model = None

        with self.assertRaises(AssertionError):
            view.get_queryset()
Esempio n. 3
0
    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)
Esempio n. 4
0
    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)