bumblebee-status/tests/modules/contrib/test_uptime.py

27 lines
713 B
Python
Raw Normal View History

import pytest
2020-09-03 03:10:09 +02:00
from unittest import TestCase, mock
2020-09-03 03:10:09 +02:00
import core.config
import core.widget
import modules.contrib.uptime
2020-09-03 03:10:09 +02:00
def build_module():
config = core.config.Config([])
return modules.contrib.uptime.Module(config=config, theme=None)
def widget(module):
return module.widgets()[0]
class UptimeTest(TestCase):
def test_load_module(self):
__import__("modules.contrib.uptime")
@mock.patch('builtins.open', new_callable=mock.mock_open, read_data='300000 10.45')
def test_uptime(self, uptime_mock):
module = build_module()
module.update()
uptime_mock.assert_called_with('/proc/uptime', 'r')
assert widget(module).full_text() == '3 days, 11:20:00'