From f8907f0c4fc0ba4bb97a1d636a50c5b40c2642f2 Mon Sep 17 00:00:00 2001 From: Edan Binshtok Date: Wed, 4 Oct 2017 09:33:23 +0300 Subject: Initial seed Initial upload of django test framework Change-Id: I643a7f4efc52cfafe4cc6d92e3178f36a0c1837c Issue-Id: VVP-1 Signed-off-by: Edan Binshtok --- iceci/__init__.py | 38 ++++ iceci/__init__.pyc | Bin 0 -> 137 bytes iceci/__pycache__/__init__.cpython-36.pyc | Bin 0 -> 133 bytes iceci/__pycache__/admin.cpython-36.pyc | Bin 0 -> 1942 bytes iceci/__pycache__/apps.cpython-36.pyc | Bin 0 -> 347 bytes iceci/__pycache__/mail.cpython-36.pyc | Bin 0 -> 4890 bytes iceci/__pycache__/models.cpython-36.pyc | Bin 0 -> 1002 bytes iceci/__pycache__/serializers.cpython-36.pyc | Bin 0 -> 1557 bytes iceci/__pycache__/urls.cpython-36.pyc | Bin 0 -> 510 bytes iceci/__pycache__/views.cpython-36.pyc | Bin 0 -> 6513 bytes iceci/admin.py | 123 +++++++++++ iceci/admin.pyc | Bin 0 -> 2637 bytes iceci/apps.py | 43 ++++ iceci/apps.pyc | Bin 0 -> 414 bytes iceci/decorator/__init__.py | 38 ++++ iceci/decorator/__init__.pyc | Bin 0 -> 147 bytes .../decorator/__pycache__/__init__.cpython-36.pyc | Bin 0 -> 143 bytes .../__pycache__/exception_decor.cpython-36.pyc | Bin 0 -> 995 bytes .../__pycache__/logFuncEntry.cpython-36.pyc | Bin 0 -> 1402 bytes iceci/decorator/exception_decor.py | 70 ++++++ iceci/decorator/logFuncEntry.py | 75 +++++++ iceci/decorator/logFuncEntry.pyc | Bin 0 -> 1760 bytes iceci/decorator/repeat.py | 49 +++++ iceci/mail.py | 173 +++++++++++++++ iceci/mail.pyc | Bin 0 -> 5239 bytes iceci/migrations/0001_initial.py | 73 ++++++ iceci/migrations/0001_initial.pyc | Bin 0 -> 1379 bytes iceci/migrations/0002_auto_20160728_1111.py | 64 ++++++ iceci/migrations/0002_auto_20160728_1111.pyc | Bin 0 -> 1006 bytes iceci/migrations/0003_auto_20160914_1004.py | 57 +++++ iceci/migrations/0003_auto_20160914_1004.pyc | Bin 0 -> 843 bytes iceci/migrations/0004_testresults_build_id.py | 58 +++++ iceci/migrations/0004_testresults_build_id.pyc | Bin 0 -> 887 bytes iceci/migrations/0005_auto_20161219_0619.py | 64 ++++++ iceci/migrations/__init__.py | 38 ++++ iceci/migrations/__init__.pyc | Bin 0 -> 148 bytes .../__pycache__/0001_initial.cpython-36.pyc | Bin 0 -> 1070 bytes .../0002_auto_20160728_1111.cpython-36.pyc | Bin 0 -> 781 bytes .../0003_auto_20160914_1004.cpython-36.pyc | Bin 0 -> 635 bytes .../0004_testresults_build_id.cpython-36.pyc | Bin 0 -> 670 bytes .../0005_auto_20161219_0619.cpython-36.pyc | Bin 0 -> 779 bytes .../migrations/__pycache__/__init__.cpython-36.pyc | Bin 0 -> 144 bytes iceci/models.py | 55 +++++ iceci/models.pyc | Bin 0 -> 1282 bytes iceci/serializers.py | 63 ++++++ iceci/serializers.pyc | Bin 0 -> 2052 bytes iceci/urls.py | 48 ++++ iceci/urls.pyc | Bin 0 -> 631 bytes iceci/views.py | 245 +++++++++++++++++++++ iceci/views.pyc | Bin 0 -> 8136 bytes 50 files changed, 1374 insertions(+) create mode 100644 iceci/__init__.py create mode 100644 iceci/__init__.pyc create mode 100644 iceci/__pycache__/__init__.cpython-36.pyc create mode 100644 iceci/__pycache__/admin.cpython-36.pyc create mode 100644 iceci/__pycache__/apps.cpython-36.pyc create mode 100644 iceci/__pycache__/mail.cpython-36.pyc create mode 100644 iceci/__pycache__/models.cpython-36.pyc create mode 100644 iceci/__pycache__/serializers.cpython-36.pyc create mode 100644 iceci/__pycache__/urls.cpython-36.pyc create mode 100644 iceci/__pycache__/views.cpython-36.pyc create mode 100644 iceci/admin.py create mode 100644 iceci/admin.pyc create mode 100644 iceci/apps.py create mode 100644 iceci/apps.pyc create mode 100644 iceci/decorator/__init__.py create mode 100644 iceci/decorator/__init__.pyc create mode 100644 iceci/decorator/__pycache__/__init__.cpython-36.pyc create mode 100644 iceci/decorator/__pycache__/exception_decor.cpython-36.pyc create mode 100644 iceci/decorator/__pycache__/logFuncEntry.cpython-36.pyc create mode 100644 iceci/decorator/exception_decor.py create mode 100644 iceci/decorator/logFuncEntry.py create mode 100644 iceci/decorator/logFuncEntry.pyc create mode 100644 iceci/decorator/repeat.py create mode 100644 iceci/mail.py create mode 100755 iceci/mail.pyc create mode 100644 iceci/migrations/0001_initial.py create mode 100755 iceci/migrations/0001_initial.pyc create mode 100644 iceci/migrations/0002_auto_20160728_1111.py create mode 100755 iceci/migrations/0002_auto_20160728_1111.pyc create mode 100644 iceci/migrations/0003_auto_20160914_1004.py create mode 100755 iceci/migrations/0003_auto_20160914_1004.pyc create mode 100644 iceci/migrations/0004_testresults_build_id.py create mode 100755 iceci/migrations/0004_testresults_build_id.pyc create mode 100644 iceci/migrations/0005_auto_20161219_0619.py create mode 100644 iceci/migrations/__init__.py create mode 100755 iceci/migrations/__init__.pyc create mode 100644 iceci/migrations/__pycache__/0001_initial.cpython-36.pyc create mode 100644 iceci/migrations/__pycache__/0002_auto_20160728_1111.cpython-36.pyc create mode 100644 iceci/migrations/__pycache__/0003_auto_20160914_1004.cpython-36.pyc create mode 100644 iceci/migrations/__pycache__/0004_testresults_build_id.cpython-36.pyc create mode 100644 iceci/migrations/__pycache__/0005_auto_20161219_0619.cpython-36.pyc create mode 100644 iceci/migrations/__pycache__/__init__.cpython-36.pyc create mode 100644 iceci/models.py create mode 100644 iceci/models.pyc create mode 100644 iceci/serializers.py create mode 100755 iceci/serializers.pyc create mode 100644 iceci/urls.py create mode 100755 iceci/urls.pyc create mode 100644 iceci/views.py create mode 100755 iceci/views.pyc (limited to 'iceci') diff --git a/iceci/__init__.py b/iceci/__init__.py new file mode 100644 index 0000000..30d7152 --- /dev/null +++ b/iceci/__init__.py @@ -0,0 +1,38 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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. diff --git a/iceci/__init__.pyc b/iceci/__init__.pyc new file mode 100644 index 0000000..fba9dad Binary files /dev/null and b/iceci/__init__.pyc differ diff --git a/iceci/__pycache__/__init__.cpython-36.pyc b/iceci/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..9858793 Binary files /dev/null and b/iceci/__pycache__/__init__.cpython-36.pyc differ diff --git a/iceci/__pycache__/admin.cpython-36.pyc b/iceci/__pycache__/admin.cpython-36.pyc new file mode 100644 index 0000000..3a59b92 Binary files /dev/null and b/iceci/__pycache__/admin.cpython-36.pyc differ diff --git a/iceci/__pycache__/apps.cpython-36.pyc b/iceci/__pycache__/apps.cpython-36.pyc new file mode 100644 index 0000000..c7a5706 Binary files /dev/null and b/iceci/__pycache__/apps.cpython-36.pyc differ diff --git a/iceci/__pycache__/mail.cpython-36.pyc b/iceci/__pycache__/mail.cpython-36.pyc new file mode 100644 index 0000000..3804d3d Binary files /dev/null and b/iceci/__pycache__/mail.cpython-36.pyc differ diff --git a/iceci/__pycache__/models.cpython-36.pyc b/iceci/__pycache__/models.cpython-36.pyc new file mode 100644 index 0000000..7c18f6a Binary files /dev/null and b/iceci/__pycache__/models.cpython-36.pyc differ diff --git a/iceci/__pycache__/serializers.cpython-36.pyc b/iceci/__pycache__/serializers.cpython-36.pyc new file mode 100644 index 0000000..48dc607 Binary files /dev/null and b/iceci/__pycache__/serializers.cpython-36.pyc differ diff --git a/iceci/__pycache__/urls.cpython-36.pyc b/iceci/__pycache__/urls.cpython-36.pyc new file mode 100644 index 0000000..ce7e0b3 Binary files /dev/null and b/iceci/__pycache__/urls.cpython-36.pyc differ diff --git a/iceci/__pycache__/views.cpython-36.pyc b/iceci/__pycache__/views.cpython-36.pyc new file mode 100644 index 0000000..3713997 Binary files /dev/null and b/iceci/__pycache__/views.cpython-36.pyc differ diff --git a/iceci/admin.py b/iceci/admin.py new file mode 100644 index 0000000..21d8f3a --- /dev/null +++ b/iceci/admin.py @@ -0,0 +1,123 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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 django.contrib import admin +from .models import TestResults +from django.conf import settings + + +def export_csv(modeladmin, request, queryset): + import csv +# import xlwt + from django.utils.encoding import smart_str + from django.http import HttpResponse + response = HttpResponse(content_type='text/csv') + response['Content-Disposition'] = 'attachment; filename=ci_Test_Results.csv' + writer = csv.writer(response, csv.excel) + # BOM (optional...Excel needs it to open UTF-8 file properly) + response.write(u'\ufeff'.encode('utf8')) + writer.writerow([ + smart_str(u"testType"), + smart_str(u"testFeature"), + smart_str(u"testName"), + smart_str(u"testResult"), + smart_str(u"notes"), + smart_str(u"duration"), + smart_str(u"build_id"), + smart_str(u"create_time"), + ]) + + total_counter = 0 + fail_counter = 0 + pass_counter = 0 + for obj in queryset: + total_counter += 1 + if obj.testResult == 'FAIL': + fail_counter += 1 + elif obj.testResult == 'PASS': + pass_counter += 1 + + writer.writerow([ + smart_str(obj.testType), + smart_str(obj.testFeature), + smart_str(obj.testName), + smart_str(obj.testResult), + smart_str(obj.notes), + smart_str(obj.duration), + smart_str(obj.build_id), + smart_str(obj.create_time), + ]) + # calsl evaluation + evaultaion = as_percentage_of(pass_counter, total_counter) + # title + writer.writerow([ + smart_str(u"total_counter"), + smart_str(u"fail_counter"), + smart_str(u"pass_counter"), + smart_str(u"evaultaion"), + ]) + # values + writer.writerow([ + smart_str(total_counter), + smart_str(fail_counter), + smart_str(pass_counter), + smart_str(evaultaion), + ]) + + return response +# export_csv.short_description = u"Export CSV" ### Check this action meaning. + + +def as_percentage_of(part, whole): + try: + return "%d%%" % (float(part) / whole * 100) + except (ValueError, ZeroDivisionError): + return "" + + +@admin.register(TestResults) +class TestResultsModelAdmin(admin.ModelAdmin): + + list_display = ["testType", "testFeature", "testName", + "testResult", "notes", "duration", "build_id", "create_time"] + list_filter = ["testResult", "testType", "testFeature", + "testName", "notes", "duration", "build_id", "create_time"] + search_fields = ["testResult", "testType", "testFeature", "testName", + "notes", "duration", "build_id", "create_time"] + actions = [export_csv] + list_per_page = settings.NUMBER_OF_TEST_RESULTS diff --git a/iceci/admin.pyc b/iceci/admin.pyc new file mode 100644 index 0000000..c047436 Binary files /dev/null and b/iceci/admin.pyc differ diff --git a/iceci/apps.py b/iceci/apps.py new file mode 100644 index 0000000..1e33154 --- /dev/null +++ b/iceci/apps.py @@ -0,0 +1,43 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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 django.apps import AppConfig + + +class IceCiConfig(AppConfig): + name = 'iceci' diff --git a/iceci/apps.pyc b/iceci/apps.pyc new file mode 100644 index 0000000..40ff960 Binary files /dev/null and b/iceci/apps.pyc differ diff --git a/iceci/decorator/__init__.py b/iceci/decorator/__init__.py new file mode 100644 index 0000000..30d7152 --- /dev/null +++ b/iceci/decorator/__init__.py @@ -0,0 +1,38 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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. diff --git a/iceci/decorator/__init__.pyc b/iceci/decorator/__init__.pyc new file mode 100644 index 0000000..46251cd Binary files /dev/null and b/iceci/decorator/__init__.pyc differ diff --git a/iceci/decorator/__pycache__/__init__.cpython-36.pyc b/iceci/decorator/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..1c87097 Binary files /dev/null and b/iceci/decorator/__pycache__/__init__.cpython-36.pyc differ diff --git a/iceci/decorator/__pycache__/exception_decor.cpython-36.pyc b/iceci/decorator/__pycache__/exception_decor.cpython-36.pyc new file mode 100644 index 0000000..582fb86 Binary files /dev/null and b/iceci/decorator/__pycache__/exception_decor.cpython-36.pyc differ diff --git a/iceci/decorator/__pycache__/logFuncEntry.cpython-36.pyc b/iceci/decorator/__pycache__/logFuncEntry.cpython-36.pyc new file mode 100644 index 0000000..ce3d14f Binary files /dev/null and b/iceci/decorator/__pycache__/logFuncEntry.cpython-36.pyc differ diff --git a/iceci/decorator/exception_decor.py b/iceci/decorator/exception_decor.py new file mode 100644 index 0000000..467f2ce --- /dev/null +++ b/iceci/decorator/exception_decor.py @@ -0,0 +1,70 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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 logging +import traceback + +from services.logging_service import LoggingServiceFactory +from services.session import session + + +logger = LoggingServiceFactory.get_logger() + + +def exception(): + """ + A decorator that wraps the passed in function and logs + exceptions should one occur + + @param logger: The logging object + """ + + def decorator(func): + + def wrapper(*args, **kwargs): + try: + return func(*args, **kwargs) + except: + err = "There was an exception in %s" % func.__name__ + logger.error(err) + session.errorCounter += 1 + session.errorList = traceback.format_exc() + raise + + return wrapper + return decorator diff --git a/iceci/decorator/logFuncEntry.py b/iceci/decorator/logFuncEntry.py new file mode 100644 index 0000000..0995f3b --- /dev/null +++ b/iceci/decorator/logFuncEntry.py @@ -0,0 +1,75 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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 services.logging_service import LoggingServiceFactory +logger = LoggingServiceFactory.get_logger() + +def _aop(decorator): + '''This decorator can be used to turn simple functions + into well-behaved decorators, so long as the decorators + are fairly simple. If a decorator expects a function and + returns a function (no descriptors), and if it doesn't + modify function attributes or docstring, then it is + eligible to use this. Simply apply @_aop to + your decorator and it will automatically preserve the + docstring and function attributes of functions to which + it is applied.''' + def new_decorator(f): + g = decorator(f) + g.__name__ = f.__name__ + g.__doc__ = f.__doc__ + g.__dict__.update(f.__dict__) + return g + + # Now a few lines needed to make _aop itself + # be a well-behaved decorator. + new_decorator.__name__ = decorator.__name__ + new_decorator.__doc__ = decorator.__doc__ + new_decorator.__dict__.update(decorator.__dict__) + return new_decorator + +# +# Sample Use: +# +@_aop +def logFuncEntry(func): + def foo(*args, **kwargs): + logger.debug('calling {}'.format(func.__name__)+" | "+str(args)+" | "+str(kwargs)) + return func(*args, **kwargs) + return foo + diff --git a/iceci/decorator/logFuncEntry.pyc b/iceci/decorator/logFuncEntry.pyc new file mode 100644 index 0000000..541fede Binary files /dev/null and b/iceci/decorator/logFuncEntry.pyc differ diff --git a/iceci/decorator/repeat.py b/iceci/decorator/repeat.py new file mode 100644 index 0000000..38eac03 --- /dev/null +++ b/iceci/decorator/repeat.py @@ -0,0 +1,49 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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 unittest,time +def repeat(times): + def repeatHelper(f): + def callHelper(*args): + for i in range(0, times): + f(*args) + time.sleep(3) + return callHelper + time.sleep(3) + return repeatHelper + diff --git a/iceci/mail.py b/iceci/mail.py new file mode 100644 index 0000000..9f23b90 --- /dev/null +++ b/iceci/mail.py @@ -0,0 +1,173 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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. +################################################################################################## +''' +Created on Apr 20, 2016 + +@author: ya107f +''' +import socket +from string import Template +import traceback + +from django.conf import settings +from django.core.mail import send_mail +from django.utils import timezone + +from services.constants import Constants +from services.logging_service import LoggingServiceFactory + + +admin_mail_from = settings.ICE_CONTACT_FROM_ADDRESS +# lastBuild = "" +param = "1" +logger = LoggingServiceFactory.get_logger() + +def sendMail(param,email, data, mail_body, mail_subject, mail_from=admin_mail_from): + logger.debug("about to send mail to " + email) + + try: +# lastBuild = param + html_msg = mail_body.substitute(data) + mail_subject = mail_subject.substitute(data) + #send mail with template + send_mail(mail_subject, '', Constants.FEGeneral.ProgramName.name +"-CI Report Test Team <" + mail_from + ">",settings.ICE_CONTACT_EMAILS , fail_silently=False, html_message=html_msg) + logger.debug("Looks like email delivery to "+email+" has succeeded") + except Exception: + traceback.print_exc() + raise + +########################## +# For Contact Request # +########################## +lastBuild= param +dt = timezone.now().strftime("%Y-%m-%d %H:%M:%S") +#envIP = str(socket.gethostbyname(socket.gethostname())) +envIP = str(socket.gethostname()) +testsResults_mail_subject = Template("""CI Testing results """+ str(dt)) +testsResults_mail_to = settings.ICE_CONTACT_EMAILS +testsResults_mail_body = Template(""" + + + CI Test Report + + + + Jenkins Link for Build +

