from datetime import datetime, timezone from kab_ingestion.github import GitHubConnector from kab_ingestion.sharepoint import SharePointConnector class Secrets: def get(self, ref): return 'token' class GH: def list_files(self,*a): return [{'path':'docs/a.md','content':'hello','mime_type':'text/markdown','sha':'1','html_url':'u'}] def list_changed(self,*a): return self.list_files() class SP: def list_files(self,*a): return [{'id':'1','name':'a.html','text':'x','mime_type':'text/html','web_url':'u','last_modified':datetime.now(timezone.utc)}] def delta(self,*a): return self.list_files(), 'next' def test_github_scope_and_normalization(): c=GitHubConnector(GH(),Secrets(),{'owner':'o','repo':'r','path_prefix':'docs/','credential_ref':'s'}) assert c.full('t').documents[0].document_id == 'github:1' def test_sharepoint_normalization(): c=SharePointConnector(SP(),Secrets(),{'site_id':'s','drive_id':'d','credential_ref':'x'}) assert c.full('t').documents[0].mime_type == 'text/html'