def test_find_without_criteria_returns_all(self):
        mockopen = MagicMock()
        fake_proc_mounts = StringIO(REFERENCE)
        with patch.object(builtins, 'open', mockopen):
            manager = mockopen.return_value.__enter__.return_value
            manager.read.return_value = REFERENCE
            manager.__iter__.return_value = fake_proc_mounts.__iter__()

            cursor = ProcMounts.find()
            items = list(cursor)
            self.assertEquals(len(items), 16)
    def test_find_by_path_without_match(self):
        mockopen = MagicMock()
        fake_proc_mounts = StringIO(REFERENCE)
        with patch.object(builtins, 'open', mockopen):
            manager = mockopen.return_value.__enter__.return_value
            manager.read.return_value = REFERENCE
            manager.__iter__.return_value = fake_proc_mounts.__iter__()

            cursor = ProcMounts.find(path='/var/blah/blah')
            with self.assertRaises(StopIteration):
                item = next(cursor)
    def test_find_by_device_with_match(self):
        mockopen = MagicMock()
        fake_proc_mounts = StringIO(REFERENCE)
        with patch.object(builtins, 'open', mockopen):
            manager = mockopen.return_value.__enter__.return_value
            manager.read.return_value = REFERENCE
            manager.__iter__.return_value = fake_proc_mounts.__iter__()

            cursor = ProcMounts.find(device='/dev/sdf')
            item = next(cursor)
            self.assertEquals(item.path, '/var')
            with self.assertRaises(StopIteration):
                item = next(cursor)