def test_generate_diff_abort_403(self, mock_test_result_file):
        """
        Try to generate diff without xhr request
        """
        from mod_test.controllers import generate_diff

        with self.assertRaises(Forbidden):
            generate_diff(1, 1, 1)
Пример #2
0
    def test_generate_diff_abort_404(self, mock_request, mock_test_result_file):
        """Try to generate diff when test file not present."""
        from mod_test.controllers import generate_diff

        mock_request.accept_mimetypes.best = 'application/json'
        mock_test_result_file.query.filter.return_value.first.return_value = None

        with self.assertRaises(NotFound):
            generate_diff(1, 1, 1)
Пример #3
0
    def test_generate_diff_abort_404(self, mock_request, mock_test_result_file):
        """
        Try to generate diff when test file not present.
        """
        from mod_test.controllers import generate_diff

        mock_request.is_xhr = True
        mock_test_result_file.query.filter.return_value.first.return_value = None

        with self.assertRaises(NotFound):
            generate_diff(1, 1, 1)
Пример #4
0
    def test_generate_diff_download(self, mock_response, mock_request, mock_test_result_file):
        """Test to download generated diff."""
        from mod_test.controllers import generate_diff

        mock_request.accept_mimetypes.best = 'application/json'

        response = generate_diff(1, 1, 1, to_view=0)

        self.assertTrue(response, mock_response())
Пример #5
0
    def test_generate_diff(self, mock_request, mock_test_result_file):
        """Test to generate diff."""
        from mod_test.controllers import generate_diff

        mock_request.accept_mimetypes.best = 'application/json'

        response = generate_diff(1, 1, 1)

        self.assertTrue(response, mock_test_result_file.filter().first().generate_html_diff())
        mock_test_result_file.filter.assert_called_once()
Пример #6
0
    def test_generate_diff_download(self, mock_response, mock_request, mock_test_result_file):
        """
        Test to download generated diff.
        """
        from mod_test.controllers import generate_diff

        mock_request.is_xhr = True

        response = generate_diff(1, 1, 1, to_view=0)

        self.assertTrue(response, mock_response())
Пример #7
0
    def test_generate_diff(self, mock_request, mock_test_result_file):
        """
        Test to generate diff.
        """
        from mod_test.controllers import generate_diff

        mock_request.is_xhr = True

        response = generate_diff(1, 1, 1)

        self.assertTrue(response, mock_test_result_file.filter().first().generate_html_diff())
        mock_test_result_file.filter.assert_called_once()