Maybe almost 100% test coverage
This commit is contained in:
parent
d8065e3f5a
commit
051f4c20f0
@ -18,6 +18,7 @@ import { of } from 'rxjs'
|
|||||||
import { CorrespondentService } from 'src/app/services/rest/correspondent.service'
|
import { CorrespondentService } from 'src/app/services/rest/correspondent.service'
|
||||||
import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
|
import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
|
||||||
import { StoragePathService } from 'src/app/services/rest/storage-path.service'
|
import { StoragePathService } from 'src/app/services/rest/storage-path.service'
|
||||||
|
import { MailRuleService } from 'src/app/services/rest/mail-rule.service'
|
||||||
|
|
||||||
describe('ConsumptionTemplateEditDialogComponent', () => {
|
describe('ConsumptionTemplateEditDialogComponent', () => {
|
||||||
let component: ConsumptionTemplateEditDialogComponent
|
let component: ConsumptionTemplateEditDialogComponent
|
||||||
@ -81,6 +82,15 @@ describe('ConsumptionTemplateEditDialogComponent', () => {
|
|||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
provide: MailRuleService,
|
||||||
|
useValue: {
|
||||||
|
listAll: () =>
|
||||||
|
of({
|
||||||
|
results: [],
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
HttpClientTestingModule,
|
HttpClientTestingModule,
|
||||||
|
@ -26,9 +26,6 @@ import { CheckComponent } from '../../input/check/check.component'
|
|||||||
describe('MailRuleEditDialogComponent', () => {
|
describe('MailRuleEditDialogComponent', () => {
|
||||||
let component: MailRuleEditDialogComponent
|
let component: MailRuleEditDialogComponent
|
||||||
let fixture: ComponentFixture<MailRuleEditDialogComponent>
|
let fixture: ComponentFixture<MailRuleEditDialogComponent>
|
||||||
let accountService: MailAccountService
|
|
||||||
let correspondentService: CorrespondentService
|
|
||||||
let documentTypeService: DocumentTypeService
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
|
43
src/documents/tests/test_migration_consumption_templates.py
Normal file
43
src/documents/tests/test_migration_consumption_templates.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
|
from documents.tests.utils import TestMigrations
|
||||||
|
|
||||||
|
|
||||||
|
class TestMigrateConsumptionTemplate(TestMigrations):
|
||||||
|
migrate_from = "1038_sharelink"
|
||||||
|
migrate_to = "1039_consumptiontemplate"
|
||||||
|
|
||||||
|
def setUpBeforeMigration(self, apps):
|
||||||
|
User = get_user_model()
|
||||||
|
Group = apps.get_model("auth.Group")
|
||||||
|
self.Permission = apps.get_model("auth", "Permission")
|
||||||
|
self.user = User.objects.create(username="user1")
|
||||||
|
self.group = Group.objects.create(name="group1")
|
||||||
|
permission = self.Permission.objects.get(codename="add_document")
|
||||||
|
self.user.user_permissions.add(permission.id)
|
||||||
|
self.group.permissions.add(permission.id)
|
||||||
|
|
||||||
|
def test_users_with_add_documents_get_add_consumptiontemplate(self):
|
||||||
|
permission = self.Permission.objects.get(codename="add_consumptiontemplate")
|
||||||
|
self.assertTrue(self.user.has_perm(f"documents.{permission.codename}"))
|
||||||
|
self.assertTrue(permission in self.group.permissions.all())
|
||||||
|
|
||||||
|
|
||||||
|
class TestReverseMigrateConsumptionTemplate(TestMigrations):
|
||||||
|
migrate_from = "1039_consumptiontemplate"
|
||||||
|
migrate_to = "1038_sharelink"
|
||||||
|
|
||||||
|
def setUpBeforeMigration(self, apps):
|
||||||
|
User = get_user_model()
|
||||||
|
Group = apps.get_model("auth.Group")
|
||||||
|
self.Permission = apps.get_model("auth", "Permission")
|
||||||
|
self.user = User.objects.create(username="user1")
|
||||||
|
self.group = Group.objects.create(name="group1")
|
||||||
|
permission = self.Permission.objects.get(codename="add_consumptiontemplate")
|
||||||
|
self.user.user_permissions.add(permission.id)
|
||||||
|
self.group.permissions.add(permission.id)
|
||||||
|
|
||||||
|
def test_remove_consumptiontemplate_permissions(self):
|
||||||
|
permission = self.Permission.objects.get(codename="add_consumptiontemplate")
|
||||||
|
self.assertFalse(self.user.has_perm(f"documents.{permission.codename}"))
|
||||||
|
self.assertFalse(permission in self.group.permissions.all())
|
Loading…
x
Reference in New Issue
Block a user