Skip to content

Commit

Permalink
Extend unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
martialblog committed Jul 7, 2023
1 parent f7d148c commit 7bbb46a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions check_bareos.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# Modifications : Thomas Widhalm, NETWAYS GmbH
# E-Mail: widhalmt@widhalm.or.at
#
# Modifications : Markus Opolka, NETWAYS GmbH
#
# This program is free software; you can redistribute it or modify
# it under the terms of the GNU General Public License version 3.0

Expand Down
17 changes: 17 additions & 0 deletions test_check_bareos.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from check_bareos import checkConnection
from check_bareos import connectDB
from check_bareos import Threshold
from check_bareos import check_threshold

from check_bareos import checkBackupSize
from check_bareos import checkEmptyBackups
Expand All @@ -37,6 +38,22 @@ def test_commandline(self):
self.assertEqual(actual.host, 'localhost')
self.assertEqual(actual.user, 'bareos')

class ThresholdTesting(unittest.TestCase):

def test_thresholds(self):
self.assertEqual(check_threshold(0, Threshold("20"), Threshold("25")), 0)
self.assertEqual(check_threshold(10, Threshold("20"), Threshold("25")), 0)
self.assertEqual(check_threshold(24, Threshold("20"), Threshold("25")), 1)
self.assertEqual(check_threshold(26, Threshold("20"), Threshold("25")), 2)

self.assertEqual(check_threshold(15, Threshold("10:"), Threshold("5:")), 0)
self.assertEqual(check_threshold(9, Threshold("10:"), Threshold("5:")), 1)
self.assertEqual(check_threshold(2, Threshold("10:"), Threshold("5:")), 2)

self.assertEqual(check_threshold(15, Threshold("10:20"), Threshold("50")), 0)
self.assertEqual(check_threshold(5, Threshold("10:20"), Threshold("50")), 1)
self.assertEqual(check_threshold(10, Threshold("@10:20"), Threshold("50")), 1)


class UtilTesting(unittest.TestCase):

Expand Down

0 comments on commit 7bbb46a

Please sign in to comment.