def test_more_searches(self):
        project1 = self.create_project()

        # all hashes are 8 characters, followed by abcd
        build1 = self.create_build(project1, label='First commit!',
                                   target='deadbeefabcd')
        build2 = self.create_build(project1, label='Second commit!',
                                   target='dabbad00abcd')
        build3 = self.create_build(project1, label='rThird commit!',
                                   target='facefeedabcd')

        path = '/api/0/projects/{0}/builds/'.format(project1.id.hex)

        queries_to_results = [
            # search by label
            ("First",           [build1]),
            ("rThird",          [build3]),
            ("Fifth",           []),
            ("commit",          [build1, build2, build3]),

            # search by hex, the first few hex characters, and a longer hex
            # phrase
            ("deadbeefabcd",    [build1]),
            ("dabba",           [build2]),
            ("facefeedabcdef",  [build3]),

            # only prefix matches
            ("abcd",            []),

            # phabricator test
            ("rREPOdeadbeefabcd",    [build1]),
            ("rMEPOdabbad00",        [build2]),
            ("rZEPOfacefeedabcdef",  [build3]),
        ]

        errmsg = "test_more_searches failed with search term %s"

        for term, expected_builds in queries_to_results:
            resp = self.client.get(path + '?query=' + term)
            assert resp.status_code == 200, errmsg % term
            data = self.unserialize(resp)
            assert len(data) == len(expected_builds), errmsg.format(term)
            assert set([d['id'] for d in data]) == \
                set([b.id.hex for b in expected_builds]), errmsg % term
dataset/ETHPy150Open dropbox/changes/tests/changes/api/test_project_build_index.py/ProjectBuildListTest.test_more_searches/original