def test_serialize_communication_user(self):
        communication_identifier_model = CommunicationUserIdentifierSerializer.serialize(
            CommunicationUserIdentifier("an id")
        )

        assert communication_identifier_model.kind is CommunicationIdentifierKind.CommunicationUser
        assert communication_identifier_model.id is "an id"
    def test_serialize_unknown_identifier(self):
        unknown_identifier_model = CommunicationUserIdentifierSerializer.serialize(
            UnknownIdentifier("an id")
        )

        assert unknown_identifier_model.kind is CommunicationIdentifierKind.Unknown
        assert unknown_identifier_model.id is "an id"
    def test_serialize_phone_number(self):
        phone_number_identifier_model = CommunicationUserIdentifierSerializer.serialize(
            PhoneNumberIdentifier("phonenumber")
        )

        assert phone_number_identifier_model.kind is CommunicationIdentifierKind.PhoneNumber
        assert phone_number_identifier_model.id is "phonenumber"
    def test_serialize_teams_user(self):
        teams_user_identifier_model = CommunicationUserIdentifierSerializer.serialize(
            MicrosoftTeamsUserIdentifier("teamsid")
        )

        assert teams_user_identifier_model.kind is CommunicationIdentifierKind.MicrosoftTeamsUser
        assert teams_user_identifier_model.id is "teamsid"
    def test_missing_property_desrializer_throws(self):
        models_with_missing_property = [
            CommunicationIdentifierModel(
                kind=CommunicationIdentifierKind.Unknown
            ), # missing id
            CommunicationIdentifierModel(
                kind=CommunicationIdentifierKind.CommunicationUser
            ), # missing id
            CommunicationIdentifierModel(
                # phone_number="phonenumber",
                kind=CommunicationIdentifierKind.PhoneNumber
            ), # missing phone number
            CommunicationIdentifierModel(
                # id="an id",
                microsoft_teams_user_id="teamsid",
                kind=CommunicationIdentifierKind.MicrosoftTeamsUser
            ), # missing is_anonymous
            CommunicationIdentifierModel(
                is_anonymous=True,
                kind=CommunicationIdentifierKind.MicrosoftTeamsUser
            ) # missing microsoft_teams_user_id,
        ]

        for model in models_with_missing_property:
            self.assertRaises(ValueError, lambda : CommunicationUserIdentifierSerializer.deserialize(model))
    def test_deserialize_unknown_identifier(self):
        unknown_identifier_actual = CommunicationUserIdentifierSerializer.deserialize(
            CommunicationIdentifierModel(raw_id="an id"))

        unknown_identifier_expected = UnknownIdentifier("an id")

        assert isinstance(unknown_identifier_actual, UnknownIdentifier)
        assert unknown_identifier_actual.identifier == unknown_identifier_expected.identifier
    def test_serialize_teams_user(self):
        teams_user_identifier_model = CommunicationUserIdentifierSerializer.serialize(
            MicrosoftTeamsUserIdentifier(
                user_id="teamsid",
                cloud=CommunicationCloudEnvironment.Public,
                raw_id="someid"))

        assert teams_user_identifier_model.microsoft_teams_user.user_id is "teamsid"
        assert teams_user_identifier_model.microsoft_teams_user.cloud is CommunicationCloudEnvironment.Public
        assert teams_user_identifier_model.raw_id is "someid"
    def test_deserialize_communication_user(self):
        communication_identifier_actual = CommunicationUserIdentifierSerializer.deserialize(
            CommunicationIdentifierModel(
                raw_id="an id", communication_user=self.testUserModel))

        communication_identifier_expected = CommunicationUserIdentifier(
            identifier="an id")

        assert isinstance(communication_identifier_actual,
                          CommunicationUserIdentifier)
        assert communication_identifier_actual.identifier == communication_identifier_expected.identifier
Exemple #9
0
    def test_serialize_teams_user(self):
        teams_user_identifier_model = CommunicationUserIdentifierSerializer.serialize(
            MicrosoftTeamsUserIdentifier(
                "teamsid",
                cloud=CommunicationCloudEnvironment.Public,
                identifier="someid"))

        assert teams_user_identifier_model.kind is CommunicationIdentifierKind.MicrosoftTeamsUser
        assert teams_user_identifier_model.microsoft_teams_user_id is "teamsid"
        assert teams_user_identifier_model.communication_cloud_environment is CommunicationCloudEnvironment.Public
        assert teams_user_identifier_model.id is "someid"
