Commit c3984fb3 authored by okhin's avatar okhin 🚴

Let's try to guess the file kind

parent e4250010
Pipeline #1238 failed with stage
in 3 seconds
...@@ -31,10 +31,10 @@ class Importer(models.Model): ...@@ -31,10 +31,10 @@ class Importer(models.Model):
def kind(self): def kind(self):
if self.url is None and self.file.name is None: if self.url is None and self.file.name is None:
return None return None
if self.url is not '' and self.url is not None: if self.file.name is not None:
return 'url'
else:
return 'file' return 'file'
else:
return 'url'
def representative(self, import_data): def representative(self, import_data):
""" """
......
...@@ -134,6 +134,7 @@ class ImporterTest(TestCase): ...@@ -134,6 +134,7 @@ class ImporterTest(TestCase):
importer.file = 'a' importer.file = 'a'
importer.url = '' importer.url = ''
self.assertEqual(importer.kind(), 'file') self.assertEqual(importer.kind(), 'file')
importer.file = None
importer.url = 'http://www.example.com/' importer.url = 'http://www.example.com/'
self.assertEqual(importer.kind(), 'url') self.assertEqual(importer.kind(), 'url')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment