=DCCReview.STATUS_CONFIRMED)
        get_data = {'q': '', 'forward': ['{"tag":"' + str(tag.pk) + '",' + self.only_arg + '}']}
        response = self.client.get(self.get_url(), get_data)
        pks = get_autocomplete_view_ids(response)
        self.assertNotIn(study.pk, pks)

    def test_does_not_return_study_with_reviewed_needfollowup_tagged_trait_for_given_tag_with_only(self):
        """With tag and only arg forwarded, does not return study with reviewed tagged traits."""
        tag = TagFactory.create()
        study = self.studies[0]
        tagged_trait = TaggedTraitFactory.create(tag=tag, trait__source_dataset__source_study_version__study=study)
        dcc_review = DCCReviewFactory.create(tagged_trait=tagged_trait, status=DCCReview.STATUS_FOLLOWUP)
        get_data = {'q': '', 'forward': ['{"tag":"' + str(tag.pk) + '",' + self.only_arg + '}']}
        response = self.client.get(self.get_url(), get_data)
        pks = get_autocomplete_view_ids(response)
        self.assertNotIn(study.pk, pks)

    def test_does_not_return_study_with_archived_tagged_trait_for_given_tag_with_only(self):
        """With tag and only arg forwarded, does not return study with archived tagged traits."""
        tag = TagFactory.create()
        study = self.studies[0]
        tagged_trait = TaggedTraitFactory.create(
            tag=tag, trait__source_dataset__source_study_version__study=study, archived=True)
        get_data = {'q': '', 'forward': ['{"tag":"' + str(tag.pk) + '",' + self.only_arg + '}']}
        response = self.client.get(self.get_url(), get_data)
        pks = get_autocomplete_view_ids(response)
        self.assertNotIn(study.pk, pks)

    def test_does_not_return_study_with_no_tagged_traits_for_given_tag_with_only(self):
        """With tag and only arg forwarded, does not return study with archived tagged traits."""
        tag = TagFactory.create()
        study = self.studies[0]
        get_data = {'q': '', 'forward': ['{"tag":"' + str(tag.pk) + '",' + self.only_arg + '}']}
        response = self.client.get(self.get_url(), get_data)
        pks = get_autocomplete_view_ids(response)
        self.assertNotIn(study.pk, pks)

    def test_does_not_return_studies_with_unreviewed_tagged_trait_with_other_tag_with_only(self):
        """With tag and only arg forwarded, does not return study with unreviewed tagged traits with other tag."""
        tag = TagFactory.create()
        study = self.studies[0]
        tagged_trait = TaggedTraitFactory.create(tag=tag, trait__source_dataset__source_study_version__study=study)
        other_tag = TagFactory.create()
        other_study = self.studies[1]
        other_tagged_trait = TaggedTraitFactory.create(
            tag=other_tag, trait__source_dataset__source_study_version__study=other_study)
        get_data = {'q': '', 'forward': ['{"tag":"' + str(tag.pk) + '",' + self.only_arg + '}']}
        response = self.client.get(self.get_url(), get_data)
        pks = get_autocomplete_view_ids(response)
        self.assertNotIn(other_study.pk, pks)

    def test_returns_all_studies_with_unreviewed_tagged_traits_without_given_tag_with_only(self):
        """With only arg but no tag forwarded, returns all studies."""
        tag = TagFactory.create()
        tagged_traits = []
        for study in self.studies:
            tmp = TaggedTraitFactory.create(trait__source_dataset__source_study_version__study=study, tag=tag)
            tagged_traits.append(tmp)
        get_data = {'q': '', 'forward': ['{' + self.only_arg + '}']}
        response = self.client.get(self.get_url(), get_data)
        pks = get_autocomplete_view_ids(response)
        self.assertEqual(sorted([study.pk for study in self.studies]), sorted(pks))

    def test_returns_all_studies_with_reviewed_tagged_traits_without_given_tag_with_only(self):
        """With only arg but no tag forwarded, returns studies with reviewed tagged traits."""
        tag = TagFactory.create()
        tagged_traits = []
        for (idx, study) in enumerate(self.studies):
            tmp = TaggedTraitFactory.create(trait__source_dataset__source_study_version__study=study, tag=tag)
            tagged_traits.append(tmp)
            if idx % 2 == 0:
                status = DCCReview.STATUS_CONFIRMED
            else:
                status = DCCReview.STATUS_FOLLOWUP
            DCCReviewFactory.create(tagged_trait=tmp, status=status)
        get_data = {'q': '', 'forward': ['{' + self.only_arg + '}']}
        response = self.client.get(self.get_url(), get_data)
        pks = get_autocomplete_view_ids(response)
        self.assertEqual(sorted([study.pk for study in self.studies]), sorted(pks))

    def test_returns_all_studies_with_archived_tagged_traits_without_given_tag_with_only(self):
        """With only arg but no tag forwarded, returns studies with archived tagged traits."""
        tag = TagFactory.create()
        tagged_traits = []
        for study in self.studies:
            tmp = TaggedTraitFactory.create(trait__source_dataset__source_study_version__study=study,
                                            archived=True, tag=tag)
            tagged_traits.append(tmp)
        get_data = {'q': '', 'forward': ['{' + self.only_arg + '}']}
        response = self.client.get(self.get_url(), get_data)
        pks = get_autocomplete_view_ids(response)
        self.assertEqual(sorted([study.pk for study in self.studies]), sorted(pks))

    def test_returns_all_studies_with_other_tag_without_given_tag_with_only(self):
        """With only arg but no tag forwarded, returns studies with tagged traits with other tag."""
        tag = TagFactory.create()
        study = self.studies[0]
        tagged_trait = TaggedTraitFactory.create(tag=tag, trait__source_dataset__source_study_version__study=study)
        other_tag = TagFactory.create()
        other_study = self.studies[1]
        other_tagged_trait = TaggedTraitFactory.create(
            tag=other_tag, trait__source_dataset__source_study_version__study=other_study)
        get_data = {'q': '', 'forward': ['{' + self.only_arg + '}']}
        response = self.client.get(self.get_url(), get_data)
        pks = get_autocomplete_view_ids(response)
        self.assertIn(other_study.pk, pks)
        self.assertEqual(sorted([study.pk for study in self.studies]), sorted(pks))

    def test_returns_all_studies_without_tagged_traits_without_given_tag_with_only(self):
        """With only arg but no tag forwarded, returns even studies without any tagged traits."""
        tag = TagFactory.create()
        study = self.studies[0]
        get_data = {'q': '', 'forward': ['{' + self.only_arg