|
22 | 22 | SOFTWARE. |
23 | 23 | """ |
24 | 24 |
|
25 | | -import itertools |
| 25 | +import json |
| 26 | +import os |
26 | 27 |
|
27 | 28 | import pytest |
28 | 29 |
|
29 | 30 | import webexteamssdk |
30 | | -from tests.environment import WEBEX_TEAMS_TEST_FILE_URL |
31 | 31 | from tests.utils import create_string |
32 | 32 |
|
33 | 33 |
|
34 | | -# Helper Functions |
| 34 | +# Module Variables |
| 35 | +attachment_actions_card_path = os.path.abspath( |
| 36 | + os.path.join(__file__, os.pardir, "attachment_actions_card.json") |
| 37 | +) |
| 38 | + |
35 | 39 |
|
| 40 | +# Helper Functions |
36 | 41 | def is_valid_attachment_action(obj): |
37 | 42 | return isinstance(obj, webexteamssdk.AttachmentAction) \ |
38 | 43 | and obj.id is not None |
39 | 44 |
|
40 | 45 |
|
41 | 46 | # Fixtures |
| 47 | +@pytest.fixture(scope="session") |
| 48 | +def attachment_actions_card(): |
| 49 | + with open(attachment_actions_card_path) as file: |
| 50 | + card = json.load(file) |
| 51 | + return card |
| 52 | + |
42 | 53 |
|
43 | 54 | @pytest.fixture(scope="session") |
44 | | -def attachment_action_create(api, test_people): |
| 55 | +def attachment_action_create(api, test_people, attachment_actions_card): |
45 | 56 | person = test_people["member_added_by_email"] |
46 | 57 | message = api.messages.create( |
47 | 58 | toPersonEmail=person.emails[0], |
48 | 59 | text=create_string("Message"), |
49 | | - attachments=[{ |
50 | | - "contentType": "application/vnd.microsoft.card.adaptive", |
51 | | - "content": { |
52 | | - "$schema": ("http://adaptivecards.io/schemas/" |
53 | | - "adaptive-card.json"), |
54 | | - "type": "AdaptiveCard", |
55 | | - "version": "1.0", |
56 | | - "body": [{ |
57 | | - "type": "ColumnSet", |
58 | | - "columns": [{ |
59 | | - "type": "Column", |
60 | | - "width": 2, |
61 | | - "items": [ |
62 | | - { |
63 | | - "type": "TextBlock", |
64 | | - "text": "Tell us about your problem", |
65 | | - "weight": "bolder", |
66 | | - "size": "medium" |
67 | | - }, |
68 | | - { |
69 | | - "type": "TextBlock", |
70 | | - "text": "Your name", |
71 | | - "wrap": True |
72 | | - }, |
73 | | - { |
74 | | - "type": "Input.Text", |
75 | | - "id": "Name", |
76 | | - "placeholder": "John Andersen" |
77 | | - }, |
78 | | - { |
79 | | - "type": "TextBlock", |
80 | | - "text": "Your email", |
81 | | - "wrap": True |
82 | | - }, |
83 | | - { |
84 | | - "type": "Input.Text", |
85 | | - "id": "Email", |
86 | | - "placeholder": "john.andersen@example.com", |
87 | | - "style": "email" |
88 | | - }, |
89 | | - ] |
90 | | - }] |
91 | | - }], |
92 | | - "actions": [ |
93 | | - { |
94 | | - "type": "Action.Submit", |
95 | | - "title": "Submit" |
96 | | - } |
97 | | - ] |
98 | | - } |
99 | | - }] |
| 60 | + attachments=[attachment_actions_card], |
100 | 61 | ) |
101 | 62 | attachment_action = api.attachment_actions.create( |
102 | 63 | type="submit", messageId=message.id, |
103 | | - inputs={"Name": "test_name", "Email": "test_email"} |
| 64 | + inputs={"Name": person.displayName, "Email": person.emails[0]} |
104 | 65 | ) |
| 66 | + |
105 | 67 | yield attachment_action |
106 | 68 |
|
107 | 69 | api.messages.delete(message.id) |
108 | 70 |
|
109 | | -# Tests |
110 | | - |
111 | 71 |
|
| 72 | +# Tests |
112 | 73 | def test_attachment_actions_create(attachment_action_create): |
113 | 74 | assert is_valid_attachment_action(attachment_action_create) |
114 | 75 |
|
|
0 commit comments