Beispiel #1
0
 def test__init_Should_SetAttributes_When_AttributesPassed(
         self, get_fill_patch, *patches):
     status_line = StatusLine(0, fill=2, regex={'key': 'value'})
     self.assertEqual(status_line.index, 0)
     self.assertEqual(status_line.regex, {'key': 'value'})
     self.assertIsNone(status_line.duration)
     self.assertEqual(status_line.text, '')
     self.assertEqual(status_line.fill, get_fill_patch.return_value)
Beispiel #2
0
 def test__init_Should_SetDefaults_When_Called(self, get_fill_patch,
                                               *patches):
     status_line = StatusLine(0)
     self.assertEqual(status_line.index, 0)
     self.assertEqual(status_line.regex, {})
     self.assertIsNone(status_line.duration)
     self.assertEqual(status_line.text, '')
     self.assertEqual(status_line.fill, get_fill_patch.return_value)
Beispiel #3
0
 def create_status_lines(self, lines):
     """ create return list of status lines
     """
     regex = {}
     regex['text'] = self.config.get('text_regex')
     fill = {}
     fill['max_index'] = lines
     terminal = []
     for index in range(lines):
         status_line = StatusLine(index, fill=fill, regex=regex)
         terminal.append(status_line)
     return terminal
Beispiel #4
0
 def test__match_Should_NotSetText_When_RegexNoMatch(
         self, sanitize_patch, *patches):
     status_line = StatusLine(0, regex={'text': 'match this'})
     status_line.text = 'something'
     status_line.match('hello world')
     self.assertEqual(status_line.text, 'something')
Beispiel #5
0
 def test__match_Should_SetText_When_Regex(self, sanitize_patch, *patches):
     status_line = StatusLine(0, regex={'text': 'hello world'})
     status_line.match('hello world')
     self.assertEqual(status_line.text, sanitize_patch.return_value)
Beispiel #6
0
 def test__pass_Should_DoNothing_When_Called(self, *patches):
     status_line = StatusLine(0)
     status_line.reset()
Beispiel #7
0
 def test__str_Should_ReturnExpected_When_Duration(self, *patches):
     status_line = StatusLine(0)
     status_line.duration = '00:01:23'
     result = str(status_line)
     self.assertEqual(result,
                      '\x1b[1m\x1b[33m\x1b[40m0\x1b[0m:  - 00:01:23')
Beispiel #8
0
 def test__str_Should_ReturnExpected_When_Called(self, *patches):
     status_line = StatusLine(0)
     result = str(status_line)
     self.assertEqual(result, '\x1b[1m\x1b[33m\x1b[40m0\x1b[0m: ')
Beispiel #9
0
 def test__get_fill_Should_ReturnExpected_When_Data(self, *patches):
     result = StatusLine._get_fill({'max_index': 203})
     expected_result = {'index': 3}
     self.assertEqual(result, expected_result)
Beispiel #10
0
 def test__get_fill_Should_ReturnExpected_When_NoData(self, *patches):
     result = StatusLine._get_fill(None)
     expected_result = {'index': FILL}
     self.assertEqual(result, expected_result)
Beispiel #11
0
 def test__sanitize_Should_ReturnExpected_When_NoText(self, *patches):
     text = ''
     result = StatusLine._sanitize(text)
     self.assertEqual(result, text)
Beispiel #12
0
 def test__sanitize_Should_ReturnExpected_When_GreaterThanMaxChars(
         self, *patches):
     text = 'hello' * 40
     result = StatusLine._sanitize(text)
     expected_result = f'{text[0:MAX_CHARS - 3]}...'
     self.assertEqual(result, expected_result)
Beispiel #13
0
 def test__sanitize_Should_ReturnExpected_When_LessThanMaxChars(
         self, *patches):
     text = 'hello world'
     result = StatusLine._sanitize(text)
     self.assertEqual(result, text.ljust(MAX_CHARS))