Environment name : """+ settings.ICE_CI_ENVIRONMENT_NAME + """

+

Environment IP : """ + envIP + """

+

Tests summary

+ + + + + + + $paramData + +
+ +
+
+ + + + + + + + + + $statisticData + +
+ +
+
+ +
+
+ +
+
+ +
+
+ + + + + + + + + + + + + $allData + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + + +""") + diff --git a/iceci/mail.pyc b/iceci/mail.pyc new file mode 100755 index 0000000..025ee39 Binary files /dev/null and b/iceci/mail.pyc differ diff --git a/iceci/migrations/0001_initial.py b/iceci/migrations/0001_initial.py new file mode 100644 index 0000000..5441f12 --- /dev/null +++ b/iceci/migrations/0001_initial.py @@ -0,0 +1,73 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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. +# Generated by Django 1.9.7 on 2016-06-06 13:51 +from __future__ import unicode_literals + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='TestResults', + fields=[ + ('id', models.AutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('testType', models.CharField(max_length=64)), + ('testCaseName', models.CharField(max_length=64)), + ('testResult', models.CharField(max_length=64)), + ('testName', models.CharField(max_length=64)), + ('notes', models.TextField( + blank=True, max_length=1024, null=True)), + ('create_time', models.DateTimeField(default=datetime.datetime( + 2016, 6, 6, 16, 50, 59, 963000), verbose_name='creation time')), + ], + options={ + 'db_table': 'ice_test_results', + 'verbose_name_plural': 'Tests Results', + }, + ), + ] diff --git a/iceci/migrations/0001_initial.pyc b/iceci/migrations/0001_initial.pyc new file mode 100755 index 0000000..090a1ae Binary files /dev/null and b/iceci/migrations/0001_initial.pyc differ diff --git a/iceci/migrations/0002_auto_20160728_1111.py b/iceci/migrations/0002_auto_20160728_1111.py new file mode 100644 index 0000000..e8cdb00 --- /dev/null +++ b/iceci/migrations/0002_auto_20160728_1111.py @@ -0,0 +1,64 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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. +# Generated by Django 1.9.7 on 2016-07-28 08:11 +from __future__ import unicode_literals + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('iceci', '0001_initial'), + ] + + operations = [ + migrations.RenameField( + model_name='testresults', + old_name='testCaseName', + new_name='testFeature', + ), + migrations.AlterField( + model_name='testresults', + name='create_time', + field=models.DateTimeField( + default=datetime.datetime.now, verbose_name='creation time'), + ), + ] diff --git a/iceci/migrations/0002_auto_20160728_1111.pyc b/iceci/migrations/0002_auto_20160728_1111.pyc new file mode 100755 index 0000000..47ac6fd Binary files /dev/null and b/iceci/migrations/0002_auto_20160728_1111.pyc differ diff --git a/iceci/migrations/0003_auto_20160914_1004.py b/iceci/migrations/0003_auto_20160914_1004.py new file mode 100644 index 0000000..88a27df --- /dev/null +++ b/iceci/migrations/0003_auto_20160914_1004.py @@ -0,0 +1,57 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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. +# Generated by Django 1.9.7 on 2016-09-14 10:04 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('iceci', '0002_auto_20160728_1111'), + ] + + operations = [ + migrations.AlterField( + model_name='testresults', + name='notes', + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/iceci/migrations/0003_auto_20160914_1004.pyc b/iceci/migrations/0003_auto_20160914_1004.pyc new file mode 100755 index 0000000..308df71 Binary files /dev/null and b/iceci/migrations/0003_auto_20160914_1004.pyc differ diff --git a/iceci/migrations/0004_testresults_build_id.py b/iceci/migrations/0004_testresults_build_id.py new file mode 100644 index 0000000..d4ba634 --- /dev/null +++ b/iceci/migrations/0004_testresults_build_id.py @@ -0,0 +1,58 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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. +# Generated by Django 1.9.7 on 2016-09-26 13:25 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('iceci', '0003_auto_20160914_1004'), + ] + + operations = [ + migrations.AddField( + model_name='testresults', + name='build_id', + field=models.TextField( + blank=True, default=b'2016,09,26,25,41', null=True), + ), + ] diff --git a/iceci/migrations/0004_testresults_build_id.pyc b/iceci/migrations/0004_testresults_build_id.pyc new file mode 100755 index 0000000..bd87590 Binary files /dev/null and b/iceci/migrations/0004_testresults_build_id.pyc differ diff --git a/iceci/migrations/0005_auto_20161219_0619.py b/iceci/migrations/0005_auto_20161219_0619.py new file mode 100644 index 0000000..ad12901 --- /dev/null +++ b/iceci/migrations/0005_auto_20161219_0619.py @@ -0,0 +1,64 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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. +# Generated by Django 1.9.7 on 2016-12-19 06:19 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('iceci', '0004_testresults_build_id'), + ] + + operations = [ + migrations.AddField( + model_name='testresults', + name='duration', + field=models.CharField(default='000', max_length=64), + preserve_default=False, + ), + migrations.AlterField( + model_name='testresults', + name='build_id', + field=models.TextField( + blank=True, default=b'2016-12-19-14-18-40', null=True), + ), + ] diff --git a/iceci/migrations/__init__.py b/iceci/migrations/__init__.py new file mode 100644 index 0000000..30d7152 --- /dev/null +++ b/iceci/migrations/__init__.py @@ -0,0 +1,38 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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. diff --git a/iceci/migrations/__init__.pyc b/iceci/migrations/__init__.pyc new file mode 100755 index 0000000..3c41b4c Binary files /dev/null and b/iceci/migrations/__init__.pyc differ diff --git a/iceci/migrations/__pycache__/0001_initial.cpython-36.pyc b/iceci/migrations/__pycache__/0001_initial.cpython-36.pyc new file mode 100644 index 0000000..a1976ee Binary files /dev/null and b/iceci/migrations/__pycache__/0001_initial.cpython-36.pyc differ diff --git a/iceci/migrations/__pycache__/0002_auto_20160728_1111.cpython-36.pyc b/iceci/migrations/__pycache__/0002_auto_20160728_1111.cpython-36.pyc new file mode 100644 index 0000000..f147368 Binary files /dev/null and b/iceci/migrations/__pycache__/0002_auto_20160728_1111.cpython-36.pyc differ diff --git a/iceci/migrations/__pycache__/0003_auto_20160914_1004.cpython-36.pyc b/iceci/migrations/__pycache__/0003_auto_20160914_1004.cpython-36.pyc new file mode 100644 index 0000000..ed2d2ee Binary files /dev/null and b/iceci/migrations/__pycache__/0003_auto_20160914_1004.cpython-36.pyc differ diff --git a/iceci/migrations/__pycache__/0004_testresults_build_id.cpython-36.pyc b/iceci/migrations/__pycache__/0004_testresults_build_id.cpython-36.pyc new file mode 100644 index 0000000..9a9c0a8 Binary files /dev/null and b/iceci/migrations/__pycache__/0004_testresults_build_id.cpython-36.pyc differ diff --git a/iceci/migrations/__pycache__/0005_auto_20161219_0619.cpython-36.pyc b/iceci/migrations/__pycache__/0005_auto_20161219_0619.cpython-36.pyc new file mode 100644 index 0000000..fcdb7b6 Binary files /dev/null and b/iceci/migrations/__pycache__/0005_auto_20161219_0619.cpython-36.pyc differ diff --git a/iceci/migrations/__pycache__/__init__.cpython-36.pyc b/iceci/migrations/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..dfabfb8 Binary files /dev/null and b/iceci/migrations/__pycache__/__init__.cpython-36.pyc differ diff --git a/iceci/models.py b/iceci/models.py new file mode 100644 index 0000000..a448eb4 --- /dev/null +++ b/iceci/models.py @@ -0,0 +1,55 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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 __future__ import unicode_literals +from django.db import models +import datetime +from django.conf import settings + +class TestResults(models.Model): + testType = models.CharField(max_length=64) + testFeature = models.CharField(max_length=64) + testName = models.CharField(max_length=64) + testResult = models.CharField(max_length=64) + notes = models.TextField(null=True, blank=True) + duration = models.CharField(max_length=64) + build_id = models.TextField(null=True, blank=True,default=settings.ICE_BUILD_REPORT_NUM) + create_time = models.DateTimeField('creation time', default=datetime.datetime.now) + class Meta: + db_table = "ice_test_results" + verbose_name_plural = 'Tests Results' diff --git a/iceci/models.pyc b/iceci/models.pyc new file mode 100644 index 0000000..b61dae6 Binary files /dev/null and b/iceci/models.pyc differ diff --git a/iceci/serializers.py b/iceci/serializers.py new file mode 100644 index 0000000..b597c10 --- /dev/null +++ b/iceci/serializers.py @@ -0,0 +1,63 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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 rest_framework import serializers +from .models import TestResults + +class TestResultsModelSerializer(serializers.ModelSerializer): + class Meta: + model = TestResults + fields = ('testType', 'testFeature', 'testName', 'testResult', 'notes', 'create_time',) + +class TestResultsSerializer(serializers.Serializer): + class Meta: + model = TestResults + fields = ('testType', 'testFeature', 'testName', 'testResult', 'notes', 'create_time',) + + def create(self, validated_data): + return TestResults(**validated_data) + + def update(self, instance, validated_data): + instance.testType = validated_data.get('testType', instance.testType) + instance.testFeature = validated_data.get('testFeature', instance.testFeature) + instance.testName = validated_data.get('testName', instance.testName) + instance.testResult = validated_data.get('testResult', instance.testResult) + instance.notes = validated_data.get('notes', instance.notes) + instance.duration = validated_data.get('duration', instance.duration) + instance.create_time = validated_data.get('create_time', instance.create_time) + return instance diff --git a/iceci/serializers.pyc b/iceci/serializers.pyc new file mode 100755 index 0000000..de41aa6 Binary files /dev/null and b/iceci/serializers.pyc differ diff --git a/iceci/urls.py b/iceci/urls.py new file mode 100644 index 0000000..baf47d2 --- /dev/null +++ b/iceci/urls.py @@ -0,0 +1,48 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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 django.conf.urls import url +from . import views + +urlpatterns = [ + url(r'^testresults/?$', views.testResult_list), + url(r'^testresults/(?P.*)$', views.testResult_detail), + url(r'^testresultstomail/(?P.*)$', views.testResult_list_to_mail), + url(r'^testresultstohtml/(?P.*)$', views.testResult_list_to_html_file), + url(r'^testresultstr/(?P.*)$', views.testResultStr) +] diff --git a/iceci/urls.pyc b/iceci/urls.pyc new file mode 100755 index 0000000..fae3472 Binary files /dev/null and b/iceci/urls.pyc differ diff --git a/iceci/views.py b/iceci/views.py new file mode 100644 index 0000000..7e0505d --- /dev/null +++ b/iceci/views.py @@ -0,0 +1,245 @@ + +# ============LICENSE_START========================================== +# org.onap.vvp/test-engine +# =================================================================== +# 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 logging +from string import Template + +from django.conf import settings +from django.http import HttpResponse +from django.views.decorators.csrf import csrf_exempt +from rest_framework.parsers import JSONParser +from rest_framework.renderers import JSONRenderer + +from iceci import mail +from iceci.mail import testsResults_mail_body +from services.constants import Constants +from services.logging_service import LoggingServiceFactory + +from .models import TestResults +from .serializers import TestResultsModelSerializer + + +LAST_BUILD_REPORT_NUM = None +# from django.core.mail import send_mail +# from . import mail +logger = LoggingServiceFactory.get_logger() + +def index(request): + return HttpResponse("Hello, world. You're at the "+Constants.FEGeneral.ProgramName.name+" ci index.") + +@csrf_exempt +def testResult_list(request): # List all tests, or create a new test. + if (request.method == 'DELETE' or request.method == 'PUT'): + return HttpResponse(status=405) + + if request.method == 'GET': + testResult = TestResults.objects.all() + serializer = TestResultsModelSerializer(testResult, many=True) + return JSONResponse(serializer.data) + + elif request.method == 'POST': + data = JSONParser().parse(request) + serializer = TestResultsModelSerializer(data=data) + if serializer.is_valid(): + serializer.save() + return JSONResponse(serializer.data, status=201) + return JSONResponse(serializer.errors, status=400) +@csrf_exempt +def testResultStr(request,param): # List all tests, or create a new test. + try: + testResults = TestResults.objects.filter(build_id=param) + pass_counter, total_counter, statisticData, fail_counter = strReportForTestResults(testResults) + evaultaion = as_percentage_of(pass_counter, total_counter) + except Exception as e: + msg = "Something went wrong while trying to send Test Results " + str(e) + return HttpResponse(msg, status=500) + + msg = "Total Tests: " + str(total_counter) +" Pass Tests: " + str(pass_counter)+" Fail Tests: "+ str(fail_counter) + " Statistics : " + str(evaultaion) + " BUILD_REPORT_NUM : "+str(param) + return HttpResponse(msg, status=200) + +@csrf_exempt +def testResult_detail(request, param): # Retrieve, update or delete a test. + if request.method == 'POST': + return HttpResponse(status=405) + + param = param.strip("/") + + try: + testResult = TestResults.objects.get(name=param) + except TestResults.DoesNotExist: + return HttpResponse(status=404) + + if request.method == 'GET': + serializer = TestResultsModelSerializer(testResult) + return JSONResponse(serializer.data) + + elif request.method == 'PUT': + data = JSONParser().parse(request) + serializer = TestResultsModelSerializer(testResult, data=data) + if serializer.is_valid(): + serializer.save() + return JSONResponse(serializer.data) + return JSONResponse(serializer.errors, status=400) + + elif request.method == 'DELETE': + testResult.delete() + return HttpResponse(status=204) + +#=============================================================================== +# def testResult_post_action(request, data): +# +# logger.debug("about to send mail to " + data['email']) +# +# html_msg = mail.mail_body.substitute(data) +# #send mail with template +# send_mail(mail.mail_subject, +# '', +# mail.mail_from, +# mail.mail_to, +# fail_silently=False, +# html_message=html_msg) +#=============================================================================== +def createHtmlStrReportForTestResults(testResults): + total_counter = 0 + fail_counter = 0 + pass_counter = 0 + statisticData = "" + str2 = "" + "@Total" + "@Pass" + "@Fail" + "@Evaultaion" + "" + paramData = "" + str3 = "" + "@Version" + "" + allData = "" + str = "" + "@TestType" + "@TestFeature" + "@TestName" + "@TestResult" + "@Notes" + "@Creation_time" + "" + for res in testResults: # testResults + allData += str.replace("@TestType", str(res.testType)).replace("@TestFeature", str(res.testFeature)).replace("@TestName", str(res.testName)).replace("@TestResult", str(res.testResult)).replace("@Notes", str(res.notes)).replace("@Creation_time", str(res.create_time)) + total_counter += 1 + if (res.testResult == "PASS"): + pass_counter += 1 + else: + fail_counter += 1 + + return pass_counter, total_counter, statisticData, str2, fail_counter, paramData, str3, allData + +def strReportForTestResults(testResults): + total_counter = 0 + fail_counter = 0 + pass_counter = 0 + statisticData = "" + for res in testResults: # testResults + total_counter += 1 + if (res.testResult == "PASS"): + pass_counter += 1 + else: + fail_counter += 1 + + return pass_counter, total_counter, statisticData, fail_counter + +@csrf_exempt +def testResult_list_to_mail(request,param): # List all tests, or create a new test. + if (request.method == 'DELETE' or request.method == 'PUT' or request.method == 'POST'): + return HttpResponse(status=405) + + data = dict() + + print("BUILD_REPORT_NUM = "+settings.ICE_BUILD_REPORT_NUM) + + testResults = TestResults.objects.filter(build_id=param) + + pass_counter, total_counter, statisticData, str2, fail_counter, paramData, str3, allData = createHtmlStrReportForTestResults(testResults) + + evaultaion = as_percentage_of(pass_counter, total_counter) + statisticData += str2.replace("@Total", str(total_counter)).replace("@Pass", str(pass_counter)).replace("@Fail", str(fail_counter)).replace("@Evaultaion", str(evaultaion)) + paramData += str3.replace("@Version", str(param)) + data['email'] = "rgafiulin@interwise.com" + data['allData'] = str(allData) + data['statisticData'] = str(statisticData) + data['paramData'] = str(paramData) + + mail.testsResults_mail_to = data['email'] + try: + mail.sendMail(param,data['email'], data, mail.testsResults_mail_body, mail.testsResults_mail_subject) + except Exception as e: + msg = "Something went wrong while trying to send Test Report mail to " + data['email'] + str(e) + return HttpResponse(msg, status=500) + + serializer = TestResultsModelSerializer(testResults, many=True) + return JSONResponse(serializer.data) + +@csrf_exempt +def testResult_list_to_html_file(request,param): + if (request.method == 'DELETE' or request.method == 'PUT' or request.method == 'POST'): + return HttpResponse(status=405) + + data = dict() + + print("BUILD_REPORT_NUM = "+settings.ICE_BUILD_REPORT_NUM) + + testResults = TestResults.objects.filter(build_id=settings.ICE_BUILD_REPORT_NUM) + + pass_counter, total_counter, statisticData, str2, fail_counter, paramData, str3, allData = createHtmlStrReportForTestResults(testResults) + + evaultaion = as_percentage_of(pass_counter, total_counter) + statisticData += str2.replace("@Total", str(total_counter)).replace("@Pass", str(pass_counter)).replace("@Fail", str(fail_counter)).replace("@Evaultaion", str(evaultaion)) + paramData += str3.replace("@Version", str(param)) + + data['allData'] = str(allData) + data['statisticData'] = str(statisticData) + data['paramData'] = str(paramData) + + html_msg = testsResults_mail_body.substitute(data) + fileName = settings.LOGS_PATH+"Test_Results_"+settings.ICE_BUILD_REPORT_NUM+".html" + try: + with open(fileName, "w") as text_file: + text_file.write(html_msg) + except Exception as e: + msg = "Something went wrong while trying to write the tet results to html file " +fileName +" "+ str(e) + return HttpResponse(msg, status=500) + + serializer = TestResultsModelSerializer(testResults, many=True) + return JSONResponse(serializer.data) + +def as_percentage_of(part, whole): + try: + return "%d%%" % (float(part) / whole * 100) + except (ValueError, ZeroDivisionError): + return "" + +class JSONResponse(HttpResponse): # An HttpResponse that renders its content into JSON. + def __init__(self, data, **kwargs): + content = JSONRenderer().render(data) + kwargs['content_type'] = 'application/json' + super(JSONResponse, self).__init__(content, **kwargs) diff --git a/iceci/views.pyc b/iceci/views.pyc new file mode 100755 index 0000000..2ba7576 Binary files /dev/null and b/iceci/views.pyc differ -- cgit 1.2.3-korg