Fakultas Ilmu Komputer UI

Commit 47b5b802 authored by Nabila Febri Viola's avatar Nabila Febri Viola
Browse files

[RED] Add test for acara donor seeder with email provided

parent 97b2e23c
Pipeline #48783 failed with stages
in 1 minute and 2 seconds
from io import StringIO
from django.core.management import call_command
from django.core.management import call_command, CommandError
from django.test import TestCase
from main.factories import UserFactory
class SeedAcaraDonorTest(TestCase):
......@@ -9,3 +10,22 @@ class SeedAcaraDonorTest(TestCase):
out = StringIO()
call_command('acara_donor_seeder', stdout=out)
self.assertIn('Success', out.getvalue())
def test_command_with_email_provided_success(self):
user1 = UserFactory(email="tes1@gmail.com")
user2 = UserFactory(email="tes2@gmail.com")
user1.save()
user2.save()
out = StringIO()
call_command(
'acara_donor_seeder', users_emails=["tes1@gmail.com",
"tes2@gmail.com"],
stdout=out)
self.assertIn('Success', out.getvalue())
def test_command_with_email_provided_failed(self):
out = StringIO()
with self.assertRaisesMessage(CommandError,
'User bities@gmail.com does not exist.'):
call_command('acara_donor_seeder',
users_emails=["bities@gmail.com", ], stdout=out)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment