versions: has_files
This commit is contained in:
Родитель
84f8ac8bb5
Коммит
ca56c84c5b
|
@ -46,6 +46,10 @@ class Version(amo.models.ModelBase):
|
|||
"""Get a list of supported platform names."""
|
||||
return list(set(f.platform.name for f in self.files.all()))
|
||||
|
||||
@amo.cached_property
|
||||
def has_files(self):
|
||||
return bool(self.files.count())
|
||||
|
||||
|
||||
class License(amo.models.ModelBase):
|
||||
"""
|
||||
|
|
|
@ -47,6 +47,13 @@ class TestVersion(test.TestCase):
|
|||
eq_(v.minor2, None)
|
||||
eq_(v.minor3, None)
|
||||
|
||||
def test_has_files(self):
|
||||
v = Version.objects.get(pk=24007)
|
||||
assert v.has_files, 'Version with files not recognized.'
|
||||
|
||||
v = Version.objects.get(pk=2)
|
||||
assert not v.has_files, 'Version without files not recognized.'
|
||||
|
||||
|
||||
class TestLicense(test.TestCase):
|
||||
"""Test built-in as well as custom licenses."""
|
||||
|
|
Загрузка…
Ссылка в новой задаче