def get_mock_loader(self) -> BaseLoader: return MockLoader( self.system, { self.system["id"]: self.system, self.system["body"]: make_list([self.body]), self.body["id"]: self.body, self.body["meeting"]: make_list([]), self.body["organization"]: make_list([]), self.body["person"]: make_list([]), self.body["paper"]: make_list([]), }, )
def cron_unfinished(self, loader): # In[] # Mock an extern list with changes to both paper new_date = timezone.now().astimezone().replace(microsecond=0) file1 = make_file(1) file2 = make_file(2) file2["modified"] = new_date file1["modified"] = new_date paper1 = make_paper([file1], paper_id=1) paper1["modified"] = new_date paper2 = make_paper([file2], paper_id=2) paper2["modified"] = new_date loader.api_data[self.body["paper"]] = make_list([paper1, paper2]) # In[] # Check that exactely the one user got one notification for the one paper self.run_cron(loader, 1) # In[] # Check the user only gets one notification for the event self.run_cron(loader, 0)
def build_mock_loader() -> MockLoader: system = make_system() body = make_body() loader = MockLoader(system) old_paper = make_paper([make_file(0), make_file(1)]) loader.api_data = { system["id"]: system, system["body"]: make_list([body]), body["id"]: body, body["paper"]: make_list([old_paper]), body["person"]: make_list([]), body["organization"]: make_list([]), body["meeting"]: make_list([]), } return loader
def update(loader: MockLoader): changed_file = make_file(1) changed_file["name"] = "changed" new_paper = make_paper([changed_file, make_file(2)]) loader.api_data[make_body()["paper"]] = make_list([new_paper]) deleted_file = make_file(0) deleted_file["deleted"] = True loader.api_data[deleted_file["id"]] = deleted_file new_file = make_file(2) loader.api_data[new_file["id"]] = new_file