Пример #1
0
    def test_version_1_loads_correctly(self):
        # Given
        p = Project(name='test', path=self.root)
        p.scan()
        fname = join(self.root, 'test.vxn')
        p._save_as_v1(fname)

        # When
        p = Project()
        p.load(fname)

        # Then
        self.assertEqual(p.number_of_files, 5)
        m = p.get('root.txt')
        self.assertEqual(m.relpath, 'root.txt')
        self.assertEqual(m.type, 'text')
        self.assertEqual(len(m.tags), 1)
        self.assertIn('completed', m.tags)
        relpath = join('sub', 'sub.txt')
        m = p.get(relpath)
        self.assertEqual(m.file_name, 'sub.txt')
        self.assertEqual(m.relpath, relpath)
        self.assertEqual(len(m.tags), 1)
        self.assertIn('completed', m.tags)
        d = p.root.directories[0]
        self.assertEqual(d.relpath, d.name)
Пример #2
0
    def test_load_should_restore_saved_state(self):
        # Given
        p = Project(name='test', description='Test', path=self.root)
        p.scan()
        out_fname = tempfile.mktemp(dir=self.root)
        out = open(out_fname, 'wb')

        # When
        p.save_as(out)
        p1 = Project()
        p1.load(out_fname)

        # Then
        self.assertEqual(p.name, 'test')
        self.assertEqual(p.description, 'Test')
        self.assertEqual(p.root.name, 'test')
        self.assertEqual(len(p.root.directories), 2)
        self.assertEqual(len(p.root.files), 2)
        self.assertEqual(len(p.tags), 1)
        self.assertEqual(p.tags[0].name, 'completed')
        self.assertEqual(p.tags[0].type, 'bool')

        self.assertEqual(p.number_of_files, 5)
        m = p.get('root.txt')
        self.assertEqual(len(m.tags), 1)
        self.assertIn('completed', m.tags)
        m = p.get(join('sub', 'sub.txt'))
        self.assertEqual(m.file_name, 'sub.txt')
        self.assertEqual(len(m.tags), 1)
        self.assertIn('completed', m.tags)

        # Ensure that the ctime and mtimes are saved.
        self.assertEqual(p.get('root.txt')._ctime, p1.get('root.txt')._ctime)
        self.assertEqual(p.get('root.txt')._mtime, p1.get('root.txt')._mtime)
Пример #3
0
    def test_load(self):
        # Given
        vixen = Vixen()

        # When
        vixen.load()

        # Then
        self.assertEqual(len(vixen.projects), 1)
        self.assertEqual(vixen.projects[0].name, '__hidden__')

        # When
        p = Project(
            name='test', path=self.root,
            description='desc', extensions=['.py', '.txt']
        )
        p.scan()
        p.save()
        vixen.add(p)

        # Then
        self.assertEqual(len(vixen.projects), 1)
        self.assertEqual(vixen.projects[0].name, 'test')

        # Given
        vixen.save()
        vixen = Vixen()
        vixen.load()

        # Then
        self.assertEqual(len(vixen.projects), 1)
        p = vixen.projects[0]
        self.assertEqual(p.name, 'test')
        self.assertEqual(p.number_of_files, 0)

        # When
        p.load()

        # Then
        self.assertEqual(p.number_of_files, 5)
        m = p.get('root.txt')
        self.assertEqual(m.relpath, 'root.txt')
        self.assertEqual(m.type, 'text')
        self.assertEqual(len(m.tags), 1)