Esempio n. 1
0
    def test_idempotent(self):
        rds = factories.RawDatumFactory.create_batch(55)

        for rd in rds:
            factories.NormalizedDataFactory(raw=rd)

        assert rawdata_janitor() == 0
        assert rawdata_janitor() == 0

        assert IngestJob.objects.count() == 0
Esempio n. 2
0
    def test_idempotent(self, mock_transform):
        rds = factories.RawDatumFactory.create_batch(55)

        for rd in rds:
            factories.NormalizedDataFactory(raw=rd)

        assert rawdata_janitor() == 0
        assert rawdata_janitor() == 0

        assert mock_transform.call_args_list == []
Esempio n. 3
0
    def test_idempotent(self):
        rds = factories.RawDatumFactory.create_batch(55)

        for rd in rds:
            factories.NormalizedDataFactory(raw=rd)

        assert rawdata_janitor() == 0
        assert rawdata_janitor() == 0

        assert IngestJob.objects.count() == 0
Esempio n. 4
0
    def test_some_unprocessed_date(self):
        rds = factories.RawDatumFactory.create_batch(55)
        for rd in rds[:25]:
            factories.NormalizedDataFactory(raw=rd)

        assert rawdata_janitor() == 30
        assert IngestJob.objects.count() == 30
Esempio n. 5
0
    def test_some_unprocessed_date(self):
        rds = factories.RawDatumFactory.create_batch(55)
        for rd in rds[:25]:
            factories.NormalizedDataFactory(raw=rd)

        assert rawdata_janitor() == 30
        assert IngestJob.objects.count() == 30
Esempio n. 6
0
    def test_some_unprocessed_date(self, mock_transform):
        rds = factories.RawDatumFactory.create_batch(55)
        for rd in rds[:25]:
            factories.NormalizedDataFactory(raw=rd)

        assert rawdata_janitor() == 30

        assert sorted(mock_transform.call_args_list) == sorted(
            [mock.call((rd.id, ), throw=True, retries=4) for rd in rds[25:]])
Esempio n. 7
0
    def test_ignores_exceptions(self, mock_transform):
        factories.RawDatumFactory.create_batch(25)

        se = ['test'] * 25
        se[10] = ValueError
        se[20] = TypeError
        mock_transform.side_effect = se

        with mock.patch('share.janitor.tasks.client') as mock_sentry:
            assert rawdata_janitor() == 25
        assert mock_sentry.captureException.called
Esempio n. 8
0
    def test_ignores_no_output(self):
        factories.RawDatumFactory.create_batch(25, no_output=True)

        assert rawdata_janitor() == 0
        assert IngestJob.objects.count() == 0
Esempio n. 9
0
 def test_unprocessed_data(self):
     rds = factories.RawDatumFactory.create_batch(55)
     assert rawdata_janitor() == 55
     assert IngestJob.objects.count() == 55
     assert all(rd.ingest_jobs.count() == 1 for rd in rds)
Esempio n. 10
0
    def test_empty(self):
        rawdata_janitor()

        assert IngestJob.objects.count() == 0
Esempio n. 11
0
    def test_ignores_no_output(self):
        factories.RawDatumFactory.create_batch(25, no_output=True)

        assert rawdata_janitor() == 0
        assert IngestJob.objects.count() == 0
Esempio n. 12
0
 def test_unprocessed_data(self):
     rds = factories.RawDatumFactory.create_batch(55)
     assert rawdata_janitor() == 55
     assert IngestJob.objects.count() == 55
     assert all(rd.ingest_jobs.count() == 1 for rd in rds)
Esempio n. 13
0
    def test_empty(self):
        rawdata_janitor()

        assert IngestJob.objects.count() == 0
Esempio n. 14
0
    def test_ignores_no_output(self, mock_transform):
        factories.RawDatumFactory.create_batch(25, no_output=True)

        assert rawdata_janitor() == 0

        assert mock_transform.call_args_list == []
Esempio n. 15
0
 def test_unprocessed_data(self, mock_transform):
     rds = factories.RawDatumFactory.create_batch(55)
     assert rawdata_janitor() == 55
     assert sorted(mock_transform.call_args_list) == sorted(
         [mock.call((rd.id, ), throw=True, retries=4) for rd in rds])
Esempio n. 16
0
    def test_empty(self, mock_transform):
        rawdata_janitor()

        assert mock_transform.called is False