예제 #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
예제 #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 == []
예제 #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
예제 #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
예제 #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
예제 #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:]])
예제 #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
예제 #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
예제 #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)
예제 #10
0
    def test_empty(self):
        rawdata_janitor()

        assert IngestJob.objects.count() == 0
예제 #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
예제 #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)
예제 #13
0
    def test_empty(self):
        rawdata_janitor()

        assert IngestJob.objects.count() == 0
예제 #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 == []
예제 #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])
예제 #16
0
    def test_empty(self, mock_transform):
        rawdata_janitor()

        assert mock_transform.called is False