Exemplo n.º 1
0
 def test_read_title_tsv(self):
     i = 0
     with TsvReader('tsvimporter/tests/data/test.title.basics.tsv') as tsv:
         self.assertListEqual(tsv.columns, TITLE_DATA['columns'])
         for row in tsv.readline():
             self.assertListEqual(row, TITLE_DATA['rows'][i])
             i += 1
Exemplo n.º 2
0
 def test_read_name_tsv_in_gzip(self):
     i = 0
     with TsvReader('tsvimporter/tests/data/test.name.basics.tsv.gz') as tsv:
         self.assertListEqual(tsv.columns, NAME_DATA['columns'])
         for row in tsv.readline():
             self.assertListEqual(row, NAME_DATA['rows'][i])
             i += 1
Exemplo n.º 3
0
 def handle(self, *args, **options):
     for path in options['path']:
         with TsvReader(path) as tsv:
             if 'primaryTitle' in tsv.columns:
                 serializer = TitlesSerializer
             if 'primaryName' in tsv.columns:
                 serializer = NamesSerializer
             self.save_to_db(tsv, serializer)
Exemplo n.º 4
0
 def test_open_wrong_extension(self):
     with self.assertRaises(ValueError):
         with TsvReader('s') as tsv:
             print(tsv)
Exemplo n.º 5
0
 def test_opening_non_existing_file_rises_error(self):
     with self.assertRaises(FileNotFoundError):
         with TsvReader('non-existing-file.tsv.gz') as tsv:
             print(tsv)