Commit 2e15dcc4 authored by Roy de Goei's avatar Roy de Goei

TMSS-157: Set starting value of SubTask id to 2000000 to avoid overlap with current system.

parent f81a7d3b
......@@ -9,5 +9,7 @@ class Migration(migrations.Migration):
('tmssapp', '0001_initial'),
operations = [ migrations.RunPython(populate_choices),
# Start SubTask id with 2 000 000 to avoid overlap with 'old' (test/production) OTDB
operations = [ migrations.RunSQL('ALTER SEQUENCE tmssapp_SubTask_id_seq RESTART WITH 2000000;'),
  • Too bad its a SQL solution and that Django does not allow a different solution. All suggested solution on the internet look like hacks. The solution chosen seems to be the best out there at the moment.

Please register or sign in to reply
migrations.RunPython(populate_lofar_json_schemas) ]
......@@ -266,6 +266,9 @@ class SubtaskTestCase(unittest.TestCase):
r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask/', st_test_data, 201, st_test_data)
url = r_dict['url']
GET_and_assert_expected_response(self, url, 200, st_test_data)
# Check that SubTask id is larger than minimum value
  • Personally I try to avoid these types of comments in the code. Not because I'm against code comments, but because I see them as a last resort.

    Here I would use a variable with a descriptive name. Say minimum_id_value and set it to 2000000. Then the code reads after it reads like a story.

    self.assertGreaterEqual(subtask_id, minimum_id_value)

    Or maybe even more readable:

    self.assert(subtask_id > minimum_id_value)

  • I will change it. Note that the current code consist of a lot of number which "does not tell the story" so that should be changed as well to be consequent.

Please register or sign in to reply
subtask_id = url.split("subtask/")[1].replace("/","")
self.assertGreaterEqual(int(subtask_id), 2000000)
def test_subtask_PUT_invalid_raises_error(self):
st_test_data = test_data_creator.Subtask()
......@@ -25,7 +25,7 @@
"model": "tmssapp.subtask",
"pk": 2,
"pk": 2000002,
"fields" : {
"start_time": "2020-01-02T00:00:00",
"stop_time": "2020-01-02T12:00:00",
......@@ -45,7 +45,7 @@
"model": "tmssapp.subtask",
"pk": 3,
"pk": 2000003,
"fields" : {
"start_time": "2020-01-03T00:00:00",
"stop_time": "2020-01-03T12:00:00",
......@@ -65,7 +65,7 @@
"model": "tmssapp.subtask",
"pk": 4,
"pk": 2000004,
"fields" : {
"start_time": "2020-01-04T00:00:00",
"stop_time": "2020-01-04T12:00:00",
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment