Skip to content

Commit

Permalink
Added tests for Mapi
Browse files Browse the repository at this point in the history
  • Loading branch information
Marat-Gumerov committed Feb 20, 2020
1 parent 99e6870 commit 3a10511
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/tests/sdk_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,50 @@ def test_discover_email_config(td: TestData):
smtp = list(filter(lambda x: x.protocol_type == 'SMTP', configs.value))[0] #type: models.EmailAccountConfig
assert smtp.host == 'smtp.gmail.com'

@pytest.mark.pipeline
def test_create_mapi(td: TestData):
name = str(uuid.uuid4())+ '.msg'
td.email.create_mapi(requests.CreateMapiRequest(
name,
models.HierarchicalObjectRequest(
models.HierarchicalObject('IPM.Contact', internal_properties=[
models.PrimitiveObject("Tag:'PidTagMessageClass':0x1A:String", None, "IPM.Contact"),
models.PrimitiveObject("Tag:'PidTagSubject':0x37:String"),
models.PrimitiveObject("Tag:'PidTagSubjectPrefix':0x3D:String"),
models.PrimitiveObject("Tag:'PidTagMessageFlags':0xE07:Integer32", value="8"),
models.PrimitiveObject("Tag:'PidTagNormalizedSubject':0xE1D:String"),
models.PrimitiveObject("Tag:'PidTagBody':0x1000:String"),
models.PrimitiveObject("Tag:'PidTagStoreSupportMask':0x340D:Integer32", value="265849"),
models.PrimitiveObject("Tag:'PidTagSurname':0x3A11:String", value="Surname"),
models.PrimitiveObject("Tag:'PidTagOtherTelephoneNumber':0x3A1F:String", value="+79123456789"),
models.PrimitiveObject("Tag:'':0x6662:Integer32", value="0"),
models.PrimitiveObject(
"Lid:'PidLidAddressBookProviderArrayType':0x8029:Integer32:00062004-0000-0000-c000-000000000046",
value="1")]),
models.StorageFolderLocation(td.storage, td.folder))))
assert td.email.object_exists(requests.ObjectExistsRequest(td.folder + '/' + name, td.storage)).exists

@pytest.mark.pipeline
def test_mapi_add_attachment(td: TestData):
name = _create_calendar(td)
attachment = _create_calendar(td)
td.email.add_mapi_attachment(requests.AddMapiAttachmentRequest(
name, attachment, models.AddAttachmentRequest(
models.StorageFolderLocation(td.storage, td.folder),
models.StorageFolderLocation(td.storage, td.folder))))
attachment_downloaded = td.email.get_calendar_attachment(requests.GetCalendarAttachmentRequest(
name, attachment, td.folder, td.storage))
with open(attachment_downloaded, 'r') as f:
filedata = f.read()
assert 'Aspose Ltd' in filedata

@pytest.mark.pipeline
def test_mapi_get_properties(td: TestData):
name = _create_calendar(td)
properties = td.email.get_mapi_properties(requests.GetMapiPropertiesRequest(
name, td.folder, td.storage))
assert 'IPM.Schedule' in properties.hierarchical_object.name

def _create_calendar(td, start_date_param=None):
name = str(uuid.uuid4())+ '.ics'
start_date = (
Expand Down

0 comments on commit 3a10511

Please sign in to comment.