diff --git a/.gitattributes b/.gitattributes index 9225f153e54b86dd361ca3e0f512023703b53074..d9143fe3ea1e16b9f4d5fe07e8ff8bf0b0dcd7b7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4234,7 +4234,6 @@ SAS/Feedback_Service/src/fb_data_44883.txt -text SAS/LSMR/CMakeLists.txt -text SAS/LSMR/bin/CMakeLists.txt -text SAS/LSMR/bin/lsmr -text -SAS/LSMR/requirements.txt -text SAS/LSMR/src/CMakeLists.txt -text SAS/LSMR/src/lsmr/CMakeLists.txt -text SAS/LSMR/src/lsmr/__init__.py -text @@ -4242,6 +4241,7 @@ SAS/LSMR/src/lsmr/lsmrapp/CMakeLists.txt -text SAS/LSMR/src/lsmr/lsmrapp/__init__.py -text SAS/LSMR/src/lsmr/lsmrapp/admin.py -text SAS/LSMR/src/lsmr/lsmrapp/apps.py -text +SAS/LSMR/src/lsmr/lsmrapp/migrations/0001_initial.py -text SAS/LSMR/src/lsmr/lsmrapp/migrations/__init__.py -text SAS/LSMR/src/lsmr/lsmrapp/models.py -text SAS/LSMR/src/lsmr/lsmrapp/tests.py -text @@ -4251,6 +4251,12 @@ SAS/LSMR/src/lsmr/urls.py -text SAS/LSMR/src/lsmr/wsgi.py -text SAS/LSMR/src/manage.py -text SAS/LSMR/test/CMakeLists.txt -text +SAS/LSMR/test/t_functional.py -text +SAS/LSMR/test/t_functional.run -text +SAS/LSMR/test/t_functional.sh -text +SAS/LSMR/test/t_lsmrapp_models.py -text +SAS/LSMR/test/t_lsmrapp_models.run -text +SAS/LSMR/test/t_lsmrapp_models.sh -text SAS/MoM/CMakeLists.txt -text SAS/MoM/MoMQueryService/CMakeLists.txt -text SAS/MoM/MoMQueryService/MoMQueryServiceClient/CMakeLists.txt -text diff --git a/CMake/LofarPackageList.cmake b/CMake/LofarPackageList.cmake index ce394cfeda3a4d9488d1b7f1042d8fd7fc42d1cd..9097d8c7bbcf29ffd3c2867199d06cf70d68432a 100644 --- a/CMake/LofarPackageList.cmake +++ b/CMake/LofarPackageList.cmake @@ -1,7 +1,7 @@ # - Create for each LOFAR package a variable containing the absolute path to # its source directory. # -# Generated by gen_LofarPackageList_cmake.sh at Fr 8. Jun 15:16:51 CEST 2018 +# Generated by gen_LofarPackageList_cmake.sh at Mo 11. Jun 16:21:43 CEST 2018 # # ---- DO NOT EDIT ---- # diff --git a/SAS/LSMR/bin/lsmr b/SAS/LSMR/bin/lsmr index 6ee38285d302001c44fd4c3bc828bf30a4e9c6c3..9a173d903d97ed27c8f218cb3a460b2e56993ece 100644 --- a/SAS/LSMR/bin/lsmr +++ b/SAS/LSMR/bin/lsmr @@ -23,7 +23,22 @@ echo "---" echo "! This is for testing only, properly deploy in Nginx or Apache for production use!" echo "---" + + +# Parse args: + +PORT=8000 +while getopts p: option +do +case "${option}" +in +p) PORT=${OPTARG};; +esac +done + +echo "Using port $PORT" + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" /usr/bin/python $DIR/../lib*/python3.4/site-packages/lofar/sas/lsmr/manage.py migrate -/usr/bin/python $DIR/../lib*/python3.4/site-packages/lofar/sas/lsmr/manage.py runserver 0.0.0.0:8000 +/usr/bin/python $DIR/../lib*/python3.4/site-packages/lofar/sas/lsmr/manage.py runserver 0.0.0.0:$PORT diff --git a/SAS/LSMR/requirements.txt b/SAS/LSMR/requirements.txt deleted file mode 100644 index fc272c36bb99dd18d2cdb50d16c33f43beb055ac..0000000000000000000000000000000000000000 --- a/SAS/LSMR/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -Django 2.0.5 -djangorestframework -markdown -django-filter diff --git a/SAS/LSMR/src/CMakeLists.txt b/SAS/LSMR/src/CMakeLists.txt index b294cfc6e56f2d0f5cf0de578145fd53b7b92dfa..2a8ba7ee5f80972e8c8bd67a47d2424b6cba1481 100644 --- a/SAS/LSMR/src/CMakeLists.txt +++ b/SAS/LSMR/src/CMakeLists.txt @@ -4,6 +4,8 @@ include(FindPythonModule) find_python_module(django REQUIRED) find_python_module(rest_framework REQUIRED) # pip install djangorestframework find_python_module(ldap REQUIRED) +find_python_module(markdown REQUIRED) +# find_python_module(django-filter REQUIRED) # FIXME: not detected set(_py_files manage.py diff --git a/SAS/LSMR/src/lsmr/lsmrapp/migrations/0001_initial.py b/SAS/LSMR/src/lsmr/lsmrapp/migrations/0001_initial.py new file mode 100644 index 0000000000000000000000000000000000000000..9983921379f68923aa8d52839d28b5afa17f9f80 --- /dev/null +++ b/SAS/LSMR/src/lsmr/lsmrapp/migrations/0001_initial.py @@ -0,0 +1,14 @@ +# Generated by Django 2.0.6 on 2018-06-11 08:56 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ] + + operations = [ + # Add things like triggers to the database here: + # migrations.RunSQL('RAW SQL CODE') + ] diff --git a/SAS/LSMR/test/CMakeLists.txt b/SAS/LSMR/test/CMakeLists.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..fe52fb69feda2284bdc9ea37a1659aa48c639fc7 100644 --- a/SAS/LSMR/test/CMakeLists.txt +++ b/SAS/LSMR/test/CMakeLists.txt @@ -0,0 +1,9 @@ +include(LofarCTest) +include(FindPythonModule) + +find_python_module(mock REQUIRED) +find_python_module(requests REQUIRED) +find_python_module(selenium REQUIRED) + +lofar_add_test(t_lsmrapp_models) +lofar_add_test(t_functional) diff --git a/SAS/LSMR/test/t_functional.py b/SAS/LSMR/test/t_functional.py new file mode 100644 index 0000000000000000000000000000000000000000..389c15121509a1f576e446aed45d4db2b43363b7 --- /dev/null +++ b/SAS/LSMR/test/t_functional.py @@ -0,0 +1,40 @@ +#!/usr/bin/python + +# Copyright (C) 2018 ASTRON (Netherlands Institute for Radio Astronomy) +# P.O. Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This file is part of the LOFAR software suite. +# The LOFAR software suite is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# The LOFAR software suite is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. + +# $Id: $ + +import unittest +import requests + +BASE_URL = 'http://localhost:8000' + +class BasicFunctionTestCase(unittest.TestCase): + + def setUp(self): + pass + + def test_welcome_page(self): + r = requests.get(BASE_URL) + self.assertEqual(r.status_code, 200) + self.assertTrue("The install worked successfully! Congratulations!" in r.content.decode('utf8')) + + +if __name__ == "__main__": + unittest.main() + diff --git a/SAS/LSMR/test/t_functional.run b/SAS/LSMR/test/t_functional.run new file mode 100644 index 0000000000000000000000000000000000000000..18b24ca1b440cd313906e1640da0f98310bde052 --- /dev/null +++ b/SAS/LSMR/test/t_functional.run @@ -0,0 +1,20 @@ +#!/bin/sh + + +# Run Django test instance +PORT=8000 +lsmr -p $PORT & +PID=$! +echo "Started server with PID: " $PID +sleep 3 + +# Run test +./t_functional.py +EXITCODE=$? + +# Kill Django test instance +pkill -f "lofar/sas/lsmr/manage.py runserver 0.0.0.0:$PORT" +kill $PID + +# Return with success or failure of actual test +exit $EXITCODE diff --git a/SAS/LSMR/test/t_functional.sh b/SAS/LSMR/test/t_functional.sh new file mode 100644 index 0000000000000000000000000000000000000000..d668e09aaa7835103417085be0658092abaefe4b --- /dev/null +++ b/SAS/LSMR/test/t_functional.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +# Run Test +./runctest.sh t_functional + diff --git a/SAS/LSMR/test/t_lsmrapp_models.py b/SAS/LSMR/test/t_lsmrapp_models.py new file mode 100644 index 0000000000000000000000000000000000000000..3047dfea392fa64aaeaee604f88d7317390e4491 --- /dev/null +++ b/SAS/LSMR/test/t_lsmrapp_models.py @@ -0,0 +1,40 @@ +#!/usr/bin/python + +# Copyright (C) 2018 ASTRON (Netherlands Institute for Radio Astronomy) +# P.O. Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This file is part of the LOFAR software suite. +# The LOFAR software suite is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# The LOFAR software suite is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. + +# $Id: $ + +import rest_framework.test +from lofar.sas.lsmr.lsmr.lsmrapp.models import * + +client = rest_framework.test.APIClient() + + +class MyModelTestTest(rest_framework.test.APITestCase): + + # todo: populate db + def setUp(self): + # mymodel.objects.create(...) + pass + + # todo: add bunch of tests + def test_GET_something(self): + response = client.get('/get/something/', format='json', follow=True) + self.assertEqual(response.status_code, 404) + #self.assertEqual(response.data, {'id': 42, 'some':'thing'}) + diff --git a/SAS/LSMR/test/t_lsmrapp_models.run b/SAS/LSMR/test/t_lsmrapp_models.run new file mode 100755 index 0000000000000000000000000000000000000000..98e04b3e8febcbc502007bc587b168e839c2f5f7 --- /dev/null +++ b/SAS/LSMR/test/t_lsmrapp_models.run @@ -0,0 +1,3 @@ +#!/bin/sh + +$LOFARROOT/lib/python3.4/site-packages/lofar/sas/lsmr/manage.py test --keepdb --pattern="t_lsmrapp_models.py" diff --git a/SAS/LSMR/test/t_lsmrapp_models.sh b/SAS/LSMR/test/t_lsmrapp_models.sh new file mode 100755 index 0000000000000000000000000000000000000000..213c159c963ec7a63d63e9a731c59548768502f1 --- /dev/null +++ b/SAS/LSMR/test/t_lsmrapp_models.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +./runctest.sh t_lsmrapp_models