[tests] Restructure
Put tests into directory structure equivalent to that of the code itself, for better separation (hopefully)
This commit is contained in:
parent
5a60a23ebd
commit
acf9d6214e
7 changed files with 0 additions and 0 deletions
0
tests/core/__init__.py
Normal file
0
tests/core/__init__.py
Normal file
33
tests/core/test_config.py
Normal file
33
tests/core/test_config.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
import unittest
|
||||
|
||||
import core.config
|
||||
|
||||
class config(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self._someModules = [ 'b', 'x', 'a' ]
|
||||
self._moreModules = [ 'this', 'module', 'here' ]
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_module(self):
|
||||
cfg = core.config.Config([ '-m' ] + self._someModules)
|
||||
self.assertEqual(self._someModules, cfg.modules())
|
||||
|
||||
def test_module_ordering_maintained(self):
|
||||
cfg = core.config.Config([ '-m' ] + self._someModules + [ '-m' ] + self._moreModules)
|
||||
self.assertEqual(self._someModules + self._moreModules, cfg.modules())
|
||||
|
||||
def test_default_interval(self):
|
||||
cfg = core.config.Config([])
|
||||
self.assertEqual(1, cfg.interval())
|
||||
|
||||
def test_interval(self):
|
||||
cfg = core.config.Config([ '-p', 'interval=4'])
|
||||
self.assertEqual(4, cfg.interval())
|
||||
|
||||
def test_float_interval(self):
|
||||
cfg = core.config.Config([ '-p', 'interval=0.5'])
|
||||
self.assertEqual(0.5, cfg.interval())
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
23
tests/core/test_module.py
Normal file
23
tests/core/test_module.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
import unittest
|
||||
|
||||
import core.module
|
||||
|
||||
class module(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self._invalidModuleName = 'invalid-module-name'
|
||||
self._validModuleName = 'test'
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_load_invalid_module(self):
|
||||
module = core.module.load(self._invalidModuleName)
|
||||
self.assertEqual('core.module', module.__class__.__module__, 'module must be a module object')
|
||||
self.assertEqual('Error', module.__class__.__name__, 'an invalid module must be a core.module.Error')
|
||||
|
||||
def test_load_valid_module(self):
|
||||
module = core.module.load(self._validModuleName)
|
||||
self.assertEqual('modules.{}'.format(self._validModuleName), module.__class__.__module__, 'module must be a modules.<name> object')
|
||||
self.assertEqual('Module', module.__class__.__name__, 'a valid module must have a Module class')
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
27
tests/core/test_output.py
Normal file
27
tests/core/test_output.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
import unittest
|
||||
import json
|
||||
|
||||
import core.output
|
||||
|
||||
class i3(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.i3 = core.output.i3()
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_start(self):
|
||||
data = json.loads(self.i3.start())
|
||||
self.assertEqual(1, data['version'], 'i3bar protocol version 1 expected')
|
||||
self.assertTrue(data['click_events'], 'click events should be enabled')
|
||||
|
||||
def test_begin_status_line(self):
|
||||
self.assertEqual('[', self.i3.begin_status_line(), 'each line must be a JSON array')
|
||||
|
||||
def test_end_status_line(self):
|
||||
self.assertEqual('],\n', self.i3.end_status_line(), 'each line must terminate properly')
|
||||
|
||||
def test_stop(self):
|
||||
self.assertEqual(']\n', self.i3.stop())
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
Loading…
Add table
Add a link
Reference in a new issue