def test_requirements(self, mock_services): """Check that requirements are returned.""" m = mock.MagicMock() m.base_fields = { 'flavor': mock.MagicMock(requirements={ 'min_disk': 10, 'min_vcpus': 2, 'min_memory_mb': 2048 }) } mock_services.get_app_forms.return_value = [('', m)] app = mock.MagicMock() app.id = 1 group = tabs.ApplicationTabs(self.request, application=app) r = group.get_tabs()[1] # Should return the requirements list used by the template file. r._get_requirements() self.assertIn('Instance flavor:', r.app.requirements) flavor_req = r.app.requirements[1] self.assertIn('Minimum disk size: 10GB', flavor_req) self.assertIn('Minimum vCPUs: 2', flavor_req) self.assertIn('Minimum RAM size: 2048MB', flavor_req)
def test_no_requirements(self, mock_services): """Check that no requirements are returned.""" m = mock.MagicMock() m.base_fields = {} mock_services.get_app_forms.return_value = [('', m)] app = mock.MagicMock() app.id = 1 group = tabs.ApplicationTabs(self.request, application=app) r = group.get_tabs()[1] # Should return an empty requirements list r._get_requirements() self.assertListEqual([], r.app.requirements)
def test_no_license(self, mock_services): """Check that no license is returned.""" # Fake the services.get_app_forms() call. m = mock.MagicMock() m.base_fields = {} mock_services.get_app_forms.return_value = [('', m)] # Fake an application object, needed when instantiating tabs. app = mock.MagicMock() app.id = 1 group = tabs.ApplicationTabs(self.request, application=app) l = group.get_tabs()[2] # Should return the license description l._get_license() self.assertEqual('', l.app.license)
def test_license(self, mock_services): """Check that a license is returned.""" # Fake the services.get_app_forms() call. m = mock.MagicMock() m.base_fields = { 'license': mock.MagicMock(description='Lorem ipsum dolor sit ' 'amet, consectetur adipiscing elit.') } mock_services.get_app_forms.return_value = [('', m)] # Fake an application object, needed when instantiating tabs. app = mock.MagicMock() app.id = 1 group = tabs.ApplicationTabs(self.request, application=app) l = group.get_tabs()[2] # Should return the license description l._get_license() self.assertEqual( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', l.app.license)