def test_mock_guild_accepts_dynamic_arguments(self):
        guild = helpers.MockGuild(
            emojis=(":hyperjoseph:", ":pensive_ela:"),
            premium_subscription_count=15,
        )

        self.assertTupleEqual(guild.emojis, (":hyperjoseph:", ":pensive_ela:"))
        self.assertEqual(guild.premium_subscription_count, 15)
    def test_mock_guild_default_initialization(self):
        guild = helpers.MockGuild()

        # The `spec` argument makes sure `isistance` checks with `discord.Guild` pass
        self.assertIsInstance(guild, discord.Guild)

        self.assertListEqual(
            guild.roles, [helpers.MockRole(name="@everyone", position=1, id=0)]
        )
        self.assertListEqual(guild.members, [])
    def test_mock_guild_alternative_arguments(self):
        core_developer = helpers.MockRole(name="Core Developer", position=2)
        guild = helpers.MockGuild(
            roles=[core_developer],
            members=[helpers.MockMember(id=54321)],
        )

        self.assertListEqual(
            guild.roles,
            [helpers.MockRole(name="@everyone", position=1, id=0), core_developer],
        )
        self.assertListEqual(guild.members, [helpers.MockMember(id=54321)])
    def test_mocks_rejects_access_to_attributes_not_part_of_spec(self):
        mocks = (
            helpers.MockGuild(),
            helpers.MockRole(),
            helpers.MockMember(),
            helpers.MockBot(),
            helpers.MockContext(),
            helpers.MockTextChannel(),
            helpers.MockMessage(),
        )

        for mock in mocks:
            with self.subTest(mock=mock), self.assertRaises(AttributeError):
                mock.the_cake_is_a_lie
    def test_mocks_allows_access_to_attributes_part_of_spec(self):
        mocks = (
            (helpers.MockGuild(), "name"),
            (helpers.MockRole(), "hoist"),
            (helpers.MockMember(), "display_name"),
            (helpers.MockBot(), "user"),
            (helpers.MockContext(), "invoked_with"),
            (helpers.MockTextChannel(), "last_message"),
            (helpers.MockMessage(), "mention_everyone"),
        )

        for mock, valid_attribute in mocks:
            with self.subTest(mock=mock):
                try:
                    getattr(mock, valid_attribute)
                except AttributeError:
                    msg = f"accessing valid attribute `{valid_attribute}` raised an AttributeError"
                    self.fail(msg)