def test_is_sticky_bit_set_when_is_set(self, mock_os): # Prepare data and mocks test_subject = WorldWritable(None) mock_os.stat.return_value = os.stat_result( (0o01000, 0, 0, 0, 0, 0, 0, 0, 0, 0)) path = '/does/not/actually/exist' # Run test scenario result = test_subject.is_sticky_bit_set(path) # Assertions self.assertTrue(result) mock_os.stat.assert_called_once_with(path)
def test_scan_when_success(self): # Prepare data and mocks test_subject = WorldWritable(None) test_subject.scan_worldwritable_files_starting_with_dot = MagicMock( return_value=[]) test_subject.scan_worldwritable_directories_with_no_sticky_bit_set = MagicMock( return_value=[]) test_subject.scan_worldwritable_files_owned_by_root = MagicMock( return_value=[]) # Run test scenario result = test_subject.scan() # Assertions test_subject.scan_worldwritable_files_starting_with_dot.assert_called_once_with( ) test_subject.scan_worldwritable_directories_with_no_sticky_bit_set.assert_called_once_with( ) test_subject.scan_worldwritable_files_owned_by_root.assert_called_once_with( ) self.assertEqual(result[0], ScanStatus.success) self.assertEqual(result[1], '')