Coverage for src/oai/repository_mersenne.py: 0%

17 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-05 09:56 +0000

1from django.conf import settings 

2 

3from oai import oai_helpers 

4from oai.repository import OAIRepository 

5from ptf import model_helpers 

6from ptf.models import Article 

7from ptf.models import SiteMembership 

8 

9 

10class MersenneRepository(OAIRepository): 

11 def Identify(self): 

12 return { 

13 "name": settings.SITE_NAME, 

14 "base_url": f"{settings.SITE_DOMAIN}/oai", 

15 "protocol_version": "2.0", 

16 "admin_email": "mersenne@listes.mathdoc.fr", 

17 "earliest_datestamp": SiteMembership.objects.filter(site__id=settings.SITE_ID) 

18 .order_by("deployed") 

19 .first() 

20 .deployed.strftime("%Y-%m-%d"), 

21 "deleted_record": "no", 

22 "granularity": "YYYY-MM-DDThh:mm:ssZ", 

23 "repositoryIdentifier": "centre-mersenne.org", 

24 "delimiter": ":", 

25 "sample_identifier": f"oai:centre-mersenne.org:{Article.objects.first().pid}", 

26 } 

27 

28 def has_set(self, setspec): 

29 col = model_helpers.get_collection(setspec) 

30 return bool(col) 

31 

32 def listsets(self): 

33 collections = oai_helpers.get_collections() 

34 return [collections] 

35 

36 

37def get_repository(base_url): 

38 # thismodule = sys.modules[__name__] 

39 # repo = settings.REPOSITORIES[base_url] 

40 # repoClass = getattr(thismodule, repo) 

41 return MersenneRepository(base_url)