summaryrefslogtreecommitdiff
path: root/szilagyi/tests.py
blob: bf59873e8872be047b47589a926a47025c7677de (plain)
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
import unittest

from . import calculate_swi


class CalculateSwi(unittest.TestCase):
	def test_out_of_range(self):
		samples = [
			(20, -10),
			(-10, 25000),
			(20, 60000),
			(41, 25000),
			(41, -10),
		]
		for dt, depth in samples:
			with self.assertRaises(ValueError):
				calculate_swi(dt, depth)

	def test_between(self):
		samples = [
			(6.53, 30000, 1, 2),
			(10.78, 20500, -1, 0),
			(24.45, 2600, 0, 1),
			(7.22, 1300, -10, -9),
			(16.1, 6200, 0, 1),
			(3, 20000, -4, -3),
		]
		for dt, depth, low, high in samples:
			swi = calculate_swi(dt, depth)
			self.assertGreater(swi, low)
			self.assertLess(swi, high)