Show More
@@ -145,6 +145,10 b' class SlackIntegrationType(IntegrationTy' | |||
|
145 | 145 | |
|
146 | 146 | @async_task(ignore_result=True, base=RequestContextTask) |
|
147 | 147 | def post_text_to_slack(settings, slack_data: SlackData): |
|
148 | # because JSON serialization, if we run async with celery, deserialize to SlackData | |
|
149 | if isinstance(slack_data, dict): | |
|
150 | slack_data = SlackData(**slack_data) | |
|
151 | ||
|
148 | 152 | title = slack_data.title |
|
149 | 153 | text = slack_data.text |
|
150 | 154 | fields = slack_data.fields |
@@ -1,4 +1,4 b'' | |||
|
1 | ||
|
1 | import dataclasses | |
|
2 | 2 | # Copyright (C) 2010-2023 RhodeCode GmbH |
|
3 | 3 | # |
|
4 | 4 | # This program is free software: you can redistribute it and/or modify |
@@ -164,3 +164,15 b' def test_lazy_translation_string(baseapp' | |||
|
164 | 164 | |
|
165 | 165 | assert b'{"label":"hello"}' == ext_json.json.dumps(data) |
|
166 | 166 | assert b'{"label2":"singular"}' == ext_json.json.dumps(data2) |
|
167 | ||
|
168 | ||
|
169 | def test_serialize_dataclass(): | |
|
170 | ||
|
171 | @dataclasses.dataclass | |
|
172 | class ExampleStruct: | |
|
173 | field_str: str | |
|
174 | field_int: int | |
|
175 | struct = ExampleStruct(field_int=1, field_str='hello') | |
|
176 | raw_struct = b'{"field_str":"hello","field_int":1}' | |
|
177 | assert raw_struct == ext_json.json.dumps(struct) | |
|
178 | assert struct == ExampleStruct(**ext_json.json.loads(raw_struct)) |
General Comments 0
You need to be logged in to leave comments.
Login now