diff options
author | 2017-10-18 08:11:04 +0300 | |
---|---|---|
committer | 2017-10-18 08:11:04 +0300 | |
commit | cd415e1759feab6f7edcb0f6a33839d3ace702c0 (patch) | |
tree | 0769d5eb711297b421baaa7a715be71ebcbba7e5 | |
parent | edecc0a9872c712d0796037c21409efa8e37cd71 (diff) |
Update tox and tests
Addd code coverage test
Add Tox and maven docker
Issue Id: VVP-28
Change-Id: I7d89802cc269c064d992f84019ee758ca0981920
Signed-off-by: Edan Binshtok <eb578m@intl.att.com>
l--------- | django/cms/settings/__init__.py | 8 | ||||
-rw-r--r-- | django/cms/tests/__init__.py | 0 | ||||
-rw-r--r-- | django/cms/tests/test_base_entity.py | 68 | ||||
-rw-r--r-- | django/cms/tests/test_import_cetgories_command.py | 76 | ||||
-rw-r--r-- | django/cms/tests/test_import_pages_command.py | 60 | ||||
-rw-r--r-- | django/cms/tests/test_page_service.py | 106 | ||||
-rw-r--r-- | django/requirements.txt | 1 | ||||
-rw-r--r-- | pom.xml | 8 |
8 files changed, 316 insertions, 11 deletions
diff --git a/django/cms/settings/__init__.py b/django/cms/settings/__init__.py index df52f04..0e19472 120000 --- a/django/cms/settings/__init__.py +++ b/django/cms/settings/__init__.py @@ -1,7 +1 @@ -# Settings file for VVP CMS -# -# You should arrange to overwrite this file, -# with one containing settings for your environment. -# -# In Kubernetes, for example, this means mount a configMap, -# volume to /srv/settings containing, settings in the file __init__.py. +/opt/configmaps/settings/__init__.py
\ No newline at end of file diff --git a/django/cms/tests/__init__.py b/django/cms/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/django/cms/tests/__init__.py diff --git a/django/cms/tests/test_base_entity.py b/django/cms/tests/test_base_entity.py new file mode 100644 index 0000000..028ec3b --- /dev/null +++ b/django/cms/tests/test_base_entity.py @@ -0,0 +1,68 @@ +# +# ============LICENSE_START========================================== +# org.onap.vvp/engagementmgr +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +from abc import ABCMeta, abstractmethod +import http.client +import django +from django.test import TestCase +from django.test.client import Client +django.setup() + + +class TestBaseEntity(TestCase): + __metaclass__ = ABCMeta + + def setUp(self): + self.urlPrefix = "/api/" + self.conn = http.client.HTTPConnection("127.0.0.1", 8000) + self.c = Client() + self.childSetup() + + def tearDown(self): + self.conn.close() + + @abstractmethod + def childSetup(self): + pass + + def console_print(self, msg): + print("======================= " + "log from test " + "=======================") + print(msg) + print("_____________________________________________________________") diff --git a/django/cms/tests/test_import_cetgories_command.py b/django/cms/tests/test_import_cetgories_command.py new file mode 100644 index 0000000..676286e --- /dev/null +++ b/django/cms/tests/test_import_cetgories_command.py @@ -0,0 +1,76 @@ +# +# ============LICENSE_START========================================== +# org.onap.vvp/engagementmgr +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +from mezzanine.blog.models import BlogCategory +from cms.management.commands import import_categories +from cms.tests.test_base_entity import TestBaseEntity + + +class ImportCategoriesCommandTestCase(TestBaseEntity): + + def childSetup(self): + print("======================= " + "ImportCategoriesCommandTestCase " + "=======================") + import_categories_command = import_categories.Command() + import_categories_command.handle() + self.console_print("command ran successfully") + + def testNewsCategoryCreatedByCommand(self): + news_title = "News" + news_category = \ + BlogCategory.objects.get(title=news_title) + + self.assertTrue(news_category is not None) + self.assertEqual(news_category.title, news_title) + + def testAnnouncementCategoryCreatedByCommand(self): + announcement_title = "Announcement" + announcement_category = \ + BlogCategory.objects.get(title=announcement_title) + + self.assertTrue(announcement_category is not None) + self.assertEqual(announcement_category.title, announcement_title) + + def testFAQCategoryCreatedByCommand(self): + faq_title = "FAQ" + faq_category = \ + BlogCategory.objects.get(title=faq_title) + + self.assertTrue(faq_category is not None) + self.assertEqual(faq_category.title, faq_title) diff --git a/django/cms/tests/test_import_pages_command.py b/django/cms/tests/test_import_pages_command.py new file mode 100644 index 0000000..02ce91a --- /dev/null +++ b/django/cms/tests/test_import_pages_command.py @@ -0,0 +1,60 @@ +# +# ============LICENSE_START========================================== +# org.onap.vvp/engagementmgr +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +from mezzanine.pages.models import RichTextPage +from cms.management.commands import import_pages +from cms.tests.test_base_entity import TestBaseEntity + + +class ImportPagesCommandTestCase(TestBaseEntity): + + def childSetup(self): + print("======================= " + "ImportPagesCommandTestCase " + "=======================") + import_pages_command = import_pages.Command() + import_pages_command.handle() + self.console_print("command ran successfully") + + def testDocumentationPageCreatedByCommand(self): + documentation_title = "Documentation" + documentation_page = \ + RichTextPage.objects.get(title=documentation_title) + + self.assertTrue(documentation_page is not None) + self.assertEqual(documentation_page.title, documentation_title) diff --git a/django/cms/tests/test_page_service.py b/django/cms/tests/test_page_service.py new file mode 100644 index 0000000..bc64036 --- /dev/null +++ b/django/cms/tests/test_page_service.py @@ -0,0 +1,106 @@ +# +# ============LICENSE_START========================================== +# org.onap.vvp/engagementmgr +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +import json + +from mezzanine.pages.models import RichTextPage + +from cms.management.commands import import_pages +from cms.tests.test_base_entity import TestBaseEntity + + +class PageServiceTestCase(TestBaseEntity): + + def childSetup(self): + print("======================= " + "PageServiceTestCase " + "=======================") + import_pages_command = import_pages.Command() + import_pages_command.handle() + + self.documentation_page = \ + RichTextPage.objects.get(title="Documentation") + self.base_page_content = "baseContentOfPage" + self.base_page_title = "baseTitle" + self.search_url = self.urlPrefix + 'pages/search/?keyword={keyword}' + + page = RichTextPage.objects.get_or_create( + title=self.base_page_title, + defaults={ + 'content': self.base_page_content, + 'login_required': False} + ) + print("Created basic page under documentation page:%s" % page[0].title) + + def testSearchPageByContent(self): + response = self.c.get(self.search_url + .format(keyword=self.base_page_content)) + + self.assertEqual(response.status_code, 200) + self.console_print("Got 200 status from server, page search success") + content = json.loads(response.content) + + self.assertEqual(len(content), 1) + self.console_print("There is exactly one page that answers this query") + self.assertEqual(content[0]['title'], self.base_page_title) + self.console_print("The page is the requested one, test pass") + + def testSearchPageByTitle(self): + response = self.c.get(self.search_url + .format(keyword=self.base_page_title)) + + self.assertEqual(response.status_code, 200) + self.console_print("Got 200 status from server, page search success") + content = json.loads(response.content) + + self.assertEqual(len(content), 1) + self.console_print("There is exactly one page that answers this query") + self.assertEqual(content[0]['title'], self.base_page_title) + self.console_print("The page is the requested one, test pass") + + def testSearchNotExistedPage(self): + response = self.c.get(self.search_url + .format(keyword="pageNotExists")) + + self.assertEqual(response.status_code, 200) + self.console_print("Got 200 status from server, page search success") + content = json.loads(response.content) + + self.assertEqual(len(content), 0) + self.console_print("There is no page that answers this query, " + "test pass") diff --git a/django/requirements.txt b/django/requirements.txt index 8a00ac1..872b253 100644 --- a/django/requirements.txt +++ b/django/requirements.txt @@ -36,6 +36,7 @@ # # ECOMP is a trademark and service mark of AT&T Intellectual Property. Django==1.10.6 +djangorestframework==3.6.4 Mezzanine==4.2.3 git+https://github.com/att-innovate/mezzanine-api.git@master psycopg2 @@ -7,8 +7,8 @@ <version>1.0.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.vvp.cms</groupId> - <artifactId>cms</artifactId> + <groupId>org.openecomp.vvp</groupId> + <artifactId>vvp-cms</artifactId> <packaging>pom</packaging> <version>1.0.0-SNAPSHOT</version> <name>vvp-cms</name> @@ -47,7 +47,7 @@ <registry>nexus3.onap.org:10003</registry> <images> <image> - <name>openecomp/vvp/cms</name> + <name>openecomp/vvp-cms</name> <alias>vvp-cms</alias> <build> <cleanup>true</cleanup> @@ -88,7 +88,7 @@ <goal>push</goal> </goals> <configuration> - <image>openecomp/vvp/cms</image> + <image>openecomp/vvp-cms</image> </configuration> </execution> </executions> |