コード例 #1
0
ファイル: data_body_test.py プロジェクト: banek/h
    def test_create_ok(self):
        data = CreateGroupMembership.create("acct:[email protected]",
                                            "reference")

        assert data.raw == {
            "data": {
                "relationships": {
                    "group": {
                        "data": {
                            "id": {
                                "$ref": "reference"
                            },
                            "type": "group"
                        }
                    },
                    "member": {
                        "data": {
                            "id": "acct:[email protected]",
                            "type": "user"
                        }
                    },
                },
                "type": "group_membership",
            }
        }
コード例 #2
0
    def test_accessors(self, create_group_membership_body):
        body = CreateGroupMembership(create_group_membership_body)

        assert body.member.id is None
        assert body.member.ref == "user_ref"
        assert body.group.id is None
        assert body.group.ref == "group_ref"
コード例 #3
0
    def test_create_ok(self):
        body = CreateGroupMembership.create("user_ref", "group_ref")

        assert body.raw == {
            "data": {
                "relationships": {
                    "member": {
                        "data": {
                            "id": {
                                "$ref": "user_ref"
                            },
                            "type": "user"
                        }
                    },
                    "group": {
                        "data": {
                            "id": {
                                "$ref": "group_ref"
                            },
                            "type": "group"
                        }
                    },
                },
                "type": "group_membership",
            }
        }
コード例 #4
0
ファイル: data_body_test.py プロジェクト: banek/h
 def test_validation_can_fail(self):
     with pytest.raises(SchemaValidationError):
         CreateGroupMembership({
             "data": {
                 "type": "group_membership",
                 "relationships": {
                     # This isn't good enough, these should have bodies
                     "member": {},
                     "group": {},
                 },
             }
         })
コード例 #5
0
ファイル: command_builder.py プロジェクト: manhncse02926/h
        def create(cls, user_ref, group_ref):
            """
            Create a group membership create.

            As the group and user ids are not known at command creation time,
            a custom reference can be supplied to the group which is then used
            here to link the two.

            :param user_ref: Custom reference to the user
            :param group_ref: Custom reference to the group
            :rtype: CreateCommand
            """
            return CreateCommand.create(
                CommandType.CREATE, CreateGroupMembership.create(user_ref, group_ref)
            )
コード例 #6
0
ファイル: data_body_test.py プロジェクト: banek/h
 def test_create_can_fail(self):
     with pytest.raises(SchemaValidationError):
         CreateGroupMembership.create("bad", None)
コード例 #7
0
ファイル: data_body_test.py プロジェクト: banek/h
    def test_accessors(self, create_group_membership_body):
        data = CreateGroupMembership(create_group_membership_body)

        assert data.member_id == "acct:[email protected]"
        assert data.group_id is None
        assert data.group_ref == "thing"
コード例 #8
0
ファイル: id_references_test.py プロジェクト: banek/h
    def group_membership_body(self):
        group_membership = CreateGroupMembership.create(
            "acct:[email protected]", "group_ref"
        )

        return group_membership.raw
コード例 #9
0
ファイル: id_references_test.py プロジェクト: manhncse02926/h
    def group_membership_body(self):
        group_membership = CreateGroupMembership.create(
            "user_ref", "group_ref")

        return group_membership.raw