Example #1
0
def test_manager_exclude_deleted():
    for _ in range(10):
        HearingFactory()
    for _ in range(3):
        Hearing.objects.first().soft_delete()
    assert Hearing.objects.count() == 7
    assert Hearing.objects.deleted().count() == 3
Example #2
0
def test_manager_exclude_deleted():
    for _ in range(10):
        HearingFactory()
    for _ in range(3):
        Hearing.objects.first().soft_delete()
    assert Hearing.objects.count() == 7
    assert Hearing.objects.deleted().count() == 3
    obj = Hearing.objects.first()
    orig_nb_comments = obj.comments.count()
    for _ in range(10):
        HearingCommentFactory(hearing=obj)
    for _ in range(3):
        obj.comments.first().soft_delete()
    assert obj.comments.count() == (7 + orig_nb_comments)
    assert obj.comments.deleted().count() == 3
    def handle(self, *args, **options):
        if options.pop("nuke", False):
            nuke(command_options=options)

        User = get_user_model()
        if issubclass(User, AbstractUser):
            if not User.objects.filter(username="******").exists():
                User.objects.create_superuser(username="******", email="*****@*****.**", password="******")
                print("Admin user 'admin' (password 'admin') created")
            while User.objects.count() < 25:
                user = UserFactory()
                print("Created user %s" % user.pk)
        while Label.objects.count() < 5:
            label = LabelFactory()
            print("Created label %s" % label.pk)
        while Hearing.objects.count() < 10:
            hearing = HearingFactory()
            print("Created hearing %s" % hearing.pk)
Example #4
0
def random_hearing():
    if not Label.objects.exists():
        LabelFactory()
    return HearingFactory()
Example #5
0
def test_cant_delete():
    hearing = HearingFactory()
    with pytest.raises(NotImplementedError):
        hearing.delete()
    assert hearing.pk
def test_cant_delete():
    hearing = HearingFactory()
    with pytest.raises(NotImplementedError):
        hearing.delete()
    assert hearing.pk