Esempio n. 1
0
 def test_logs_file_to_debug_log(self):
     random_file = "/some/path/to/a/file/%s" % random.randint(100, 200)
     with create_mock_open() as o:
         o.side_effect = IOError
         with mock.patch.object(utils, "stderrlog") as log:
             utils.can_open(random_file)
     log.info.assert_called_with("Unable to open %s\n" % random_file)
Esempio n. 2
0
 def test_closes_file_handler_if_successful(self):
     with create_mock_open() as o:
         utils.can_open("/some/file")
     o.assert_has_calls([
         mock.call("/some/file", "ab"),
         mock.call().close(),
     ])
Esempio n. 3
0
 def test_closes_file_handler_if_successful(self):
     with create_mock_open() as o:
         utils.can_open("/some/file")
     o.assert_has_calls([
         mock.call("/some/file", "ab"),
         mock.call().close(),
     ])
Esempio n. 4
0
 def test_logs_file_to_debug_log(self):
     random_file = "/some/path/to/a/file/%s" % random.randint(100, 200)
     with create_mock_open() as o:
         o.side_effect = IOError
         with mock.patch.object(utils, "log") as log:
             utils.can_open(random_file)
     log.debug.assert_called_with("Unable to open %s" % random_file)
Esempio n. 5
0
 def test_returns_false_if_unable_to_open(self):
     with create_mock_open() as o:
         o.side_effect = IOError
         self.assertFalse(utils.can_open("/some/path/some/file"))
Esempio n. 6
0
 def test_returns_true_if_can_open(self):
     with create_mock_open():
         self.assertTrue(utils.can_open("/some/path/some/file"))
Esempio n. 7
0
 def test_returns_false_if_unable_to_open(self):
     with create_mock_open() as o:
         o.side_effect = IOError
         self.assertFalse(utils.can_open("/some/path/some/file"))
Esempio n. 8
0
 def test_returns_true_if_can_open(self):
     with create_mock_open():
         self.assertTrue(utils.can_open("/some/path/some/file"))