Commits

Yuya Nishihara committed 618521b

tests: manifestmodel: add tests for fileSubrepoCtx()

  • Participants
  • Parent commits 4bad335

Comments (0)

Files changed (1)

tests/qt_manifestmodel_test.py

         self.assertFalse(m.isDir(m.indexFromPath('sub/foo')))
         self.assertTrue(m.isDir(m.indexFromPath('sub/baz')))
 
+    def test_rawfctx(self):
+        m = self.new_model(5)
+        self.check_rawfctx(m, 'foo', None, 'foo')
+        self.check_rawfctx(m, 'sub', None, 'sub')
+        self.check_rawfctx(m, 'sub/foo', 2, 'foo')
+        self.check_rawfctx(m, 'sub/baz/bax', 2, 'baz/bax')
+        self.check_rawfctx(m, 'sub/invalid', None, '')
+        self.check_rawfctx(m, 'deep/sub/foo', 0, 'foo')
+        self.check_rawfctx(m, 'sub/nested', 2, 'nested')
+        self.check_rawfctx(m, 'sub/nested/foo', 0, 'foo')
+
+    def check_rawfctx(self, m, path, expectedrev, expectedsubpath):
+        ctx, subpath = m.fileSubrepoCtx(m.indexFromPath(path))
+        if ctx is None:
+            rev = None
+        else:
+            rev = ctx.rev()
+        self.assertEqual((expectedrev, expectedsubpath), (rev, subpath))
+
     def test_rowcount(self):
         m = self.new_model(0)
         self.assertEqual(3, m.rowCount())