smartpush 2.0.0__py3-none-any.whl → 2.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -561,13 +561,33 @@ class FakeDataGenerator:
561
561
  def fake_height(self):
562
562
  return random.randint(600, 2500)
563
563
 
564
+ @property
565
+ def generate_color_name(self) -> str:
566
+ """生成随机颜色名称(如 "red", "blue")"""
567
+ return fake.color_name()
568
+
569
+ @property
570
+ def generate_hex_color(self) -> str:
571
+ """生成随机十六进制颜色(如 "#ff0000")"""
572
+ return fake.hex_color()
573
+
574
+ @property
575
+ def generate_rgb_color(self) -> tuple[int, ...]:
576
+ """生成随机RGB颜色元组(如 (255, 0, 0))"""
577
+ rgb_str = fake.rgb_color() # 返回字符串 "255,0,0"
578
+ return tuple(map(int, rgb_str.split(",")))
579
+
580
+ @property
581
+ def generate_rgba_color(self) -> str:
582
+ """生成随机RGBA颜色(如 "rgba(255,0,0,0.5)")"""
583
+ return fake.rgba_color()
584
+
564
585
  def generate_user_data(self):
565
586
  """
566
587
  生成完整的用户测试数据
567
588
  """
568
589
  user_agent = self.fake.user_agent()
569
590
  parsed_ua = parse(user_agent)
570
-
571
591
  return {
572
592
  'user_agent': user_agent,
573
593
  'fake_currency': self.fake.currency()[0],
@@ -675,5 +695,6 @@ class FakeDataGenerator:
675
695
  'fake_unix_time': self.fake.unix_time(),
676
696
  'fake_year': self.fake.year(),
677
697
  'fake_width': random.randint(800, 4000),
678
- 'fake_height': random.randint(600, 2500)
698
+ 'fake_height': random.randint(600, 2500),
699
+ 'fake_hex_color': self.fake.hex_color()
679
700
  }
@@ -13,8 +13,7 @@ from smartpush.email.schema import *
13
13
  更新活动草稿内容
