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):
def kind(self):
if self.url is None and self.file.name is None:
return None
if self.url is not '' and self.url is not None:
return 'url'
else:
if self.file.name is not None:
return 'file'
else:
return 'url'
def representative(self, import_data):
"""
......
......@@ -134,6 +134,7 @@ class ImporterTest(TestCase):
importer.file = 'a'
importer.url = ''
self.assertEqual(importer.kind(), 'file')
importer.file = None
importer.url = 'http://www.example.com/'
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