Adds a test for logo validation
Added tests for new logo validation behaviour which restricts file type of the logo image uploaded. Also fix i18 import in package_base.py Closes-Bug: #1497257 Related-Bug: #1560547 Change-Id: I772e4b1fc56de86171938a536197b253a131645c
This commit is contained in:
parent
25f5cab6ad
commit
b92b7e6add
@ -22,6 +22,7 @@ import sys
|
|||||||
import semantic_version
|
import semantic_version
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
from murano.common.i18n import _
|
||||||
from murano.packages import exceptions
|
from murano.packages import exceptions
|
||||||
from murano.packages import package
|
from murano.packages import package
|
||||||
|
|
||||||
|
@ -27,12 +27,14 @@ from six.moves import range
|
|||||||
from murano.api.v1 import catalog
|
from murano.api.v1 import catalog
|
||||||
from murano.db.catalog import api as db_catalog_api
|
from murano.db.catalog import api as db_catalog_api
|
||||||
from murano.db import models
|
from murano.db import models
|
||||||
|
from murano.packages import exceptions
|
||||||
from murano.packages import load_utils
|
from murano.packages import load_utils
|
||||||
import murano.tests.unit.api.base as test_base
|
import murano.tests.unit.api.base as test_base
|
||||||
import murano.tests.unit.utils as test_utils
|
import murano.tests.unit.utils as test_utils
|
||||||
|
|
||||||
|
|
||||||
class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
|
class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestCatalogApi, self).setUp()
|
super(TestCatalogApi, self).setUp()
|
||||||
self.controller = catalog.Controller()
|
self.controller = catalog.Controller()
|
||||||
@ -332,15 +334,15 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
|
|||||||
'/v1/catalog/packages/', params={'catalog': 'True'}))
|
'/v1/catalog/packages/', params={'catalog': 'True'}))
|
||||||
self.assertEqual(4, len(result['packages']))
|
self.assertEqual(4, len(result['packages']))
|
||||||
|
|
||||||
def _test_package(self):
|
def _test_package(self, manifest='manifest.yaml'):
|
||||||
package_dir = os.path.abspath(
|
package_dir = os.path.abspath(
|
||||||
os.path.join(
|
os.path.join(
|
||||||
__file__,
|
__file__,
|
||||||
'../../../packages/test_packages/test.mpl.v1.app'
|
'../../../packages/test_packages/test.mpl.v1.app',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
pkg = load_utils.load_from_dir(
|
pkg = load_utils.load_from_dir(
|
||||||
package_dir
|
package_dir, filename=manifest
|
||||||
)
|
)
|
||||||
package = {
|
package = {
|
||||||
'fully_qualified_name': pkg.full_name,
|
'fully_qualified_name': pkg.full_name,
|
||||||
@ -360,6 +362,10 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
|
|||||||
}
|
}
|
||||||
return pkg, package
|
return pkg, package
|
||||||
|
|
||||||
|
def test_not_valid_logo(self):
|
||||||
|
self.assertRaises(exceptions.PackageLoadError,
|
||||||
|
self._test_package, 'manifest_with_broken_logo.yaml')
|
||||||
|
|
||||||
def test_load_package_with_supplier_info(self):
|
def test_load_package_with_supplier_info(self):
|
||||||
self._set_policy_rules(
|
self._set_policy_rules(
|
||||||
{'get_package': '@'}
|
{'get_package': '@'}
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
Format: 1.0
|
||||||
|
Type: Application
|
||||||
|
FullName: test.mpl.v1.app
|
||||||
|
Description: Test V1 Application
|
||||||
|
Author: Test runner
|
||||||
|
Tags: [Linux]
|
||||||
|
Classes:
|
||||||
|
test.mpl.v1.app.Thing: Thing.yaml
|
||||||
|
Logo: test_logo.png.not_valid
|
||||||
|
UI: ui.yaml
|
||||||
|
Supplier:
|
||||||
|
Name: Supplier Name
|
||||||
|
CompanyUrl:
|
||||||
|
Text: Example Company
|
||||||
|
Link: http://example.com
|
||||||
|
Logo: test_supplier_logo.png
|
||||||
|
Summary: Company summary goes here
|
||||||
|
Description: Marked up company description goes here
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user