예제 #1
0
    def test_group_does_not_have_codes(self):
        ctx = FakeContext()
        PromoCodeGroup.create(guild_id=ctx.guild.id, name='foo')
        asyncio.run(list_code(ctx, group_name='foo'))

        self.assertTrue(ctx.send_called)
        self.assertEqual(ctx.send_parameters, "Grupo foo não possui códigos")
예제 #2
0
    def test_group_exist_in_another_guild(self):
        ctx = FakeContext()
        guild2 = FakeGuild2()
        PromoCodeGroup.create(guild_id=guild2.id, name='foo')
        asyncio.run(list_code(ctx, group_name='foo'))

        self.assertTrue(ctx.send_called)
        self.assertEqual(ctx.send_parameters, "Grupo foo não existe")
예제 #3
0
    def test_group_has_codes(self):
        ctx = FakeContext()
        group = PromoCodeGroup.create(guild_id=ctx.guild.id, name='foo')
        PromoCode.create(group=group, code='ASDF-1234')
        asyncio.run(list_code(ctx, group_name='foo'))

        self.assertTrue(ctx.author.send_called)
        self.assertEqual(ctx.author.send_parameters,
                         "Códigos para o grupo foo: \n- ASDF-1234")
예제 #4
0
    def test_group_has_sent_codes(self):
        ctx = FakeContext()
        user = FakeUser()
        group = PromoCodeGroup.create(guild_id=ctx.guild.id, name='foo')
        sent_at = datetime.now()
        promo_code = PromoCode.create(
            group=group,
            code='ASDF-1234',
            sent_to_name=user.name,
            sent_to_id=user.id,
            sent_at=sent_at
        )
        asyncio.run(list_code(ctx, group_name='foo'))

        self.assertTrue(ctx.author.send_called)
        self.assertEqual(
            ctx.author.send_parameters,
            "Códigos para o grupo foo: \n- {0} enviado para o usuário {1} em {2}".format(  # noqa E501
                promo_code.code,
                user.name,
                sent_at.astimezone(LOCAL_TIMEZONE).strftime(DATETIME_FORMAT)
            )
        )
예제 #5
0
    def test_group_does_not_exist(self):
        ctx = FakeContext()
        asyncio.run(list_code(ctx, group_name='foo'))

        self.assertTrue(ctx.send_called)
        self.assertEqual(ctx.send_parameters, "Grupo foo não existe")