Fakultas Ilmu Komputer UI

Commit 35c7e1e6 authored by Farhan Azyumardhi Azmi's avatar Farhan Azyumardhi Azmi
Browse files

[GREEN] Add test case for removedummy management command

parent 268a2b9e
Pipeline #56931 passed with stages
in 7 minutes and 55 seconds
......@@ -9,6 +9,7 @@ from django.test import Client, RequestFactory, TestCase
from django.db import IntegrityError
from django.urls import resolve
from administration.models import VerificationSetting, VerificationReport
from administration.utils import id_generator
from app.views import UploadMateriView
from authentication.models import User
......@@ -931,9 +932,10 @@ class RevisiMateriTest(TestCase):
class GenerateDummyCommandTest(TestCase):
material_numbers = [5, 10, 25, 100]
invalid_material_numbers = [-100, -10, -1, 0, 1, 2, 3, 4]
stdout = StringIO()
def setUp(self):
self.material_numbers = [5, 10, 25, 100]
self.invalid_material_numbers = [-100, -10, -1, 0, 1, 2, 3, 4]
self.stdout = StringIO()
def test_command_output_with_given_num_of_materi(self):
for num_of_materi in self.material_numbers:
......@@ -955,6 +957,22 @@ class GenerateDummyCommandTest(TestCase):
call_command("generatedummy", num_of_materi)
class RemoveDummyCommandTest(TestCase):
def test_calling_remove_dummy_command_should_remove_generated_dummy_objects(self):
stdout = StringIO()
call_command("generatedummy", 50)
call_command("removedummy", stdout=stdout)
self.assertEqual("Successfully remove all dummy object\n", stdout.getvalue())
self.assertEqual(User.objects.count(), 0)
self.assertEqual(Category.objects.count(), 0)
self.assertEqual(Materi.objects.count(), 0)
self.assertEqual(VerificationSetting.objects.count(), 0)
self.assertEqual(VerificationReport.objects.count(), 0)
class RatingMateriTest(TestCase):
def setUp(self):
self.url = '/administration/'
......
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