14
14
  """
15
15
 
16
-
17
- class ActivityTemplate(ActivityTemplateRequestBase, RequestBase):
16
+ class ActivityTemplate(ActivityTemplateRequestBase):
18
17
 
19
18
  def create_activity_template(self):
20
19
  requestParam = {"activityName": "自动化创建草稿活动-" + DateUtils.get_current_datetime_to_str(),
@@ -28,7 +27,7 @@ class ActivityTemplate(ActivityTemplateRequestBase, RequestBase):
28
27
  "customerGroupIds": [], "excludeContactPacks": [], "excludeCustomerGroupIds": [],
29
28
  "warmupPack": 0}
30
29
  result = self.request(path=URL.Activity.step1.url, method=URL.Activity.step1.method, data=requestParam)
31
- return json.dumps(result)
30
+ return result
32
31
 
33
32
  def update_activity_template_schema(self, currentJsonSchema, schema):
34
33
  currentJsonSchema = self.add_element_to_section_column_children(currentJsonSchema, schema)
@@ -43,7 +42,13 @@ class ActivityTemplate(ActivityTemplateRequestBase, RequestBase):
43
42
 
44
43
  result = self.request(path=URL.Activity.step2.url, method=URL.Activity.step2.method,
45
44
  data=requestParam)
46
- return json.dumps(result)
45
+ return result
46
+
47
+ def getActivityTemplateStep2(self):
48
+ requestParam = {"id": self.activityTemplateId}
49
+ result = self.request(path=URL.Activity.step2_get.url, method=URL.Activity.step2_get.method,params = requestParam)
50
+ return result
51
+
47
52
 
48
53
  @staticmethod
49
54
  def add_element_to_section_column_children(currentJsonSchema, new_schema):
@@ -64,3 +69,26 @@ class ActivityTemplate(ActivityTemplateRequestBase, RequestBase):
64
69
  break # 若有多个Column可根据需求调整,这里匹配第一个Column
65
70
  break # 若有多个Section可根据需求调整,这里匹配第一个Section
66
71
  return currentJsonSchema
72
+ @staticmethod
73
+ def get_column_children_universal_property(currentJsonSchema,universalId,property):
74
+ _currentJsonSchema = json.loads(currentJsonSchema)
75
+ for child in _currentJsonSchema.get("children", []):
76
+ if child.get("type") == "Section":
77
+ # 2. 在Section的children中找到Column节点
78
+ for column in child.get("children", []):
79
+ if column.get("type") == "Column":
80
+ for block in column.get("children", []):
81
+ if block.get("universalId") == universalId:
82
+ result = block.get('props').get(property)
83
+ return result
84
+ return None
85
+
86
+ def assert_activity_template_schema_is_update(self,universalId,property='containerBackgroundColor',value = '#123456'):
87
+ step2_result = self.getActivityTemplateStep2()
88
+ currentJsonSchema = json.loads(step2_result['resultData']['currentJsonSchema'])
89
+ assert self.get_column_children_universal_property(currentJsonSchema,universalId,property) == value
90
+
91
+
92
+ if __name__ == '__main__':
93
+ currentJsonSchema = "{\"id\":\"a4a9fba2a\",\"type\":\"Stage\",\"props\":{\"backgroundColor\":\"#EAEDF1\",\"width\":\"600px\",\"fullWidth\":\"normal-width\"},\"children\":[{\"id\":\"84ba788da\",\"type\":\"Header\",\"props\":{\"backgroundColor\":\"#ffffff\",\"borderLeft\":\"1px none #ffffff\",\"borderRight\":\"1px none #ffffff\",\"borderTop\":\"1px none #ffffff\",\"borderBottom\":\"1px none #ffffff\",\"paddingTop\":\"0px\",\"paddingBottom\":\"0px\",\"paddingLeft\":\"0px\",\"paddingRight\":\"0px\",\"cols\":[12]},\"children\":[{\"id\":\"98d909a48\",\"type\":\"Column\",\"props\":{},\"children\":[{\"id\":\"adbbaaaea\",\"universalId\":\"4c8a94eb-fb4f-4cba-934c-8bbcf4f02f63\",\"universalName\":\"Auto-Logo-2025-11-26 15:11:22\",\"type\":\"Logo\",\"props\":{\"width\":120,\"height\":120,\"imgRatio\":1,\"src\":\"https://cdn.smartpushedm.com/frontend/smart-push/staging/1741054956275/1758595834300_74d62ae6.png?width=120&height=120\",\"href\":\"https://smartpush4.myshoplinestg.com\",\"align\":\"center\",\"containerBackgroundColor\":\"#123456\",\"paddingLeft\":\"20px\",\"paddingRight\":\"20px\",\"paddingTop\":\"20px\",\"paddingBottom\":\"20px\",\"paddingCondition\":true,\"segmentTypeConfig\":1},\"children\":[]}]}]},{\"id\":\"84ba7bbda\",\"type\":\"Section\",\"props\":{\"backgroundColor\":\"#ffffff\",\"borderLeft\":\"1px none #ffffff\",\"borderRight\":\"1px none #ffffff\",\"borderTop\":\"1px none #ffffff\",\"borderBottom\":\"1px none #ffffff\",\"paddingTop\":\"0px\",\"paddingBottom\":\"0px\",\"paddingLeft\":\"0px\",\"paddingRight\":\"0px\",\"cols\":[12]},\"children\":[{\"id\":\"8cab9aa48\",\"type\":\"Column\",\"props\":{},\"children\":[{\"id\":\"f946192ef\",\"universalId\":\"4c8a94eb-fb4f-4cba-934c-8bbcf4f02f63\",\"universalName\":\"Auto-Logo-2025-11-26 15:11:22\",\"type\":\"Logo\",\"props\":{\"width\":120,\"height\":120,\"imgRatio\":1,\"src\":\"https://cdn.smartpushedm.com/frontend/smart-push/staging/1741054956275/1758595834300_74d62ae6.png?width=120&height=120\",\"href\":\"https://smartpush4.myshoplinestg.com\",\"align\":\"center\",\"containerBackgroundColor\":\"transparent\",\"paddingLeft\":\"20px\",\"paddingRight\":\"20px\",\"paddingTop\":\"20px\",\"paddingBottom\":\"20px\",\"paddingCondition\":true,\"segmentTypeConfig\":1},\"children\":[]}]}]},{\"id\":\"b8bbabad9\",\"type\":\"Footer\",\"props\":{\"backgroundColor\":\"#ffffff\",\"borderLeft\":\"1px none #ffffff\",\"borderRight\":\"1px none #ffffff\",\"borderTop\":\"1px none #ffffff\",\"borderBottom\":\"1px none #ffffff\",\"paddingTop\":\"0px\",\"paddingBottom\":\"0px\",\"paddingLeft\":\"0px\",\"paddingRight\":\"0px\",\"cols\":[12]},\"children\":[{\"id\":\"b3bcabad7\",\"type\":\"Column\",\"props\":{},\"children\":[{\"id\":\"b39b6a94a\",\"type\":\"Subscribe\",\"props\":{\"content\":\"<p style=\\\\\\\"text-align:center;\\\\\\\"><span style=\\\\\\\"font-size:12px\\\\\\\"><span style=\\\\\\\"font-family:Arial, Helvetica, sans-serif\\\\\\\">在此處輸入聯繫地址,可以讓你的顧客更加信任這封郵件</span></span></p><div class=\\\\\\\"sp-font-12\\\\\\\" style=\\\\\\\"color: rgb(122, 132, 153); font-size: 12px; text-align: center; font-style: oblique;\\\\\\\">Questions? Please <a href=[[customerEmail]] style=\\\\\\\"color:#479EEF;text-decoration:underline\\\\\\\" rel=\\\\\\\"noreferrer\\\\\\\">contact us</a>, we are glad to help.</div><div class=\\\\\\\"sp-font-12\\\\\\\" style=\\\\\\\"color: rgb(122, 132, 153); font-size: 12px; text-align: center; font-style: oblique;\\\\\\\">If you don't want to receive our message, just <a href=[[unsubscribe.url]] target=\\\\\\\"_blank\\\\\\\" style=\\\\\\\"color:#479EEF;text-decoration:underline\\\\\\\" rel=\\\\\\\"noreferrer\\\\\\\">click here</a> to cancel the subscription.</div>\"},\"children\":[]}]}]}],\"extend\":{\"version\":\"1.0.0\",\"updateTime\":\"2025-11-26T07:25:17.609Z\"}}"
94
+ print(ActivityTemplate.get_column_children_universal_property(currentJsonSchema,'4c8a94eb-fb4f-4cba-934c-8bbcf4f02f63','containerBackgroundColor'))
smartpush/email/schema.py CHANGED
@@ -582,4 +582,4 @@ if __name__ == '__main__':
582
582
  # BlockSchema.ImageText,
583
583
  # BlockSchema.Button, BlockSchema.Divider, BlockSchema.Social, BlockSchema.HTMLCode]
584
584
 
585
- print(genSchemaAnalysis(BlockSchema.Section))
585
+ print(BlockSchema.genSchemaAnalysis(BlockSchema.Section))
@@ -4,6 +4,7 @@ import time
4
4
  from smartpush.base.request_base import RequestBase
5
5
  from smartpush.base.url_enum import *
6
6
  from smartpush.email.schema import *
7
+ from smartpush.email.activity import ActivityTemplate
7
8
 
8
9
 
9
10
  def gen_universal_request_param(universalId, schema, **kwargs):
@@ -130,6 +131,16 @@ class UniversalContent(RequestBase):
130
131
  print(f"------收藏的block在该section({section_universa_name})中,断言成功------")
131
132
  except:
132
133
  raise
134
+ @staticmethod
135
+ def assert_universal_schema_is_update(schema, property='containerBackgroundColor', value ='#123456'):
136
+ """
137
+ 用于查找素材schema的属性是否更新成功
138
+ :param property:
139
+ :param value:
140
+ :return:
141
+ """
142
+ _schema =schema if isinstance(schema,dict) else json.loads(schema)
143
+ assert _schema['props'][property] == value
133
144
 
134
145
 
135
146
  def get_time():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smartpush
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: 用于smartpush自动化测试工具包
5
5
  Author: lulu、felix、long
6
6
 
@@ -4,15 +4,15 @@ smartpush/test.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  smartpush/account/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  smartpush/account/operate_account.py,sha256=nzJLLAEwNElavZeWVqnA_MSGTBzQrSrknmezYBwtvWs,1525
6
6
  smartpush/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- smartpush/base/faker_data.py,sha256=TOd5EKVImxZpsKEW_dtKa2iqiUGqU7OBkOM8pvqKVUc,24643
7
+ smartpush/base/faker_data.py,sha256=-OcFFQnDGpjZR3guo_tHfxV7zQEHo9ciidWGqKv_jNs,25437
8
8
  smartpush/base/request_base.py,sha256=jQRnURl9-BA5BnymjyD5auqFc256CtmepM_woFVkE6g,2754
9
9
  smartpush/base/url_enum.py,sha256=vVg4Y1w8ayT_jD3DDzQCEzD6cWpnRr-7MxPeEqU5OTU,2226
10
10
  smartpush/crowd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  smartpush/crowd/crowd.py,sha256=KNwvX-BnBnMVVuHM79a-VeBMp_guB-Kqw3tFaAPiAp8,9768
12
12
  smartpush/email/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- smartpush/email/activity.py,sha256=bFiuxp8wb5qxQP0hg2BSqztqnLy7jxuaUONpqF9dl0M,3493
14
- smartpush/email/schema.py,sha256=790z_2aym1L4yd3igslgMmugvDOJ_XXwzMFrgfUsqg0,31208
15
- smartpush/email/universal_content.py,sha256=_SHnp1QeZK076U0MEWIFsSSgzEWt2W1R2oMEMbMOa08,11502
13
+ smartpush/email/activity.py,sha256=XME4UpOcP3oKBk4LJTkDvR7b6E7RgvPXpRC3tTMAVf0,8821
14
+ smartpush/email/schema.py,sha256=Uef41D0Z_xw07khOyLiJhjfZ9GVE0urN0tG8orQjIfY,31220
15
+ smartpush/email/universal_content.py,sha256=0VaY_-2--AofdJBuRrOClDXZqn-tCU_FOxSPY-GIRIk,11954
16
16
  smartpush/export/__init__.py,sha256=D9GbWcmwnetEndFDty5XbVienFK1WjqV2yYcQp3CM84,99
17
17
  smartpush/export/basic/ExcelExportChecker.py,sha256=YqWmDGSFadQdK2vNJ070Qvad9ZtqEwiQyPkOemlACfs,21508
18
18
  smartpush/export/basic/GetOssUrl.py,sha256=zxNZj6x7Ph9N3P5k82pLpBFjZxKrDfbgqS2fTYyhvso,8467
@@ -34,7 +34,7 @@ smartpush/utils/StringUtils.py,sha256=n8mo9k0JQN63MReImgv-66JxmmymOGknR8pH2fkQrA
34
34
  smartpush/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
35
  smartpush/utils/date_utils.py,sha256=Xgx2DbmWYri71xXBiaKYTZDeh2a8MFhYns_xB0U2JOA,13159
36
36
  smartpush/utils/form_utils.py,sha256=ld-g_Dm_ZlnagQt7imYfUc87bcBRVlTctywuLtzmjXQ,849
37
- smartpush-2.0.0.dist-info/METADATA,sha256=v4plV_C6P-VNEfK4waKSnHj2DvCLvAl_6ASXVz1RZ5Y,131
38
- smartpush-2.0.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
39
- smartpush-2.0.0.dist-info/top_level.txt,sha256=5_CXqu08EfbPaKLjuSAOAqCmGU6shiatwDU_ViBGCmg,10
40
- smartpush-2.0.0.dist-info/RECORD,,
37
+ smartpush-2.0.1.dist-info/METADATA,sha256=vvby9hLqP-pNQo9MTusB1EULNABvvi3BLYFXhnB2G2c,131
38
+ smartpush-2.0.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
39
+ smartpush-2.0.1.dist-info/top_level.txt,sha256=5_CXqu08EfbPaKLjuSAOAqCmGU6shiatwDU_ViBGCmg,10
40
+ smartpush-2.0.1.dist-info/RECORD,,