# Path: federation/entities/base.py
# class Post(RawContentMixin, PublicMixin, CreatedAtMixin, ProviderDisplayNameMixin, BaseEntity):
#     """Reflects a post, status message, etc, which will be composed from the message or to the message."""
#     location = ""
#     url = ""
# 
#     _allowed_children = (Image,)
#     _default_activity = ActivityType.CREATE
# 
# class Profile(CreatedAtMixin, OptionalRawContentMixin, PublicMixin, BaseEntity):
#     """Represents a profile for a user."""
#     atom_url = ""
#     email = ""
#     gender = ""
#     image_urls = None
#     location = ""
#     name = ""
#     nsfw = False
#     public_key = ""
#     tag_list = None
#     url = ""
#     username = ""
#     inboxes: Dict = None
# 
#     _allowed_children = (Image,)
# 
#     def __init__(self, *args, **kwargs):
#         self.image_urls = {
#             "small": "", "medium": "", "large": ""
#         }
#         self.inboxes = {
#             "private": None,
#             "public": None,
#         }
#         self.tag_list = []
#         super().__init__(*args, **kwargs)
#         # As an exception, a Profile does not require to have an `actor_id`
#         self._required.remove('actor_id')
# 
#     def validate_email(self):
#         if self.email:
#             validator = Email()
#             if not validator.is_valid(self.email):
#                 raise ValueError("Email is not valid")
# 
# class Share(CreatedAtMixin, TargetIDMixin, EntityTypeMixin, OptionalRawContentMixin, PublicMixin,
#             ProviderDisplayNameMixin, BaseEntity):
#     """Represents a share of another entity.
# 
#     ``entity_type`` defaults to "Post" but can be any base entity class name. It should be the class name of the
#     entity that was shared.
# 
#     The optional ``raw_content`` can be used for a "quoted share" case where the sharer adds their own note to the
#     share.
#     """
#     entity_type = "Post"
# 
# class Retraction(CreatedAtMixin, TargetIDMixin, EntityTypeMixin, BaseEntity):
#     """Represents a retraction of content by author."""
# 
#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         # ID not required for retraction
#         self._required.remove('id')
# 
# class Image(OptionalRawContentMixin, CreatedAtMixin, BaseEntity):
#     """Reflects a single image, possibly linked to another object."""
#     url: str = ""
#     name: str = ""
#     height: int = 0
#     width: int = 0
#     inline: bool = False
#     media_type: str = ""
# 
#     _default_activity = ActivityType.CREATE
#     _valid_media_types: Tuple[str] = (
#         "image/jpeg",
#         "image/png",
#         "image/gif",
#     )
# 
#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         self._required += ["url"]
#         self._required.remove("id")
#         self._required.remove("actor_id")
#         if self.url and not self.media_type:
#             self.media_type = self.get_media_type()
# 
#     def get_media_type(self) -> str:
#         media_type = fetch_content_type(self.url)
#         if media_type in self._valid_media_types:
#             return media_type
#         return ""
# 
# class Follow(CreatedAtMixin, TargetIDMixin, BaseEntity):
#     """Represents a handle following or unfollowing another handle."""
#     following = True
# 
#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         self._required += ["following"]
#         # ID not required for follow
#         self._required.remove('id')
# 
# Path: federation/entities/diaspora/entities.py
# class DiasporaPost(DiasporaEntityMixin, Post):
#     """Diaspora post, ie status message."""
#     _tag_name = "status_message"
# 
#     def to_xml(self):
#         """Convert to XML message."""
#         element = etree.Element(self._tag_name)
#         properties = [
#             {"text": self.raw_content},
#             {"guid": self.guid},
#             {"author": self.handle},
#             {"public": "true" if self.public else "false"},
#             {"created_at": format_dt(self.created_at)},
#             {"provider_display_name": self.provider_display_name},
#         ]
#         if self.id and self.id.startswith("http"):
#             properties.append({
#                 "activitypub_id": self.id,
#             })
#         struct_to_xml(element, properties)
#         return element


from random import shuffle
from factory import fuzzy
from federation.entities.base import Post, Profile, Share, Retraction, Image, Follow
from federation.entities.diaspora.entities import DiasporaPost
import factory



class ActorIDMixinFactory(factory.Factory):
    actor_id = factory.Faker('uri')


class EntityTypeMixinFactory(factory.Factory):
    entity_type = 'Post'


class IDMixinFactory(factory.Factory):

