def test_update_without_change_is_ignored(self): loader = build_mock_loader() importer = Importer(loader, force_singlethread=True) importer.run(self.body["id"]) [paper] = Paper.objects.all() self.assertEqual(paper.history.count(), 1) # The "updated" list still contains the same paper object importer.update(self.body["id"]) [paper] = Paper.objects.all() self.assertEqual(paper.history.count(), 1) # Consistency check: The count is increased if there is actual change update(loader) importer.update(self.body["id"]) [paper] = Paper.objects.all() self.assertEqual(paper.history.count(), 2)
def check_basic_import(self): self.new_timestamp = (self.base_timestamp + relativedelta(years=-100)).isoformat() self.init_mock_loader() importer = Importer(self.loader, force_singlethread=True) importer.run(self.body_id) now = timezone.now() for table, count in self.tables.items(): self.assertEqual( table.objects.count(), count, "{}: {} vs. {}".format(table, count, table.objects.all()), ) self.assertLess(table.objects.first().modified, now) self.assertEqual(File.objects.count(), 6) # Test for #56 self.assertEqual( Meeting.by_oparl_id( "https://oparl.example.org/meeting/281").organizations.count(), 1, )
def test_embedded_update(self): loader = build_mock_loader() importer = Importer(loader, force_singlethread=True) importer.run(self.body["id"]) paper_id = make_paper([])["id"] self.assertEqual(Paper.objects.count(), 1) file_ids = Paper.by_oparl_id(paper_id).files.values_list("oparl_id", flat=True) self.assertEqual( sorted(file_ids), [make_file(0)["id"], make_file(1)["id"]]) self.assertEqual(File.objects.count(), 2) update(loader) importer.update(self.body["id"]) self.assertEqual(Paper.objects.count(), 1) self.assertEqual(File.objects.count(), 2) file_ids = Paper.by_oparl_id(paper_id).files.values_list("oparl_id", flat=True) self.assertEqual( sorted(file_ids), [make_file(1)["id"], make_file(2)["id"]]) self.assertEqual(File.objects_with_deleted.count(), 3)