Example #1
0
    def test_import_csv_fails_with_bad_csv_header(self):
        # Given
        p = Project(name='test', path=self.root)
        p.scan()
        data = dedent(u"""\
        /blah/blah,1
        """)
        csv = self._write_csv(data)

        # When
        success, err = p.import_csv(csv)

        # Then
        self.assertFalse(success)

        # Given
        data = dedent(u"""\
        relpath,fox
        root.txt,1
        """)
        csv = self._write_csv(data)

        # When
        success, err = p.import_csv(csv)

        # Then
        self.assertFalse(success)
Example #2
0
    def test_import_csv_works(self):
        # Given
        p = Project(name='test', path=self.root)
        p.add_tags([TagInfo(name='fox', type='int')])
        p.scan()
        data = dedent(u"""\
        path,fox,junk
        %s,2,hello
        %s,1,bye
        """ % (join(self.root, 'root.txt'), join(self.root, 'hello.py')))
        csv = self._write_csv(data)

        # Get one of the paths to see if cached media are handled correctly.
        self.assertEqual(p.get('root.txt').tags['fox'], 0)

        # When
        success, err = p.import_csv(csv)

        # Then
        self.assertTrue(success)
        self.assertEqual(p.get('root.txt').tags['fox'], 2)
        self.assertEqual(p.get('hello.py').tags['fox'], 1)