forked from nicolargo/batinfo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_batinfo.py
50 lines (41 loc) · 1.76 KB
/
test_batinfo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# BatInfo test suite
# A simple Python lib to retreive battery information
#
# Copyright (C) 2013 Nicolargo <nicolas@nicolargo.com>
#
# BatInfo is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BatInfo is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from batinfo import batteries
import unittest
class TestBatInfo(unittest.TestCase):
def setUp(self):
self.bat = batteries(bat_root_path="./test")
def test_BatInfo_get(self):
self.assertTrue(len(self.bat) == 2)
def test_BatInfo_name_default(self):
# print("Battery name: %s" % self.bat.stat().name)
self.assertTrue(type(self.bat.stat[0].name) == str)
self.assertTrue(self.bat.stat[0].name == "battery")
def test_BatInfo_capacity(self):
# print("Battery capacity: %s" % self.bat.stat().capacity)
self.assertTrue(type(self.bat.stat[0].capacity) == int)
self.assertTrue(self.bat.stat[0].capacity == 53)
def test_BatInfo_charge_now(self):
# print("Battery 2 charge_now: %s" % self.bat.stat().charge_now)
self.assertTrue(type(self.bat.stat[1].charge_now) == int)
self.assertTrue(self.bat.stat[1].charge_now == 1972000)
if __name__ == '__main__':
unittest.main()