Exemplo 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
Exemplo 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 == []
Exemplo 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
Exemplo 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
Exemplo 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
Exemplo 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:]])
Exemplo 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
Exemplo 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
Exemplo 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)
Exemplo n.º 10
0
    def test_empty(self):
        rawdata_janitor()

        assert IngestJob.objects.count() == 0
Exemplo 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
Exemplo 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)
Exemplo n.º 13
0
    def test_empty(self):
        rawdata_janitor()

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

        assert mock_transform.called is False