Exemplo n.º 1
0
 def put(self, doc_number, notice):
     """Store a single notice"""
     model = Notice(document_number=doc_number,
                    fr_url=notice['fr_url'],
                    publication_date=notice['publication_date'],
                    cfr_part=notice['cfr_part'],
                    notice=notice)
     if 'effective_on' in notice:
         model.effective_on = notice['effective_on']
     model.save()
    def test_listing(self):
        n = Notice(document_number='22', cfr_part='876', fr_url='fr1', 
                   notice={}, effective_on=date(2005, 5, 5),
                   publication_date=date(2001, 3, 3))
        n.save()
        n = Notice(document_number='9', cfr_part='876', fr_url='fr2', 
                   notice={}, publication_date=date(1999, 1, 1))
        n.save()
        n = Notice(document_number='9', cfr_part='111', fr_url='fr2', 
                   notice={}, publication_date=date(1999, 1, 1))
        n.save()

        print self.dmn.listing()

        self.assertEqual([{'document_number': '22', 
                           'cfr_part': '876', 
                           'fr_url': 'fr1',
                           'publication_date': '2001-03-03',
                           'effective_on': '2005-05-05'},
                          {'document_number': '9', 
                           'cfr_part': '876',
                           'fr_url': 'fr2',
                           'publication_date': '1999-01-01'},
                          {'document_number': '9', 
                           'cfr_part': '111',
                           'fr_url': 'fr2',
                           'publication_date': '1999-01-01'}],
                         self.dmn.listing())

        # self.assertEqual(self.dmn.listing(), self.dmn.listing('876'))
        self.assertEqual([], self.dmn.listing('888'))
 def insert(self, doc_number, notice):
     """Store a single notice"""
     model = Notice(document_number=doc_number,
                    fr_url=notice['fr_url'],
                    publication_date=notice['publication_date'],
                    notice=notice)
     if 'effective_on' in notice:
         model.effective_on = notice['effective_on']
     model.save()
     for cfr_part in notice.get('cfr_parts', []):
         model.noticecfrpart_set.create(cfr_part=cfr_part)
Exemplo n.º 4
0
    def test_listing(self):
        n = Notice(document_number='22',
                   fr_url='fr1',
                   notice={},
                   effective_on=date(2005, 5, 5),
                   publication_date=date(2001, 3, 3))
        n.save()
        n.noticecfrpart_set.create(cfr_part='876')
        n = Notice(document_number='9',
                   fr_url='fr2',
                   notice={},
                   publication_date=date(1999, 1, 1))
        n.noticecfrpart_set.create(cfr_part='876')
        n.noticecfrpart_set.create(cfr_part='111')
        n.save()

        self.assertEqual([{
            'document_number': '22',
            'fr_url': 'fr1',
            'publication_date': '2001-03-03',
            'effective_on': '2005-05-05'
        }, {
            'document_number': '9',
            'fr_url': 'fr2',
            'publication_date': '1999-01-01'
        }], self.dmn.listing())

        self.assertEqual(self.dmn.listing(), self.dmn.listing('876'))
        self.assertEqual([], self.dmn.listing('888'))
Exemplo n.º 5
0
    def put(self, doc_number, notice):
        """Store a single notice"""
        Notice.objects.filter(document_number=doc_number).delete()

        model = Notice(document_number=doc_number,
                       fr_url=notice['fr_url'],
                       publication_date=notice['publication_date'],
                       notice=notice)
        if 'effective_on' in notice:
            model.effective_on = notice['effective_on']
        model.save()
        cfr_parts = set(notice.get('cfr_parts', []))
        for cfr_part in cfr_parts:
            model.noticecfrpart_set.create(cfr_part=cfr_part)
Exemplo n.º 6
0
    def put(self, doc_number, part, notice):
        """ Store a single notice """

        Notice.objects.filter(document_number=doc_number,
                cfr_part=part).delete()

        model = Notice(document_number=doc_number,
                       cfr_part=part,
                       fr_url=notice['fr_url'],
                       publication_date=notice['publication_date'],
                       notice=notice)

        if 'effective_on' in notice:
            model.effective_on = notice['effective_on']

        model.save()
Exemplo n.º 7
0
    def put(self, doc_number, part, notice):
        """ Store a single notice """

        Notice.objects.filter(document_number=doc_number,
                              cfr_part=part).delete()

        model = Notice(document_number=doc_number,
                       cfr_part=part,
                       fr_url=notice['fr_url'],
                       publication_date=notice['publication_date'],
                       notice=notice)

        if 'effective_on' in notice:
            model.effective_on = notice['effective_on']

        model.save()
Exemplo n.º 8
0
 def test_get_success(self):
     Notice(document_number='docdoc',
            fr_url='frfr',
            publication_date=date.today(),
            notice={
                "some": "body"
            }).save()
     self.assertEqual({"some": 'body'}, self.dmn.get('docdoc'))