Beispiel #1
0
    def test_drafts_for_user_omits_registered(self):
        prereg_schema = MetaSchema.find_one(
            Q('name', 'eq', 'Prereg Challenge') & Q('schema_version', 'eq', 2))

        d1 = factories.DraftRegistrationFactory(
            initiator=self.user, registration_schema=prereg_schema)
        d2 = factories.DraftRegistrationFactory(
            initiator=self.user, registration_schema=prereg_schema)
        d3 = factories.DraftRegistrationFactory(
            initiator=self.user, registration_schema=prereg_schema)
        d1.registered_node = factories.ProjectFactory()
        d1.save()
        drafts = drafts_for_user(self.user, 'prereg')
        for d in drafts:
            assert_in(d._id, (d2._id, d3._id))
            assert_not_equal(d._id, d1._id)
Beispiel #2
0
    def test_has_project_and_draft_registration(self):
        prereg_schema = MetaSchema.find_one(Q('name', 'eq',
                                              'Prereg Challenge'))
        factories.DraftRegistrationFactory(initiator=self.user,
                                           registration_schema=prereg_schema)

        assert_equal(landing_page(user=self.user), {
            'has_projects': True,
            'has_draft_registrations': True,
        })
Beispiel #3
0
    def test_prereg(self):
        meta = {'q1': {'value': fake.sentence()}}

        node = factories.NodeFactory(creator=self.osf_user)
        prereg_pending = []
        for i in range(3):
            draft = factories.DraftRegistrationFactory(
                branched_from=node,
                registration_schema=self.prereg_schema,
                registration_metadata=meta)
            draft.submit_for_review(self.osf_user,
                                    {'registration_choice': 'immediate'},
                                    save=True)
            prereg_pending.append(draft)
        non_prereg_pending = []
        for i in range(3):
            draft = factories.DraftRegistrationFactory(
                branched_from=node, registration_schema=self.other_schema)
            draft.submit_for_review(self.osf_user,
                                    {'registration_choice': 'immediate'},
                                    save=True)
            non_prereg_pending.append(draft)
        prereg_not_pending = []
        for i in range(3):
            draft = factories.DraftRegistrationFactory(
                branched_from=node, registration_schema=self.prereg_schema)
            prereg_not_pending.append(draft)
        non_prereg_not_pending = []
        for i in range(3):
            draft = factories.DraftRegistrationFactory(
                branched_from=node, registration_schema=self.other_schema)
            non_prereg_not_pending.append(draft)

        url = reverse('pre_reg:prereg')
        res = self.client.get(url)

        assert_equal(res.status_code, http.OK)
        assert_in('drafts', res.context)
        assert_equal(len(res.context['drafts']), len(prereg_pending))
        for draft in res.context['drafts']:
            assert_in(draft['pk'], [d._id for d in prereg_pending])
Beispiel #4
0
 def setUpPrereg(self):
     ensure_schemas()
     self.prereg_challenge_admin_user = AuthUserFactory()
     self.prereg_challenge_admin_user.system_tags.append(settings.PREREG_ADMIN_TAG)
     self.prereg_challenge_admin_user.save()
     prereg_schema = MetaSchema.find_one(
             Q('name', 'eq', 'Prereg Challenge') &
             Q('schema_version', 'eq', 2)
     )
     # import ipdb; ipdb.set_trace()
     self.draft_registration = factories.DraftRegistrationFactory(
             initiator=self.user,
             registration_schema=prereg_schema
     )
Beispiel #5
0
    def setUp(self):
        super(TestCheckPreregAuth, self).setUp()

        ensure_schemas()
        self.prereg_challenge_admin_user = AuthUserFactory()
        self.prereg_challenge_admin_user.system_tags.append(
            settings.PREREG_ADMIN_TAG)
        self.prereg_challenge_admin_user.save()
        prereg_schema = MetaSchema.find_one(
            Q('name', 'eq', 'Prereg Challenge') & Q('schema_version', 'eq', 2))

        self.user = AuthUserFactory()
        self.node = factories.ProjectFactory(creator=self.user)

        self.parent = factories.ProjectFactory()
        self.child = factories.NodeFactory(parent=self.parent)

        self.draft_registration = factories.DraftRegistrationFactory(
            initiator=self.user,
            registration_schema=prereg_schema,
            branched_from=self.parent)
    def setUp(self):
        super(TestMigratePreregMetadata, self).setUp()

        self.draft = factories.DraftRegistrationFactory(
            registration_metadata=SCHEMA_DATA)