コード例 #1
0
 def test_filters_are_clones_not_references(self):
     """_filter must be cloned"""
     # Everything else is considered immutable
     qs = FBO(
         path=TEST_FILES_ROOT,
         glob='*.rst',
     )
     self.assertEqual(
         3,
         qs.count(),
     )
     qs2 = qs.filter(name='test1.rst')
     self.assertEqual(
         3,
         qs.count(),
     )
コード例 #2
0
    def test_intrinsic_metadata(self):
        """Intrinsic metadata."""

        qs = FBO(
            path=TEST_FILES_ROOT,
            glob='*.md',
            metadata='.meta',
        ).all()

        self.assertEqual(
            4,
            qs.count(),
        )
        # Have to test this both ways so that however it
        # comes out of the filesystem "by default" (ie
        # intrinsically, probably inode ordering) we'll get
        # a failure if our explicit ordering isn't applied.
        self.assertEqual(
            'index.md',
            qs.order_by('name')[0].name,
        )
        self.assertEqual(
            'test2.md',
            qs.order_by('-name')[0].name,
        )
コード例 #3
0
    def test_extrinsic_metadata(self):
        """Various format front matter."""

        qs = FBO(
            path=TEST_FILES_ROOT,
            glob='*.rst',
            metadata=FileObject.MetadataInFileHead,
        ).all()

        self.assertEqual(
            3,
            qs.count(),
        )
        # Have to test this both ways so that however it
        # comes out of the filesystem "by default" (ie
        # intrinsically, probably inode ordering) we'll get
        # a failure if our explicit ordering isn't applied.
        self.assertEqual(
            'test1.rst',
            qs.order_by('title')[0].name,
        )
        self.assertEqual(
            'test3.rst',
            qs.order_by('-title')[0].name,
        )
コード例 #4
0
    def test_everything(self):
        """Just find all file objects."""

        qs = FBO(
            path=TEST_FILES_ROOT,
        ).exclude(
            name__glob='*~',
        ).exclude(
            name__glob='*.meta',
        )

        self.assertEqual(
            7,
            qs.count(),
        )
        self.assertEqual(
            {
                'index.md',
                'subdir/index.md',
                'test1.md',
                'test2.md',
                'test1.rst',
                'test2.rst',
                'test3.rst',
            },
            { o.name for o in qs },
        )
コード例 #5
0
    def test_glob_restriction(self):
        """With globbing."""

        qs = FBO(
            path=TEST_FILES_ROOT,
            glob='*.md',
        ).all()

        self.assertEqual(
            4,
            qs.count(),
        )
        self.assertEqual(
            {
                'index.md',
                'subdir/index.md',
                'test1.md',
                'test2.md',
            },
            { o.name for o in qs },
        )