def test_file_previews(self):
        args = MagicMock()
        args.file_preview_path = self.tmpdir
        args.node = "node1"
        args.show_repr = False

        list(items.bw_items(self.repo, args))

        self.assertTrue(exists(join(self.tmpdir, "foo/47")))
        self.assertFalse(exists(join(self.tmpdir, "foo/48")))
        with open(join(self.tmpdir, "foo/47")) as f:
            self.assertEqual(f.read(), "content")
    def test_file_previews(self):
        args = {}
        args['file_preview_path'] = self.tmpdir
        args['node'] = "node1"
        args['show_repr'] = False

        list(items.bw_items(self.repo, args))

        self.assertTrue(exists(join(self.tmpdir, "foo/47")))
        self.assertFalse(exists(join(self.tmpdir, "foo/48")))
        with open(join(self.tmpdir, "foo/47")) as f:
            self.assertEqual(f.read(), "content")
    def test_simple_item_list(self):
        args = MagicMock()
        args.file_preview_path = None
        args.node = "node1"
        args.show_repr = False

        output = list(items.bw_items(self.repo, args))

        self.assertEqual(
            output,
            [
                "type1:item1",
                "type1:item2",
                "directory:/bar/baz",
                "file:/foo/47",
                "file:/foo/48",
            ],
        )
    def test_simple_item_list(self):
        args = {}
        args['file_preview_path'] = None
        args['node'] = "node1"
        args['show_repr'] = False

        output = list(items.bw_items(self.repo, args))

        self.assertEqual(
            output,
            [
                "type1:item1",
                "type1:item2",
                "directory:/bar/baz",
                "file:/foo/47",
                "file:/foo/48",
            ],
        )