From c082535d4adc9539f5adb7bb25a5f65f9fb0cccb Mon Sep 17 00:00:00 2001 From: inadequate777 Date: Mon, 4 May 2026 09:45:58 +0000 Subject: [PATCH 01/16] updated color fields for takwrapper display --- src/dba/models/TaskWrapperDisplay.php | 15 ++++++++++++++- src/dba/models/TaskWrapperDisplayFactory.php | 4 ++-- src/migrations/mysql/20260413140000_task-view.sql | 2 +- .../postgres/20260413140000_task-view.sql | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/dba/models/TaskWrapperDisplay.php b/src/dba/models/TaskWrapperDisplay.php index 18ebdee3e..98e8b17f1 100644 --- a/src/dba/models/TaskWrapperDisplay.php +++ b/src/dba/models/TaskWrapperDisplay.php @@ -17,6 +17,7 @@ class TaskWrapperDisplay extends AbstractModel { private ?int $cracked; private ?int $taskId; private ?string $taskName; + private ?string $color; private ?string $attackCmd; private ?int $chunkTime; private ?int $statusTimer; @@ -35,7 +36,7 @@ class TaskWrapperDisplay extends AbstractModel { private ?string $hashTypeDescription; private ?string $groupName; - function __construct(?int $taskWrapperId, ?int $taskWrapperPriority, ?int $taskWrapperMaxAgents, ?int $taskType, ?int $hashlistId, ?int $accessGroupId, ?string $taskWrapperName, ?string $displayName, ?int $taskWrapperIsArchived, ?int $cracked, ?int $taskId, ?string $taskName, ?string $attackCmd, ?int $chunkTime, ?int $statusTimer, ?int $keyspace, ?int $keyspaceProgress, ?int $taskPriority, ?int $taskMaxAgents, ?int $isSmall, ?int $isCpuTask, ?int $taskIsArchived, ?int $taskUsePreprocessor, ?string $hashlistName, ?int $hashCount, ?int $hashlistCracked, ?int $hashTypeId, ?string $hashTypeDescription, ?string $groupName) { + function __construct(?int $taskWrapperId, ?int $taskWrapperPriority, ?int $taskWrapperMaxAgents, ?int $taskType, ?int $hashlistId, ?int $accessGroupId, ?string $taskWrapperName, ?string $displayName, ?int $taskWrapperIsArchived, ?int $cracked, ?int $taskId, ?string $taskName, ?string $color, ?string $attackCmd, ?int $chunkTime, ?int $statusTimer, ?int $keyspace, ?int $keyspaceProgress, ?int $taskPriority, ?int $taskMaxAgents, ?int $isSmall, ?int $isCpuTask, ?int $taskIsArchived, ?int $taskUsePreprocessor, ?string $hashlistName, ?int $hashCount, ?int $hashlistCracked, ?int $hashTypeId, ?string $hashTypeDescription, ?string $groupName) { $this->taskWrapperId = $taskWrapperId; $this->taskWrapperPriority = $taskWrapperPriority; $this->taskWrapperMaxAgents = $taskWrapperMaxAgents; @@ -48,6 +49,7 @@ function __construct(?int $taskWrapperId, ?int $taskWrapperPriority, ?int $taskW $this->cracked = $cracked; $this->taskId = $taskId; $this->taskName = $taskName; + $this->color = $color; $this->attackCmd = $attackCmd; $this->chunkTime = $chunkTime; $this->statusTimer = $statusTimer; @@ -81,6 +83,7 @@ function getKeyValueDict(): array { $dict['cracked'] = $this->cracked; $dict['taskId'] = $this->taskId; $dict['taskName'] = $this->taskName; + $dict['color'] = $this->color; $dict['attackCmd'] = $this->attackCmd; $dict['chunkTime'] = $this->chunkTime; $dict['statusTimer'] = $this->statusTimer; @@ -116,6 +119,7 @@ static function getFeatures(): array { $dict['cracked'] = ['read_only' => True, "type" => "int", "subtype" => "unset", "choices" => "unset", "null" => False, "pk" => False, "protected" => True, "private" => False, "alias" => "cracked", "public" => False, "dba_mapping" => False]; $dict['taskId'] = ['read_only' => True, "type" => "int", "subtype" => "unset", "choices" => "unset", "null" => False, "pk" => False, "protected" => True, "private" => False, "alias" => "taskId", "public" => False, "dba_mapping" => False]; $dict['taskName'] = ['read_only' => False, "type" => "str(256)", "subtype" => "unset", "choices" => "unset", "null" => False, "pk" => False, "protected" => False, "private" => False, "alias" => "taskName", "public" => False, "dba_mapping" => False]; + $dict['color'] = ['read_only' => False, "type" => "str(50)", "subtype" => "unset", "choices" => "unset", "null" => True, "pk" => False, "protected" => False, "private" => False, "alias" => "color", "public" => False, "dba_mapping" => False]; $dict['attackCmd'] = ['read_only' => False, "type" => "str(65535)", "subtype" => "unset", "choices" => "unset", "null" => False, "pk" => False, "protected" => False, "private" => False, "alias" => "attackCmd", "public" => False, "dba_mapping" => False]; $dict['chunkTime'] = ['read_only' => False, "type" => "int", "subtype" => "unset", "choices" => "unset", "null" => False, "pk" => False, "protected" => False, "private" => False, "alias" => "chunkTime", "public" => False, "dba_mapping" => False]; $dict['statusTimer'] = ['read_only' => False, "type" => "int", "subtype" => "unset", "choices" => "unset", "null" => False, "pk" => False, "protected" => False, "private" => False, "alias" => "statusTimer", "public" => False, "dba_mapping" => False]; @@ -249,6 +253,14 @@ function setTaskName(?string $taskName): void { $this->taskName = $taskName; } + function getColor(): ?string { + return $this->color; + } + + function setColor(?string $color): void { + $this->color = $color; + } + function getAttackCmd(): ?string { return $this->attackCmd; } @@ -397,6 +409,7 @@ function setGroupName(?string $groupName): void { const CRACKED = "cracked"; const TASK_ID = "taskId"; const TASK_NAME = "taskName"; + const COLOR = "color"; const ATTACK_CMD = "attackCmd"; const CHUNK_TIME = "chunkTime"; const STATUS_TIMER = "statusTimer"; diff --git a/src/dba/models/TaskWrapperDisplayFactory.php b/src/dba/models/TaskWrapperDisplayFactory.php index 50552a138..b32d0250f 100644 --- a/src/dba/models/TaskWrapperDisplayFactory.php +++ b/src/dba/models/TaskWrapperDisplayFactory.php @@ -30,7 +30,7 @@ function getCacheValidTime(): int { * @return TaskWrapperDisplay */ function getNullObject(): TaskWrapperDisplay { - return new TaskWrapperDisplay(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); + return new TaskWrapperDisplay(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); } /** @@ -44,7 +44,7 @@ function createObjectFromDict($pk, $dict): TaskWrapperDisplay { $conv[strtolower($key)] = $val; } $dict = $conv; - return new TaskWrapperDisplay($dict['taskwrapperid'], $dict['taskwrapperpriority'], $dict['taskwrappermaxagents'], $dict['tasktype'], $dict['hashlistid'], $dict['accessgroupid'], $dict['taskwrappername'], $dict['displayname'], $dict['taskwrapperisarchived'], $dict['cracked'], $dict['taskid'], $dict['taskname'], $dict['attackcmd'], $dict['chunktime'], $dict['statustimer'], $dict['keyspace'], $dict['keyspaceprogress'], $dict['taskpriority'], $dict['taskmaxagents'], $dict['issmall'], $dict['iscputask'], $dict['taskisarchived'], $dict['taskusepreprocessor'], $dict['hashlistname'], $dict['hashcount'], $dict['hashlistcracked'], $dict['hashtypeid'], $dict['hashtypedescription'], $dict['groupname']); + return new TaskWrapperDisplay($dict['taskwrapperid'], $dict['taskwrapperpriority'], $dict['taskwrappermaxagents'], $dict['tasktype'], $dict['hashlistid'], $dict['accessgroupid'], $dict['taskwrappername'], $dict['displayname'], $dict['taskwrapperisarchived'], $dict['cracked'], $dict['taskid'], $dict['taskname'], $dict['color'], $dict['attackcmd'], $dict['chunktime'], $dict['statustimer'], $dict['keyspace'], $dict['keyspaceprogress'], $dict['taskpriority'], $dict['taskmaxagents'], $dict['issmall'], $dict['iscputask'], $dict['taskisarchived'], $dict['taskusepreprocessor'], $dict['hashlistname'], $dict['hashcount'], $dict['hashlistcracked'], $dict['hashtypeid'], $dict['hashtypedescription'], $dict['groupname']); } /** diff --git a/src/migrations/mysql/20260413140000_task-view.sql b/src/migrations/mysql/20260413140000_task-view.sql index 6d0422f7d..e67efd677 100644 --- a/src/migrations/mysql/20260413140000_task-view.sql +++ b/src/migrations/mysql/20260413140000_task-view.sql @@ -2,7 +2,7 @@ CREATE VIEW TaskWrapperDisplay AS SELECT tw.taskWrapperId AS taskWrapperId, tw.priority AS taskWrapperPriority, tw.maxAgents AS taskWrapperMaxAgents, tw.taskType AS taskType, tw.hashlistId AS hashlistId, tw.accessGroupId AS accessGroupId, tw.taskWrapperName AS taskWrapperName, tw.isArchived AS taskWrapperIsArchived, tw.cracked AS cracked, - t.taskId AS taskId, t.taskName AS taskName, t.attackCmd AS attackCmd, t.chunkTime AS chunkTime, + t.taskId AS taskId, t.taskName AS taskName, t.color AS color, t.attackCmd AS attackCmd, t.chunkTime AS chunkTime, t.statusTimer AS statusTimer, t.keyspace AS keyspace, t.keyspaceProgress AS keyspaceProgress, t.priority AS taskPriority, t.maxAgents AS taskMaxAgents, t.isArchived AS taskIsArchived, t.isSmall AS isSmall, t.isCpuTask AS isCpuTask, t.usePreprocessor AS taskUsePreprocessor, diff --git a/src/migrations/postgres/20260413140000_task-view.sql b/src/migrations/postgres/20260413140000_task-view.sql index 6d0422f7d..e67efd677 100644 --- a/src/migrations/postgres/20260413140000_task-view.sql +++ b/src/migrations/postgres/20260413140000_task-view.sql @@ -2,7 +2,7 @@ CREATE VIEW TaskWrapperDisplay AS SELECT tw.taskWrapperId AS taskWrapperId, tw.priority AS taskWrapperPriority, tw.maxAgents AS taskWrapperMaxAgents, tw.taskType AS taskType, tw.hashlistId AS hashlistId, tw.accessGroupId AS accessGroupId, tw.taskWrapperName AS taskWrapperName, tw.isArchived AS taskWrapperIsArchived, tw.cracked AS cracked, - t.taskId AS taskId, t.taskName AS taskName, t.attackCmd AS attackCmd, t.chunkTime AS chunkTime, + t.taskId AS taskId, t.taskName AS taskName, t.color AS color, t.attackCmd AS attackCmd, t.chunkTime AS chunkTime, t.statusTimer AS statusTimer, t.keyspace AS keyspace, t.keyspaceProgress AS keyspaceProgress, t.priority AS taskPriority, t.maxAgents AS taskMaxAgents, t.isArchived AS taskIsArchived, t.isSmall AS isSmall, t.isCpuTask AS isCpuTask, t.usePreprocessor AS taskUsePreprocessor, From 091a385179ca3c51e825c9af1f55ca9df84393ba Mon Sep 17 00:00:00 2001 From: inadequate777 Date: Mon, 4 May 2026 10:00:49 +0000 Subject: [PATCH 02/16] added color field to generator.php --- src/dba/models/generator.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dba/models/generator.php b/src/dba/models/generator.php index f92957560..b8a032941 100644 --- a/src/dba/models/generator.php +++ b/src/dba/models/generator.php @@ -453,6 +453,7 @@ ['name' => 'cracked', 'read_only' => True, 'type' => 'int', 'protected' => True], ['name' => 'taskId', 'read_only' => True, 'type' => 'int', 'protected' => True], ['name' => 'taskName', 'read_only' => False, 'type' => 'str(256)'], + ['name' => 'color', 'read_only' => False, 'type' => 'str(50)', 'null' => True], ['name' => 'attackCmd', 'read_only' => False, 'type' => 'str(65535)'], ['name' => 'chunkTime', 'read_only' => False, 'type' => 'int'], ['name' => 'statusTimer', 'read_only' => False, 'type' => 'int'], From 87e44488d491e69142b086810ca1811b4a99aae3 Mon Sep 17 00:00:00 2001 From: inadequate777 Date: Tue, 5 May 2026 09:38:58 +0000 Subject: [PATCH 03/16] test for mock request Co-authored-by: Copilot --- ci/apiv2/test_taskwrapperdisplays.py | 69 ++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 ci/apiv2/test_taskwrapperdisplays.py diff --git a/ci/apiv2/test_taskwrapperdisplays.py b/ci/apiv2/test_taskwrapperdisplays.py new file mode 100644 index 000000000..ce0b72cc0 --- /dev/null +++ b/ci/apiv2/test_taskwrapperdisplays.py @@ -0,0 +1,69 @@ +import requests +from unittest.mock import patch, MagicMock + +from hashtopolis import HashtopolisConnector, HashtopolisConfig +from utils import BaseTest + + +class TaskWrapperDisplaysTest(BaseTest): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.config = HashtopolisConfig() + + def test_empty_body(self): + conn = HashtopolisConnector('/ui/taskwrapperdisplays', self.config) + conn.authenticate() + + headers = conn._headers + uri = conn._api_endpoint + conn._model_uri + + r = requests.get(uri, headers=headers) + values = r.json().get('jsonapi') + + self.assertGreaterEqual(len(values), 1) + @patch('requests.get') + @patch('requests.post') + def test_color(self, mock_post, mock_get): + mock_post_response = MagicMock() + mock_post_response.status_code = 201 + mock_post_response.headers = {'Content-Type': 'application/json'} + mock_post_response.text = '{"token": "fake-token", "token_expires": "never"}' + mock_post_response.json.return_value = { + 'token': 'fake-token', + 'token_expires': 'never' + } + mock_post.return_value = mock_post_response + + mock_response = MagicMock() + mock_response.status_code = 200 + mock_response.json.return_value = { + 'jsonapi': {'version': '1.1'}, + 'data': [ + { + 'attributes': { + 'color': '#913cce' + } + } + ] + } + mock_get.return_value = mock_response + + conn = HashtopolisConnector('/ui/taskwrapperdisplays', self.config) + conn.authenticate() + + headers = conn._headers + uri = conn._api_endpoint + conn._model_uri + + r = requests.get(uri, headers=headers) + response_json = r.json() + values = response_json.get('jsonapi') + color_value = None + data_items = response_json.get('data') or [] + if data_items: + color_value = data_items[0].get('attributes', {}).get('color') + + print(f"\nResponse status: {r.status_code}") + print(f"Color field value: {color_value}") + self.assertEqual(200, r.status_code) + self.assertEqual("#913cce", color_value) \ No newline at end of file From 00527bdab184916fc2242499fbcffa85c07c1bd9 Mon Sep 17 00:00:00 2001 From: inadequate777 Date: Tue, 5 May 2026 09:42:52 +0000 Subject: [PATCH 04/16] comment --- ci/apiv2/test_taskwrapperdisplays.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/apiv2/test_taskwrapperdisplays.py b/ci/apiv2/test_taskwrapperdisplays.py index ce0b72cc0..942646563 100644 --- a/ci/apiv2/test_taskwrapperdisplays.py +++ b/ci/apiv2/test_taskwrapperdisplays.py @@ -63,7 +63,7 @@ def test_color(self, mock_post, mock_get): if data_items: color_value = data_items[0].get('attributes', {}).get('color') - print(f"\nResponse status: {r.status_code}") - print(f"Color field value: {color_value}") + #print(f"\nResponse status: {r.status_code}") + #print(f"Color field value: {color_value}") self.assertEqual(200, r.status_code) self.assertEqual("#913cce", color_value) \ No newline at end of file From fbcd577650e8bff4936a9e075a097104bb6f971b Mon Sep 17 00:00:00 2001 From: inadequate777 Date: Tue, 5 May 2026 10:28:36 +0000 Subject: [PATCH 05/16] new test Co-authored-by: Copilot --- ci/apiv2/test_taskwrapperdisplays.py | 44 ++++++++-------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/ci/apiv2/test_taskwrapperdisplays.py b/ci/apiv2/test_taskwrapperdisplays.py index 942646563..1b2afa0ef 100644 --- a/ci/apiv2/test_taskwrapperdisplays.py +++ b/ci/apiv2/test_taskwrapperdisplays.py @@ -22,32 +22,10 @@ def test_empty_body(self): values = r.json().get('jsonapi') self.assertGreaterEqual(len(values), 1) - @patch('requests.get') - @patch('requests.post') - def test_color(self, mock_post, mock_get): - mock_post_response = MagicMock() - mock_post_response.status_code = 201 - mock_post_response.headers = {'Content-Type': 'application/json'} - mock_post_response.text = '{"token": "fake-token", "token_expires": "never"}' - mock_post_response.json.return_value = { - 'token': 'fake-token', - 'token_expires': 'never' - } - mock_post.return_value = mock_post_response - mock_response = MagicMock() - mock_response.status_code = 200 - mock_response.json.return_value = { - 'jsonapi': {'version': '1.1'}, - 'data': [ - { - 'attributes': { - 'color': '#913cce' - } - } - ] - } - mock_get.return_value = mock_response + def test_color(self): + hashlist = self.create_hashlist() + task = self.create_task(hashlist, extra_payload={'color': '#8000ff'}) conn = HashtopolisConnector('/ui/taskwrapperdisplays', self.config) conn.authenticate() @@ -56,14 +34,18 @@ def test_color(self, mock_post, mock_get): uri = conn._api_endpoint + conn._model_uri r = requests.get(uri, headers=headers) - response_json = r.json() - values = response_json.get('jsonapi') + values = r.json() + data_items = values.get('data') or [] + color_value = None - data_items = response_json.get('data') or [] - if data_items: - color_value = data_items[0].get('attributes', {}).get('color') + expected_id = str(task.taskWrapperId) + for item in data_items: + if str(item.get('id')) == expected_id: + color_value = item.get('attributes', {}).get('color') + break #print(f"\nResponse status: {r.status_code}") #print(f"Color field value: {color_value}") self.assertEqual(200, r.status_code) - self.assertEqual("#913cce", color_value) \ No newline at end of file + self.assertIsNotNone(color_value) + self.assertEqual("#8000ff", color_value) \ No newline at end of file From 3fbebdd8b42706e6b7ea11d45eb087dfcccab428 Mon Sep 17 00:00:00 2001 From: inadequate777 Date: Tue, 5 May 2026 12:24:54 +0000 Subject: [PATCH 06/16] added test for color and no color --- ci/apiv2/test_taskwrapperdisplays.py | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/ci/apiv2/test_taskwrapperdisplays.py b/ci/apiv2/test_taskwrapperdisplays.py index 1b2afa0ef..9c763f3cd 100644 --- a/ci/apiv2/test_taskwrapperdisplays.py +++ b/ci/apiv2/test_taskwrapperdisplays.py @@ -11,7 +11,9 @@ def setUpClass(cls): super().setUpClass() cls.config = HashtopolisConfig() - def test_empty_body(self): + def test_color(self): + hashlist = self.create_hashlist() + task = self.create_task(hashlist, extra_payload={'color': '#8000ff'}) conn = HashtopolisConnector('/ui/taskwrapperdisplays', self.config) conn.authenticate() @@ -19,14 +21,19 @@ def test_empty_body(self): uri = conn._api_endpoint + conn._model_uri r = requests.get(uri, headers=headers) - values = r.json().get('jsonapi') - - self.assertGreaterEqual(len(values), 1) + values = r.json() + data_items = values.get('data') or [] - def test_color(self): - hashlist = self.create_hashlist() - task = self.create_task(hashlist, extra_payload={'color': '#8000ff'}) + color_value = None + color_value = data_items[0].get('attributes', {}).get('color') + self.assertEqual(200, r.status_code) + self.assertIsNotNone(color_value) + self.assertEqual("#8000ff", color_value) + self.assertNotEqual("#ff0000", color_value) + def test_no_color(self): + hashlist = self.create_hashlist() + task = self.create_task(hashlist, extra_payload={'color': '#FFFFFF'}) conn = HashtopolisConnector('/ui/taskwrapperdisplays', self.config) conn.authenticate() @@ -38,14 +45,7 @@ def test_color(self): data_items = values.get('data') or [] color_value = None - expected_id = str(task.taskWrapperId) - for item in data_items: - if str(item.get('id')) == expected_id: - color_value = item.get('attributes', {}).get('color') - break - - #print(f"\nResponse status: {r.status_code}") - #print(f"Color field value: {color_value}") + color_value = data_items[0].get('attributes', {}).get('color') self.assertEqual(200, r.status_code) - self.assertIsNotNone(color_value) - self.assertEqual("#8000ff", color_value) \ No newline at end of file + self.assertIsNone(color_value) + self.assertNotEqual("#FFFFFF", color_value) \ No newline at end of file From f27813c15e1afed4acd71866b86699e078191e4c Mon Sep 17 00:00:00 2001 From: inadequate777 Date: Tue, 5 May 2026 12:58:53 +0000 Subject: [PATCH 07/16] only local task --- ci/apiv2/test_taskwrapperdisplays.py | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/ci/apiv2/test_taskwrapperdisplays.py b/ci/apiv2/test_taskwrapperdisplays.py index 9c763f3cd..e3709fe42 100644 --- a/ci/apiv2/test_taskwrapperdisplays.py +++ b/ci/apiv2/test_taskwrapperdisplays.py @@ -23,29 +23,13 @@ def test_color(self): r = requests.get(uri, headers=headers) values = r.json() data_items = values.get('data') or [] - + expected_id = str(task.taskWrapperId) color_value = None - color_value = data_items[0].get('attributes', {}).get('color') + for item in data_items: + if str(item.get('id')) == expected_id: + color_value = item.get('attributes', {}).get('color') + break self.assertEqual(200, r.status_code) self.assertIsNotNone(color_value) self.assertEqual("#8000ff", color_value) self.assertNotEqual("#ff0000", color_value) - - def test_no_color(self): - hashlist = self.create_hashlist() - task = self.create_task(hashlist, extra_payload={'color': '#FFFFFF'}) - conn = HashtopolisConnector('/ui/taskwrapperdisplays', self.config) - conn.authenticate() - - headers = conn._headers - uri = conn._api_endpoint + conn._model_uri - - r = requests.get(uri, headers=headers) - values = r.json() - data_items = values.get('data') or [] - - color_value = None - color_value = data_items[0].get('attributes', {}).get('color') - self.assertEqual(200, r.status_code) - self.assertIsNone(color_value) - self.assertNotEqual("#FFFFFF", color_value) \ No newline at end of file From aeb4090ca0d68c949f12e0034582d001acd96aaa Mon Sep 17 00:00:00 2001 From: inadequate777 Date: Tue, 5 May 2026 13:05:02 +0000 Subject: [PATCH 08/16] new name --- ci/apiv2/test_taskwrapperdisplays.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/apiv2/test_taskwrapperdisplays.py b/ci/apiv2/test_taskwrapperdisplays.py index e3709fe42..56b04be61 100644 --- a/ci/apiv2/test_taskwrapperdisplays.py +++ b/ci/apiv2/test_taskwrapperdisplays.py @@ -11,7 +11,7 @@ def setUpClass(cls): super().setUpClass() cls.config = HashtopolisConfig() - def test_color(self): + def test_taskwrapperdisplays_returns_color_field(self): hashlist = self.create_hashlist() task = self.create_task(hashlist, extra_payload={'color': '#8000ff'}) conn = HashtopolisConnector('/ui/taskwrapperdisplays', self.config) From 7b435193fb509292c18f6ac0734f324ebab43049 Mon Sep 17 00:00:00 2001 From: inadequate777 Date: Wed, 6 May 2026 09:01:05 +0000 Subject: [PATCH 09/16] fixed color value --- ci/apiv2/test_taskwrapperdisplays.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/apiv2/test_taskwrapperdisplays.py b/ci/apiv2/test_taskwrapperdisplays.py index 56b04be61..aee01aa36 100644 --- a/ci/apiv2/test_taskwrapperdisplays.py +++ b/ci/apiv2/test_taskwrapperdisplays.py @@ -1,5 +1,4 @@ import requests -from unittest.mock import patch, MagicMock from hashtopolis import HashtopolisConnector, HashtopolisConfig from utils import BaseTest @@ -13,7 +12,7 @@ def setUpClass(cls): def test_taskwrapperdisplays_returns_color_field(self): hashlist = self.create_hashlist() - task = self.create_task(hashlist, extra_payload={'color': '#8000ff'}) + task = self.create_task(hashlist) conn = HashtopolisConnector('/ui/taskwrapperdisplays', self.config) conn.authenticate() @@ -25,11 +24,12 @@ def test_taskwrapperdisplays_returns_color_field(self): data_items = values.get('data') or [] expected_id = str(task.taskWrapperId) color_value = None + expected_color_value = str(task.color) for item in data_items: if str(item.get('id')) == expected_id: color_value = item.get('attributes', {}).get('color') break self.assertEqual(200, r.status_code) self.assertIsNotNone(color_value) - self.assertEqual("#8000ff", color_value) - self.assertNotEqual("#ff0000", color_value) + self.assertEqual(expected_color_value, color_value) + self.assertNotEqual("ff0000", color_value) From 8202c985cb4ea1c3c10e9284fd583eb7fdd8fb94 Mon Sep 17 00:00:00 2001 From: inadequate777 Date: Wed, 6 May 2026 10:55:15 +0000 Subject: [PATCH 10/16] rename and test url --- ci/apiv2/requirements.txt | 2 +- .../{test_taskwrapperdisplays.py => test_taskwrapperdisplay.py} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename ci/apiv2/{test_taskwrapperdisplays.py => test_taskwrapperdisplay.py} (96%) diff --git a/ci/apiv2/requirements.txt b/ci/apiv2/requirements.txt index 51f53dcda..49a3e5a3c 100644 --- a/ci/apiv2/requirements.txt +++ b/ci/apiv2/requirements.txt @@ -1,5 +1,5 @@ click click_log pytest -git+https://github.com/hashtopolis/python-hashtopolis.git +git+https://github.com/hashtopolis/python-hashtopolis.git@2044-bug-missing-color-labeling-of-tasks#egg=hashtopolis-pylib confidence diff --git a/ci/apiv2/test_taskwrapperdisplays.py b/ci/apiv2/test_taskwrapperdisplay.py similarity index 96% rename from ci/apiv2/test_taskwrapperdisplays.py rename to ci/apiv2/test_taskwrapperdisplay.py index aee01aa36..e085a3ae5 100644 --- a/ci/apiv2/test_taskwrapperdisplays.py +++ b/ci/apiv2/test_taskwrapperdisplay.py @@ -4,7 +4,7 @@ from utils import BaseTest -class TaskWrapperDisplaysTest(BaseTest): +class TaskWrapperDisplayTest(BaseTest): @classmethod def setUpClass(cls): super().setUpClass() From 841cc100d849532eda64df63f777a72c0f2f6e16 Mon Sep 17 00:00:00 2001 From: inadequate777 Date: Wed, 6 May 2026 12:54:46 +0000 Subject: [PATCH 11/16] wip --- ci/apiv2/test_taskwrapperdisplay.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/apiv2/test_taskwrapperdisplay.py b/ci/apiv2/test_taskwrapperdisplay.py index e085a3ae5..6d594a763 100644 --- a/ci/apiv2/test_taskwrapperdisplay.py +++ b/ci/apiv2/test_taskwrapperdisplay.py @@ -18,7 +18,6 @@ def test_taskwrapperdisplays_returns_color_field(self): headers = conn._headers uri = conn._api_endpoint + conn._model_uri - r = requests.get(uri, headers=headers) values = r.json() data_items = values.get('data') or [] From 0f4102ece6c44febcbac3dbc45133ca39d3357f1 Mon Sep 17 00:00:00 2001 From: inadequate777 Date: Thu, 7 May 2026 08:45:56 +0000 Subject: [PATCH 12/16] fixed test --- ci/apiv2/requirements.txt | 2 +- ci/apiv2/test_taskwrapperdisplay.py | 26 ++++++++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/ci/apiv2/requirements.txt b/ci/apiv2/requirements.txt index 49a3e5a3c..ed7682124 100644 --- a/ci/apiv2/requirements.txt +++ b/ci/apiv2/requirements.txt @@ -1,5 +1,5 @@ click click_log pytest -git+https://github.com/hashtopolis/python-hashtopolis.git@2044-bug-missing-color-labeling-of-tasks#egg=hashtopolis-pylib +git+https://github.com/hashtopolis/python-hashtopolis.git@2044-bug-missing-color-labeling-of-tasks confidence diff --git a/ci/apiv2/test_taskwrapperdisplay.py b/ci/apiv2/test_taskwrapperdisplay.py index 6d594a763..d2683ad19 100644 --- a/ci/apiv2/test_taskwrapperdisplay.py +++ b/ci/apiv2/test_taskwrapperdisplay.py @@ -1,25 +1,20 @@ -import requests - -from hashtopolis import HashtopolisConnector, HashtopolisConfig +from hashtopolis import TaskWrapperDisplay, TaskWrapperDisplayHelper from utils import BaseTest class TaskWrapperDisplayTest(BaseTest): - @classmethod - def setUpClass(cls): - super().setUpClass() - cls.config = HashtopolisConfig() - - def test_taskwrapperdisplays_returns_color_field(self): + model_class = TaskWrapperDisplay + def test_toast(self): hashlist = self.create_hashlist() task = self.create_task(hashlist) - conn = HashtopolisConnector('/ui/taskwrapperdisplays', self.config) - conn.authenticate() + expected_color_value = str(task.color) + display = TaskWrapperDisplay.objects.get(id=task.taskWrapperId) + self.assertEqual(display.color, expected_color_value) - headers = conn._headers - uri = conn._api_endpoint + conn._model_uri - r = requests.get(uri, headers=headers) - values = r.json() + def test_taskwrapperdisplays_returns_color_field(self): + hashlist = self.create_hashlist() + task = self.create_task(hashlist) + values = TaskWrapperDisplayHelper().get_task_wrapper_display() data_items = values.get('data') or [] expected_id = str(task.taskWrapperId) color_value = None @@ -28,7 +23,6 @@ def test_taskwrapperdisplays_returns_color_field(self): if str(item.get('id')) == expected_id: color_value = item.get('attributes', {}).get('color') break - self.assertEqual(200, r.status_code) self.assertIsNotNone(color_value) self.assertEqual(expected_color_value, color_value) self.assertNotEqual("ff0000", color_value) From dd881b7f6070826f7c35bfaa4fdd3ea6bed39d4d Mon Sep 17 00:00:00 2001 From: inadequate777 Date: Thu, 7 May 2026 09:18:40 +0000 Subject: [PATCH 13/16] new slimmed down test --- ci/apiv2/test_taskwrapperdisplay.py | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/ci/apiv2/test_taskwrapperdisplay.py b/ci/apiv2/test_taskwrapperdisplay.py index d2683ad19..3c111cd33 100644 --- a/ci/apiv2/test_taskwrapperdisplay.py +++ b/ci/apiv2/test_taskwrapperdisplay.py @@ -1,28 +1,13 @@ -from hashtopolis import TaskWrapperDisplay, TaskWrapperDisplayHelper +from hashtopolis import TaskWrapperDisplay from utils import BaseTest - - class TaskWrapperDisplayTest(BaseTest): model_class = TaskWrapperDisplay - def test_toast(self): + + def test_task_wrapper_display_should_return_color_field(self): hashlist = self.create_hashlist() task = self.create_task(hashlist) expected_color_value = str(task.color) - display = TaskWrapperDisplay.objects.get(id=task.taskWrapperId) - self.assertEqual(display.color, expected_color_value) - - def test_taskwrapperdisplays_returns_color_field(self): - hashlist = self.create_hashlist() - task = self.create_task(hashlist) - values = TaskWrapperDisplayHelper().get_task_wrapper_display() - data_items = values.get('data') or [] - expected_id = str(task.taskWrapperId) - color_value = None - expected_color_value = str(task.color) - for item in data_items: - if str(item.get('id')) == expected_id: - color_value = item.get('attributes', {}).get('color') - break - self.assertIsNotNone(color_value) - self.assertEqual(expected_color_value, color_value) - self.assertNotEqual("ff0000", color_value) + task_wrapper_Display_object = TaskWrapperDisplay.objects.get(id=task.taskWrapperId) + self.assertIsNotNone(task_wrapper_Display_object.color) + self.assertEqual(task_wrapper_Display_object.color, expected_color_value) + self.assertNotEqual("ff0000", task_wrapper_Display_object.color) \ No newline at end of file From 3ce60fb12d0a5d006c189c0e00d4b8957ae81f6b Mon Sep 17 00:00:00 2001 From: inadequate777 Date: Thu, 7 May 2026 10:40:44 +0000 Subject: [PATCH 14/16] correct requierments.txt file --- ci/apiv2/requirements.txt | 2 +- ci/apiv2/test_taskwrapperdisplay.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/apiv2/requirements.txt b/ci/apiv2/requirements.txt index ed7682124..51f53dcda 100644 --- a/ci/apiv2/requirements.txt +++ b/ci/apiv2/requirements.txt @@ -1,5 +1,5 @@ click click_log pytest -git+https://github.com/hashtopolis/python-hashtopolis.git@2044-bug-missing-color-labeling-of-tasks +git+https://github.com/hashtopolis/python-hashtopolis.git confidence diff --git a/ci/apiv2/test_taskwrapperdisplay.py b/ci/apiv2/test_taskwrapperdisplay.py index 3c111cd33..f4cddc033 100644 --- a/ci/apiv2/test_taskwrapperdisplay.py +++ b/ci/apiv2/test_taskwrapperdisplay.py @@ -10,4 +10,4 @@ def test_task_wrapper_display_should_return_color_field(self): task_wrapper_Display_object = TaskWrapperDisplay.objects.get(id=task.taskWrapperId) self.assertIsNotNone(task_wrapper_Display_object.color) self.assertEqual(task_wrapper_Display_object.color, expected_color_value) - self.assertNotEqual("ff0000", task_wrapper_Display_object.color) \ No newline at end of file + self.assertNotEqual("FFFFFF", task_wrapper_Display_object.color) \ No newline at end of file From 605a92646aa7ce9a624c23f81a4bb170dd1f06a8 Mon Sep 17 00:00:00 2001 From: inadequate777 Date: Thu, 7 May 2026 11:44:13 +0000 Subject: [PATCH 15/16] pk instad of id --- ci/apiv2/test_taskwrapperdisplay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/apiv2/test_taskwrapperdisplay.py b/ci/apiv2/test_taskwrapperdisplay.py index f4cddc033..a03e7f535 100644 --- a/ci/apiv2/test_taskwrapperdisplay.py +++ b/ci/apiv2/test_taskwrapperdisplay.py @@ -7,7 +7,7 @@ def test_task_wrapper_display_should_return_color_field(self): hashlist = self.create_hashlist() task = self.create_task(hashlist) expected_color_value = str(task.color) - task_wrapper_Display_object = TaskWrapperDisplay.objects.get(id=task.taskWrapperId) + task_wrapper_Display_object = TaskWrapperDisplay.objects.get(pk=task.taskWrapperId) self.assertIsNotNone(task_wrapper_Display_object.color) self.assertEqual(task_wrapper_Display_object.color, expected_color_value) self.assertNotEqual("FFFFFF", task_wrapper_Display_object.color) \ No newline at end of file From 50f640d3bc912c972b36b9cd3ed673bd76936ef6 Mon Sep 17 00:00:00 2001 From: inadequate777 Date: Thu, 7 May 2026 11:49:29 +0000 Subject: [PATCH 16/16] create test object for future tests --- ci/apiv2/test_taskwrapperdisplay.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ci/apiv2/test_taskwrapperdisplay.py b/ci/apiv2/test_taskwrapperdisplay.py index a03e7f535..c98cdaa08 100644 --- a/ci/apiv2/test_taskwrapperdisplay.py +++ b/ci/apiv2/test_taskwrapperdisplay.py @@ -3,11 +3,16 @@ class TaskWrapperDisplayTest(BaseTest): model_class = TaskWrapperDisplay - def test_task_wrapper_display_should_return_color_field(self): + def create_test_object(self, *nargs, delete=True, **kwargs): + # Always cleanup hashlist when done, this is potentially confusing, + # since it will also remove the related task hashlist = self.create_hashlist() - task = self.create_task(hashlist) - expected_color_value = str(task.color) - task_wrapper_Display_object = TaskWrapperDisplay.objects.get(pk=task.taskWrapperId) - self.assertIsNotNone(task_wrapper_Display_object.color) - self.assertEqual(task_wrapper_Display_object.color, expected_color_value) - self.assertNotEqual("FFFFFF", task_wrapper_Display_object.color) \ No newline at end of file + task = self.create_task(hashlist, delete=delete) + return TaskWrapperDisplay.objects.get(pk=task.taskWrapperId) + + def test_task_wrapper_display_should_return_color_field(self): + task_wrapper_display_object = self.create_test_object() + expected_color_value = str(task_wrapper_display_object.color) + self.assertIsNotNone(task_wrapper_display_object.color) + self.assertEqual(task_wrapper_display_object.color, expected_color_value) + self.assertNotEqual("FFFFFF", task_wrapper_display_object.color) \ No newline at end of file