Skip to content
Snippets Groups Projects
Commit 50d16441 authored by Jörn Künsemöller's avatar Jörn Künsemöller
Browse files

TMSS-482: Add tests for DynamicRelationalHyperlinkesModelSerializer

parent 7b96ddce
No related branches found
No related tags found
1 merge request!316Resolve TMSS-526
......@@ -33,11 +33,12 @@ if(BUILD_TESTING)
lofar_add_test(t_tasks)
lofar_add_test(t_scheduling)
lofar_add_test(t_conversions)
lofar_add_test(t_complex_serializers)
# To get ctest running
file(COPY testdata DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(t_scheduling PROPERTIES TIMEOUT 300)
set_tests_properties(t_tmssapp_scheduling_REST_API PROPERTIES TIMEOUT 300)
set_tests_properties(t_tmssapp_specification_REST_API PROPERTIES TIMEOUT 360)
set_tests_properties(t_tmssapp_specification_REST_API PROPERTIES TIMEOUT 600)
endif()
#!/usr/bin/env python3
# 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: $
from datetime import datetime
import unittest
import logging
logger = logging.getLogger(__name__)
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO)
from lofar.common.test_utils import skip_integration_tests
if skip_integration_tests():
exit(3)
# Do Mandatory setup step:
# use setup/teardown magic for tmss test database, ldap server and django server
# (ignore pycharm unused import statement, python unittests does use at RunTime the tmss_test_environment_unittest_setup module)
from lofar.sas.tmss.test.tmss_test_environment_unittest_setup import *
from lofar.sas.tmss.test.tmss_test_data_django_models import *
# import and setup test data creator
from lofar.sas.tmss.test.tmss_test_data_rest import TMSSRESTTestDataCreator
test_data_creator = TMSSRESTTestDataCreator(BASE_URL, AUTH)
class DynamicRelationalHyperlinkedModelSerializerTestCase(test.TestCase):
@classmethod
def setUpClass(cls) -> None:
# create some connected objects
cls.td_url = test_data_creator.post_data_and_get_url(test_data_creator.TaskDraft(), '/task_draft/')
cls.tb_url = test_data_creator.post_data_and_get_url(test_data_creator.TaskBlueprint(draft_url=cls.td_url), '/task_blueprint/')
test_data_creator.post_data_and_get_url(test_data_creator.Subtask(task_blueprint_url=cls.tb_url), '/subtask/')
def test_GET_task_draft_serializes_to_depth_0_by_default(self):
r = GET_and_assert_equal_expected_code(self, self.td_url, 200)
self.assertIn('specifications_doc', r)
self.assertNotIn('specifications_doc', r['task_blueprints'][0])
def test_GET_task_draft_serializes_to_specified_depth(self):
r = GET_and_assert_equal_expected_code(self, self.td_url + '?depth=0', 200)
self.assertIn('specifications_doc', r)
self.assertNotIn('specifications_doc', r['task_blueprints'][0])
r = GET_and_assert_equal_expected_code(self, self.td_url + '?depth=1', 200)
self.assertIn('specifications_doc', r['task_blueprints'][0])
self.assertNotIn('requirements_doc', r['task_blueprints'][0]['scheduling_unit_blueprint'])
r = GET_and_assert_equal_expected_code(self, self.td_url + '?depth=2', 200)
self.assertIn('requirements_doc', r['task_blueprints'][0]['scheduling_unit_blueprint'])
if __name__ == "__main__":
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
level=logging.INFO)
unittest.main()
#!/bin/bash
# Run the unit test
source python-coverage.sh
python_coverage_test "*tmss*" t_complex_serializers.py
#!/bin/sh
./runctest.sh t_scheduling
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment