<commit_before>import pytest


class TestFind:

    async def test(self, spawn_client, static_time):
        client = await spawn_client()

        await client.db.indexes.insert_many([
            {
                "_id": "foo",
                "version": 0,
                "created_at": static_time,
                "virus_count": 231,
                "ready": True,
                "has_files": True,
                "user": {
                    "id": "test"
                },
                "job": {
                    "id": "abh675"
                }
            },
            {
                "_id": "bar",
                "version": 1,
                "created_at": static_time,
                "virus_count": 232,
                "ready": False,
                "has_files": True,
                "user": {
                    "id": "test"
                },
                "job": {
                    "id": "sj82la"
                }
            }
        ])

        resp = await client.get("/api/indexes")

        assert resp.status == 200

        assert await resp.json() == {
            "documents": [
                {
                    "created_at": "2017-10-06T20:00:00Z",
                    "has_files": True,
                    "id": "bar",
                    "job": {
                        "id": "sj82la"
                    },
                    "ready": False,
                    "user": {
                        "id": "test"
                    },
                    "version": 1,
                    "virus_count": 232
                },
                {
                    "created_at": "2017-10-06T20:00:00Z",
                    "has_files": True,
                    "id": "foo",
                    "job": {
                        "id": "abh675"
                    },
                    "ready": True,
                    "user": {
                        "id": "test"
                    },
                    "version": 0,
                    "virus_count": 231
                }
            ],
            "modified_virus_count": 0,
            "total_virus_count": 0
        }


class TestGet:

    async def test(self, spawn_client, static_time):
        client = await spawn_client()

        await client.db.indexes.insert_one({
            "_id": "foobar",
            "version": 0,
            "created_at": static_time,
            "virus_count": 232,
            "ready": False,
            "has_files": True,<commit_msg>Fix failing indexes API test<commit_after>import pytest


class TestFind:

    async def test(self, spawn_client, static_time):
        client = await spawn_client()

        await client.db.indexes.insert_many([
            {
                "_id": "foo",
                "version": 0,
                "created_at": static_time,
                "virus_count": 231,
                "ready": True,
                "has_files": True,
                "user": {
                    "id": "test"
                },
                "job": {
                    "id": "abh675"
                }
            },
            {
                "_id": "bar",
                "version": 1,
                "created_at": static_time,
                "virus_count": 232,
                "ready": False,
                "has_files": True,
                "user": {
                    "id": "test"
                },
                "job": {
                    "id": "sj82la"
                }
            }
        ])

        resp = await client.get("/api/indexes")

        assert resp.status == 200

        assert await resp.json() == {
            "documents": [
                {
                    "created_at": "2017-10-06T20:00:00Z",
                    "has_files": True,
                    "id": "bar",
                    "job": {
                        "id": "sj82la"
                    },
                    "ready": False,
                    "user": {
                        "id": "test"
                    },
                    "version": 1,
                    "virus_count": 232
                },
                {
                    "created_at": "2017-10-06T20:00:00Z",
                    "has_files": True,
                    "id": "foo",
                    "job": {
                        "id": "abh675"
                    },
                    "ready": True,
                    "user": {
                        "id": "test"
                    },
                    "version": 0,
                    "virus_count": 231
                }
            ],
            "total_count": 2,
            "found_count": 2,
            "page": 1,
            "page_count": 1,
            "per_page": 15,
            "modified_virus_count": 0,
            "total_virus_count": 0
        }


class TestGet:

    async def test(self, spawn_client, static_time):
        client = await spawn_client()

        await client.db.indexes.insert_one({
            "_id": "foobar",
            "version": 0,
            "created_at": static_time,
            "virus_count": 232,
            "ready": False,
            "has_files": True,
{'fraction_non_alphanumeric': 0.1207870640950711, 'fraction_numerical': 0.02571595558153127, 'mean_word_length': 0.7969898494924746, 'pattern_counts': {'":': 103, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4308541', 'n_tokens_mistral': 1515, 'n_tokens_neox': 1279, 'n_words': 261}