Exemple #1
0
    def test_load_target_list_last_names(self, mock_region):
        mock_region.return_value.names_file = \
            '../recidiviz/tests/ingest/testdata/docket/names/last_only.csv'
        scrape_key = ScrapeKey(REGIONS[0], constants.ScrapeType.BACKGROUND)

        docket.load_target_list(scrape_key)

        names = []
        for _ in range(12):
            item = docket.get_new_docket_item(scrape_key)
            name_serialized = item.message.data.decode()
            names.append(json.loads(name_serialized))
        assert names == [
            ['SMITH', ''],
            ['JOHNSON', ''],
            ['WILLIAMS', ''],
            ['BROWN', ''],
            ['JONES', ''],
            ['MILLER', ''],
            ['DAVIS', ''],
            ['GARCIA', ''],
            ['RODRIGUEZ', ''],
            ['WILSON', ''],
            ['MARTINEZ', ''],
            ['ANDERSON', ''],
        ]
        assert not docket.get_new_docket_item(scrape_key)
Exemple #2
0
    def test_load_target_list_last_names(self, mock_region):
        mock_region.return_value.names_file = (
            "../recidiviz/tests/ingest/testdata/docket/names/last_only.csv")
        scrape_key = ScrapeKey(REGIONS[0], constants.ScrapeType.BACKGROUND)

        docket.load_target_list(scrape_key)

        names = []
        for _ in range(12):
            item = docket.get_new_docket_item(scrape_key)
            name_serialized = item.message.data.decode()
            names.append(json.loads(name_serialized))
        assert names == [
            ["SMITH", ""],
            ["JOHNSON", ""],
            ["WILLIAMS", ""],
            ["BROWN", ""],
            ["JONES", ""],
            ["MILLER", ""],
            ["DAVIS", ""],
            ["GARCIA", ""],
            ["RODRIGUEZ", ""],
            ["WILSON", ""],
            ["MARTINEZ", ""],
            ["ANDERSON", ""],
        ]
        assert not docket.get_new_docket_item(scrape_key)
Exemple #3
0
    def test_load_target_list_full_names(self, mock_region: Mock) -> None:
        mock_region.return_value.names_file = (
            "../recidiviz/tests/ingest/testdata/docket/names/last_and_first.csv"
        )
        scrape_key = ScrapeKey(REGIONS[0], constants.ScrapeType.BACKGROUND)

        docket.load_target_list(scrape_key)

        names = []
        for _ in range(8):
            item = docket.get_new_docket_item(scrape_key)
            assert item is not None
            name_serialized = item.message.data.decode()
            names.append(json.loads(name_serialized))
        assert names == [
            ["Smith", "James"],
            ["Smith", "Michael"],
            ["Smith", "Robert"],
            ["Smith", "David"],
            ["Johnson", "James"],
            ["Johnson", "Michael"],
            ["Smith", "William"],
            ["Williams", "James"],
        ]
        assert not docket.get_new_docket_item(scrape_key)
Exemple #4
0
    def test_load_target_list_background_no_names_file(self, mock_region):
        mock_region.return_value.names_file = None
        scrape_key = ScrapeKey(REGIONS[0], constants.ScrapeType.BACKGROUND)

        docket.load_target_list(scrape_key)

        item = docket.get_new_docket_item(scrape_key)
        assert item.message.data.decode() == json.dumps("empty")
Exemple #5
0
    def test_load_target_list_last_names_with_bad_query(self, mock_region):
        mock_region.return_value.names_file = (
            "../recidiviz/tests/ingest/testdata/docket/names/last_only.csv")
        scrape_key = ScrapeKey(REGIONS[0], constants.ScrapeType.BACKGROUND)

        docket.load_target_list(scrape_key, surname="GARBAGE")

        item = docket.get_new_docket_item(scrape_key)
        assert item.message.data.decode() == json.dumps(("GARBAGE", ""))
        assert not docket.get_new_docket_item(scrape_key)
Exemple #6
0
    def test_load_target_list_last_names_with_query(self, mock_region):
        mock_region.return_value.names_file = (
            "../recidiviz/tests/ingest/testdata/docket/names/last_only.csv")
        scrape_key = ScrapeKey(REGIONS[0], constants.ScrapeType.BACKGROUND)

        docket.load_target_list(scrape_key, surname="WILSON")

        names = []
        for _ in range(3):
            item = docket.get_new_docket_item(scrape_key)
            name_serialized = item.message.data.decode()
            names.append(json.loads(name_serialized))
        assert names == [
            ["WILSON", ""],
            ["MARTINEZ", ""],
            ["ANDERSON", ""],
        ]
        assert not docket.get_new_docket_item(scrape_key)
Exemple #7
0
    def test_load_target_list_full_names(self, mock_region):
        mock_region.return_value.names_file = \
            '../recidiviz/tests/ingest/testdata/docket/names/last_and_first.csv'
        scrape_key = ScrapeKey(REGIONS[0], constants.ScrapeType.BACKGROUND)

        docket.load_target_list(scrape_key)

        names = []
        for _ in range(8):
            item = docket.get_new_docket_item(scrape_key)
            name_serialized = item.message.data.decode()
            names.append(json.loads(name_serialized))
        assert names == [
            ['Smith', 'James'],
            ['Smith', 'Michael'],
            ['Smith', 'Robert'],
            ['Smith', 'David'],
            ['Johnson', 'James'],
            ['Johnson', 'Michael'],
            ['Smith', 'William'],
            ['Williams', 'James'],
        ]
        assert not docket.get_new_docket_item(scrape_key)