def test_put(self, es):
        sn = SplitterNotices()
        doc = {
            "some": "structure",
            "effective_on": "2011-01-01",
            "fr_url": "http://example.com",
            "publication_date": "2010-02-02",
            "cfr_parts": ["222"],
        }
        sn.put("docdoc", doc)

        notices = Notice.objects.all()
        self.assertEqual(1, len(notices))
        self.assertEqual("docdoc", notices[0].document_number)
        self.assertEqual(date(2011, 1, 1), notices[0].effective_on)
        self.assertEqual("http://example.com", notices[0].fr_url)
        self.assertEqual(date(2010, 2, 2), notices[0].publication_date)
        ncp = notices[0].noticecfrpart_set.all()
        self.assertEqual(1, len(ncp))
        self.assertEqual("222", ncp[0].cfr_part)
        self.assertEqual(doc, notices[0].notice)

        self.assertTrue(es.return_value.index.called)
        args, kwargs = es.return_value.index.call_args
        self.assertEqual(3, len(args))
        self.assertEqual("notice", args[1])
        self.assertEqual(doc, args[2])
        self.assertTrue("id" in kwargs)
        self.assertEqual("docdoc", kwargs["id"])
    def test_put_overwrite(self, es):
        sn = SplitterNotices()
        doc = {
            "some": "structure",
            "effective_on": "2011-01-01",
            "fr_url": "http://example.com",
            "publication_date": "2010-02-02",
            "cfr_part": "222",
        }
        sn.put("docdoc", doc)

        notices = Notice.objects.all()
        self.assertEqual(1, len(notices))
        self.assertEqual("http://example.com", notices[0].fr_url)

        doc["fr_url"] = "url2"
        sn.put("docdoc", doc)

        notices = Notice.objects.all()
        self.assertEqual(1, len(notices))
        self.assertEqual("url2", notices[0].fr_url)