Пример #1
0
    def test_get_limits_nochange(self, mock_Semaphore):
        ld = control.LimitData()
        ld.limit_data = self.TEST_DATA
        ld.limit_sum = self.TEST_DATA_CHECKSUM

        self.assertRaises(control.NoChangeException, ld.get_limits,
                          self.TEST_DATA_CHECKSUM)
        mock_Semaphore.return_value.assert_has_calls([
            mock.call.__enter__(),
            mock.call.__exit__(control.NoChangeException, mock.ANY, mock.ANY),
        ])
Пример #2
0
    def test_get_limits_nosum(self, mock_Semaphore):
        ld = control.LimitData()
        ld.limit_data = self.TEST_DATA
        ld.limit_sum = self.TEST_DATA_CHECKSUM

        result = ld.get_limits()

        mock_Semaphore.return_value.assert_has_calls([
            mock.call.__enter__(),
            mock.call.__exit__(None, None, None),
        ])
        self.assertEqual(result, (self.TEST_DATA_CHECKSUM, self.TEST_DATA))
Пример #3
0
    def test_set_limits(self, mock_loads, mock_Semaphore):
        ld = control.LimitData()

        ld.set_limits(self.TEST_DATA)

        mock_Semaphore.return_value.assert_has_calls([
            mock.call.__enter__(),
            mock.call.__exit__(None, None, None),
        ])
        mock_loads.assert_has_calls([mock.call(x) for x in self.TEST_DATA])
        self.assertEqual(ld.limit_data, self.TEST_DATA)
        self.assertEqual(ld.limit_sum, self.TEST_DATA_CHECKSUM)
Пример #4
0
    def test_set_limits_nochange(self, mock_loads, mock_Semaphore):
        ld = control.LimitData()
        ld.limit_sum = self.TEST_DATA_CHECKSUM

        ld.set_limits(self.TEST_DATA)

        mock_Semaphore.return_value.assert_has_calls([
            mock.call.__enter__(),
            mock.call.__exit__(None, None, None),
        ])
        self.assertFalse(mock_loads.called)
        self.assertEqual(ld.limit_data, [])
        self.assertEqual(ld.limit_sum, self.TEST_DATA_CHECKSUM)
Пример #5
0
    def test_init(self):
        ld = control.LimitData()

        self.assertEqual(ld.limit_data, [])
        self.assertEqual(ld.limit_sum, self.EMPTY_CHECKSUM)
        self.assertIsInstance(ld.limit_lock, eventlet.semaphore.Semaphore)