Exemple #10
0
    def test_deserialize_communication_user(self):
        communication_identifier_actual = CommunicationUserIdentifierSerializer.deserialize(
            CommunicationIdentifierModel(
                kind=CommunicationIdentifierKind.CommunicationUser,
                id="an id"))

        communication_identifier_expected = CommunicationUserIdentifier(
            "an id")

        assert isinstance(communication_identifier_actual,
                          CommunicationUserIdentifier)
        assert communication_identifier_actual == communication_identifier_actual
    def test_deserialize_phone_number(self):
        phone_number_identifier_actual = CommunicationUserIdentifierSerializer.deserialize(
            CommunicationIdentifierModel(
                kind=CommunicationIdentifierKind.PhoneNumber,
                phone_number="phonenumber"
            )
        )

        phone_number_identifier_expected = PhoneNumberIdentifier("phonenumber")

        assert isinstance(phone_number_identifier_actual, PhoneNumberIdentifier)
        assert phone_number_identifier_actual.phone_number == phone_number_identifier_expected.phone_number
    def test_deserialize_phone_number(self):
        phone_number_identifier_actual = CommunicationUserIdentifierSerializer.deserialize(
            CommunicationIdentifierModel(
                raw_id="someid", phone_number=self.testPhoneNumberModel))

        phone_number_identifier_expected = PhoneNumberIdentifier(
            self.testPhoneNumber, raw_id="someid")

        assert isinstance(phone_number_identifier_actual,
                          PhoneNumberIdentifier)
        assert phone_number_identifier_actual.phone_number == phone_number_identifier_expected.phone_number
        assert phone_number_identifier_actual.raw_id == phone_number_identifier_expected.raw_id
    def test_deserialize_teams_user(self):
        teams_user_identifier_actual = CommunicationUserIdentifierSerializer.deserialize(
            CommunicationIdentifierModel(
                kind=CommunicationIdentifierKind.MicrosoftTeamsUser,
                microsoft_teams_user_id="teamsid",
                is_anonymous=True
            )
        )

        teams_user_identifier_expected = MicrosoftTeamsUserIdentifier("teamsid", is_anonymous=True)

        assert isinstance(teams_user_identifier_actual, MicrosoftTeamsUserIdentifier)
        assert teams_user_identifier_actual.user_id == teams_user_identifier_expected.user_id
    def test_deserialize_teams_user(self):
        teams_user_identifier_actual = CommunicationUserIdentifierSerializer.deserialize(
            CommunicationIdentifierModel(
                raw_id="someid", microsoft_teams_user=self.testTeamsUserModel))

        teams_user_identifier_expected = MicrosoftTeamsUserIdentifier(
            raw_id="someid",
            user_id="Microsoft Teams User Id",
            cloud=CommunicationCloudEnvironment.Public,
            is_anonymous=True)

        assert isinstance(teams_user_identifier_actual,
                          MicrosoftTeamsUserIdentifier)
        assert teams_user_identifier_actual.raw_id == teams_user_identifier_expected.raw_id
        assert teams_user_identifier_actual.user_id == teams_user_identifier_expected.user_id
        assert teams_user_identifier_actual.is_anonymous == teams_user_identifier_expected.is_anonymous
        assert teams_user_identifier_actual.cloud == teams_user_identifier_expected.cloud
Exemple #15
0
    def test_deserialize_teams_user(self):
        teams_user_identifier_actual = CommunicationUserIdentifierSerializer.deserialize(
            CommunicationIdentifierModel(
                id="someid",
                kind=CommunicationIdentifierKind.MicrosoftTeamsUser,
                microsoft_teams_user_id="teamsid",
                is_anonymous=True,
                communication_cloud_environment="PUBLIC"))

        teams_user_identifier_expected = MicrosoftTeamsUserIdentifier(
            "teamsid",
            identifier="someid",
            cloud=CommunicationCloudEnvironment.Public,
            is_anonymous=True)

        assert isinstance(teams_user_identifier_actual,
                          MicrosoftTeamsUserIdentifier)
        assert teams_user_identifier_actual.identifier == teams_user_identifier_expected.identifier
        assert teams_user_identifier_actual.user_id == teams_user_identifier_expected.user_id
        assert teams_user_identifier_actual.is_anonymous == teams_user_identifier_expected.is_anonymous
        assert teams_user_identifier_actual.cloud == teams_user_identifier_expected.cloud
Exemple #16
0
    def test_deserialize_unknown_kind(self):
        unknown_identifier = CommunicationUserIdentifierSerializer.deserialize(
            CommunicationIdentifierModel(kind="foreign", id="an id"))

        assert isinstance(unknown_identifier, UnknownIdentifier)
        assert unknown_identifier.identifier == "an id"
Exemple #17
0
 def test_serialize_foreign_throws(self):
     foreign_obj = "Foreign object"
     self.assertRaises(
         TypeError, lambda: CommunicationUserIdentifierSerializer.serialize(
             foreign_obj))
    def test_serialize_communication_user(self):
        communication_identifier_model = CommunicationUserIdentifierSerializer.serialize(
            CommunicationUserIdentifier(identifier="an id"))

        assert communication_identifier_model.communication_user.id is "an id"
    def test_serialize_unknown_identifier(self):
        unknown_identifier_model = CommunicationUserIdentifierSerializer.serialize(
            UnknownIdentifier(identifier="an id"))

        assert unknown_identifier_model.raw_id is "an id"
    def test_serialize_phone_number(self):
        phone_number_identifier_model = CommunicationUserIdentifierSerializer.serialize(
            PhoneNumberIdentifier("phonenumber"))

        assert phone_number_identifier_model.phone_number.value is "phonenumber"