Coverage for cc_modules/tests/cc_blob_tests.py: 43%
14 statements
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-08 23:14 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-08 23:14 +0000
1#!/usr/bin/env python
3"""
4camcops_server/cc_modules/tests/cc_blob_tests.py
6===============================================================================
8 Copyright (C) 2012, University of Cambridge, Department of Psychiatry.
9 Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
11 This file is part of CamCOPS.
13 CamCOPS is free software: you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
18 CamCOPS is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.
26===============================================================================
28"""
30from camcops_server.cc_modules.cc_blob import Blob
31from camcops_server.cc_modules.cc_unittest import DemoDatabaseTestCase
32from camcops_server.cc_modules.cc_xml import XmlElement
35# =============================================================================
36# Unit tests
37# =============================================================================
40class BlobTests(DemoDatabaseTestCase):
41 """
42 Unit tests.
43 """
45 def test_blob(self) -> None:
46 self.announce("test_blob")
47 q = self.dbsession.query(Blob)
48 b = q.first() # type: Blob
49 assert b, "Missing BLOB in demo database!"
50 self.assertIsInstanceOrNone(b.get_rotated_image(), bytes)
51 self.assertIsInstance(b.get_img_html(), str)
52 self.assertIsInstance(b.get_xml_element(self.req), XmlElement)
53 self.assertIsInstance(b.get_data_url(), str)