Coverage for cc_modules/tests/cc_device_tests.py: 42%

12 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2022-11-08 23:14 +0000

1#!/usr/bin/env python 

2 

3""" 

4camcops_server/cc_modules/tests/cc_device_tests.py 

5 

6=============================================================================== 

7 

8 Copyright (C) 2012, University of Cambridge, Department of Psychiatry. 

9 Created by Rudolf Cardinal (rnc1001@cam.ac.uk). 

10 

11 This file is part of CamCOPS. 

12 

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. 

17 

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. 

22 

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/>. 

25 

26=============================================================================== 

27 

28""" 

29 

30from camcops_server.cc_modules.cc_device import Device 

31from camcops_server.cc_modules.cc_unittest import DemoDatabaseTestCase 

32 

33 

34# ============================================================================= 

35# Unit tests 

36# ============================================================================= 

37 

38 

39class DeviceTests(DemoDatabaseTestCase): 

40 """ 

41 Unit tests. 

42 """ 

43 

44 def test_device(self) -> None: 

45 self.announce("test_device") 

46 q = self.dbsession.query(Device) 

47 d = q.first() # type: Device 

48 assert d, "Missing Device in demo database!" 

49 self.assertIsInstance(d.get_friendly_name(), str) 

50 self.assertIsInstance(d.get_id(), int) 

51 self.assertIsInstance(d.is_valid(), bool)