Coverage for jsanctions/tests.py: 100%

# Coverage for jsanctions/tests.py : 100%

## 29 statements

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 import os

2 from django.conf import settings

3 from django.test import TestCase

4 from jsanctions.eu import import_eu_sanctions

5 from jsanctions.models import SanctionEntity, SanctionsListFile

6 from jsanctions.ofac import import_ofac_sanctions

7 from jsanctions.un import import_un_sanctions

8

9

10 class Tests(TestCase):

11 def test_eu_sanctions_import(self):

12 filename = os.path.join(settings.BASE_DIR, "data/eu/2021-03-05.xml")

13 source = SanctionsListFile.objects.create_from_filename(filename)

14 assert isinstance(source, SanctionsListFile)

15 import_eu_sanctions(source, verbose=False)

16 print('EU count =', SanctionEntity.objects.all().filter(source=source).count())

17 self.assertEqual(SanctionEntity.objects.all().filter(source=source).count(), 2269)

18

19 def test_ofac_sanctions_import(self):

20 filename = os.path.join(settings.BASE_DIR, "data/ofac/sdn.xml")

21 source = SanctionsListFile.objects.create_from_filename(filename)

22 assert isinstance(source, SanctionsListFile)

23 import_ofac_sanctions(source, verbose=False)

24 print('OFAC count =', SanctionEntity.objects.all().filter(source=source).count())

25 self.assertEqual(SanctionEntity.objects.all().filter(source=source).count(), 8832)

26

27 def test_un_sanctions_import(self):

28 filename = os.path.join(settings.BASE_DIR, "data/un/consolidated.xml")

29 source = SanctionsListFile.objects.create_from_filename(filename)

30 assert isinstance(source, SanctionsListFile)

31 import_un_sanctions(source, verbose=False)

32 print('UN count =', SanctionEntity.objects.all().filter(source=source).count())

33 self.assertEqual(SanctionEntity.objects.all().filter(source=source).count(), 711+293)