コード例 #1
0
    def test_validation_passes_with_valid_conditions(self):
        conditions = [
            {'hours': 10, 'percent': 10},
            {'percent': 100}
        ]

        validate_conditions(conditions)
コード例 #2
0
    def test_raises_exception_if_all_conditions_have_hours(self):
        conditions = [{'hours': 10, 'percent': 10}]
        exc = None

        # ACT
        try:
            validate_conditions(conditions)
        except Exception as err:
            exc = err

        # ASSERTS
        self.assertIsNotNone(exc)
        self.assertEqual(str(exc), 'Invalid conditions.')
コード例 #3
0
    def test_raises_exception_if_hours_bigger_than_24(self):
        # ARRANGE
        conditions = [
            {'hours': 72, 'percent': 10000},
            {'percent': 10},
        ]
        exc = None

        # ACT
        try:
            validate_conditions(conditions)
        except Exception as err:
            exc = err

        # ASSERTS
        self.assertIsNotNone(exc)
        self.assertEqual(str(exc), 'Hours cannot be > 24.')
コード例 #4
0
	def test_raises_exception_if_percent_less_than_0(self):
		# ARRANGE
		conditions = [
			{'hours': 23, 'percent': -10},
			{'percent': 10},
		]
		exc = None

		# ACT
		try:
			validate_conditions(conditions)
		except Exception as err:

			exc = err

		# ASSERTS
		self.assertIsNotNone(exc)
		self.assertEqual(str(exc), 'Percent cannot be < 0%')