# Path: federation/entities/base.py
# class Post(RawContentMixin, PublicMixin, CreatedAtMixin, ProviderDisplayNameMixin, BaseEntity):
#     """Reflects a post, status message, etc, which will be composed from the message or to the message."""
#     location = ""
#     url = ""
# 
#     _allowed_children = (Image,)
#     _default_activity = ActivityType.CREATE
# 
# class Profile(CreatedAtMixin, OptionalRawContentMixin, PublicMixin, BaseEntity):
#     """Represents a profile for a user."""
#     atom_url = ""
#     email = ""
#     gender = ""
#     image_urls = None
#     location = ""
#     name = ""
#     nsfw = False
#     public_key = ""
#     tag_list = None
#     url = ""
#     username = ""
#     inboxes: Dict = None
# 
#     _allowed_children = (Image,)
# 
#     def __init__(self, *args, **kwargs):
#         self.image_urls = {
#             "small": "", "medium": "", "large": ""
#         }
#         self.inboxes = {
#             "private": None,
#             "public": None,
#         }
#         self.tag_list = []
#         super().__init__(*args, **kwargs)
#         # As an exception, a Profile does not require to have an `actor_id`
#         self._required.remove('actor_id')
# 
#     def validate_email(self):
#         if self.email:
#             validator = Email()
#             if not validator.is_valid(self.email):
#                 raise ValueError("Email is not valid")
# 
# class Share(CreatedAtMixin, TargetIDMixin, EntityTypeMixin, OptionalRawContentMixin, PublicMixin,
#             ProviderDisplayNameMixin, BaseEntity):
#     """Represents a share of another entity.
# 
#     ``entity_type`` defaults to "Post" but can be any base entity class name. It should be the class name of the
#     entity that was shared.
# 
#     The optional ``raw_content`` can be used for a "quoted share" case where the sharer adds their own note to the
#     share.
#     """
#     entity_type = "Post"
# 
# class Retraction(CreatedAtMixin, TargetIDMixin, EntityTypeMixin, BaseEntity):
#     """Represents a retraction of content by author."""
# 
#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         # ID not required for retraction
#         self._required.remove('id')
# 
# class Image(OptionalRawContentMixin, CreatedAtMixin, BaseEntity):
#     """Reflects a single image, possibly linked to another object."""
#     url: str = ""
#     name: str = ""
#     height: int = 0
#     width: int = 0
#     inline: bool = False
#     media_type: str = ""
# 
#     _default_activity = ActivityType.CREATE
#     _valid_media_types: Tuple[str] = (
#         "image/jpeg",
#         "image/png",
#         "image/gif",
#     )
# 
#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         self._required += ["url"]
#         self._required.remove("id")
#         self._required.remove("actor_id")
#         if self.url and not self.media_type:
#             self.media_type = self.get_media_type()
# 
#     def get_media_type(self) -> str:
#         media_type = fetch_content_type(self.url)
#         if media_type in self._valid_media_types:
#             return media_type
#         return ""
# 
# class Follow(CreatedAtMixin, TargetIDMixin, BaseEntity):
#     """Represents a handle following or unfollowing another handle."""
#     following = True
# 
#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         self._required += ["following"]
#         # ID not required for follow
#         self._required.remove('id')
# 
# Path: federation/entities/diaspora/entities.py
# class DiasporaPost(DiasporaEntityMixin, Post):
#     """Diaspora post, ie status message."""
#     _tag_name = "status_message"
# 
#     def to_xml(self):
#         """Convert to XML message."""
#         element = etree.Element(self._tag_name)
#         properties = [
#             {"text": self.raw_content},
#             {"guid": self.guid},
#             {"author": self.handle},
#             {"public": "true" if self.public else "false"},
#             {"created_at": format_dt(self.created_at)},
#             {"provider_display_name": self.provider_display_name},
#         ]
#         if self.id and self.id.startswith("http"):
#             properties.append({
#                 "activitypub_id": self.id,
#             })
#         struct_to_xml(element, properties)
#         return element


# Path: federation/tests/factories/entities.py
from random import shuffle
from factory import fuzzy
from federation.entities.base import Post, Profile, Share, Retraction, Image, Follow
from federation.entities.diaspora.entities import DiasporaPost
import factory




class ActorIDMixinFactory(factory.Factory):
    actor_id = factory.Faker('uri')


class EntityTypeMixinFactory(factory.Factory):
    entity_type = 'Post'


class IDMixinFactory(factory.Factory):

    id = factory.Faker('uri')