Beispiel #1
0
 def test_get_counter_new(self, mock_open, mock_create_file):
     counterfile = 'counter'
     mock_open.side_effect = IOError(
         'file or directory %s not found' % counterfile)
     version = get_counter(counterfile)
     mock_open.assert_called_once_with(counterfile)
     mock_create_file.assert_called_once_with(counterfile, '1')
     self.assertEqual(version, 1)
Beispiel #2
0
 def test_get_counter_new(self, mock_open, mock_create_file):
     counterfile = 'counter'
     mock_open.side_effect = IOError('file or directory %s not found' %
                                     counterfile)
     version = get_counter(counterfile)
     mock_open.assert_called_once_with(counterfile)
     mock_create_file.assert_called_once_with(counterfile, '1')
     self.assertEqual(version, 1)
Beispiel #3
0
 def test_get_counter_permission_error(self, mock_open):
     counterfile = 'counter'
     mock_open.read.return_value = 1
     version = get_counter(counterfile)
     mock_open.assert_called_once_with(counterfile)
     self.assertEqual(version, 2)
Beispiel #4
0
 def test_get_counter_permission_oserror(self, mock_open, mock_create_file):
     counterfile = 'counter'
     mock_open.side_effect = OSError('permission denied')
     with self.assertRaises(SaChannelUpdateError):
         get_counter(counterfile)
     mock_open.assert_called_once_with(counterfile)
Beispiel #5
0
 def test_get_counter_permission_error(self, mock_open):
     counterfile = 'counter'
     mock_open.read.return_value = 1
     version = get_counter(counterfile)
     mock_open.assert_called_once_with(counterfile)
     self.assertEqual(version, 2)
Beispiel #6
0
 def test_get_counter_permission_oserror(self, mock_open, mock_create_file):
     counterfile = 'counter'
     mock_open.side_effect = OSError('permission denied')
     with self.assertRaises(SaChannelUpdateError):
         get_counter(counterfile)
     mock_open.assert_called_once_with(counterfile)