Пример #1
0
 def node_in_conference(self, user):
     node = ProjectFactory(creator=user, is_public=True)
     con = ConferenceFactory()
     con.auto_check_spam = False
     con.submissions.add(node)
     con.save()
     return node
 def meeting(self):
     return ConferenceFactory(
         name='OSF 2019',
         endpoint='osf2019',
         location='Boulder, CO',
         poster=True,
         talk=False,
     )
    def test_conference_submissions(self):
        AbstractNode.objects.all().delete()
        conference1 = ConferenceFactory()
        conference2 = ConferenceFactory()
        # Create conference nodes
        create_fake_conference_nodes(
            3,
            conference1,
        )
        create_fake_conference_nodes(
            2,
            conference2,
        )

        url = api_url_for('conference_submissions')
        res = self.app.get(url)
        assert_equal(res.json['success'], True)
Пример #4
0
    def test_conference_submissions(self):
        AbstractNode.remove()
        conference1 = ConferenceFactory()
        conference2 = ConferenceFactory()
        # Create conference nodes
        create_fake_conference_nodes(
            3,
            conference1.endpoint,
        )
        create_fake_conference_nodes(
            2,
            conference2.endpoint,
        )

        url = api_url_for('conference_submissions')
        res = self.app.get(url)
        assert_equal(res.json['success'], True)
Пример #5
0
def create_eligible_conference(active=True):
    conference = ConferenceFactory(active=active)
    for i in range(0, 5):
        project = ProjectFactory(is_public=True)
        project.add_tag(conference.endpoint, Auth(project.creator))
        project.save()
        api_utils.create_test_file(project, project.creator, create_guid=False)
    return conference
def create_eligible_conference(active=True):
    conference = ConferenceFactory(active=active)
    for i in range(0, 5):
        project = ProjectFactory(is_public=True)
        conference.submissions.add(project)
        project.save()
        api_utils.create_test_file(project, project.creator, create_guid=False)
    return conference
Пример #7
0
 def test_integration(self, mock_upload, mock_send_mail):
     fullname = 'John Deacon'
     username = '******'
     title = 'good songs'
     conference = ConferenceFactory()
     body = 'dragon on my back'
     content = 'dragon attack'
     recipient = '{0}{1}[email protected]'.format(
         'test-' if settings.DEV_MODE else '',
         conference.endpoint,
     )
     self.app.post(
         api_url_for('meeting_hook'),
         {
             'X-Mailgun-Sscore':
             0,
             'timestamp':
             '123',
             'token':
             'secret',
             'signature':
             hmac.new(
                 key=settings.MAILGUN_API_KEY.encode(),
                 msg='{}{}'.format('123', 'secret').encode(),
                 digestmod=hashlib.sha256,
             ).hexdigest(),
             'attachment-count':
             '1',
             'X-Mailgun-Sscore':
             0,
             'from':
             '{0} <{1}>'.format(fullname, username),
             'recipient':
             recipient,
             'subject':
             title,
             'stripped-text':
             body,
         },
         upload_files=[
             ('attachment-1', 'attachment-1', content.encode()),
         ],
     )
     assert_true(mock_upload.called)
     users = OSFUser.objects.filter(username=username)
     assert_equal(users.count(), 1)
     nodes = AbstractNode.objects.filter(title=title)
     assert_equal(nodes.count(), 1)
     node = nodes[0]
     assert_equal(
         WikiVersion.objects.get_for_node(node, 'home').content, body)
     assert_true(mock_send_mail.called)
     call_args, call_kwargs = mock_send_mail.call_args
     assert_absolute(call_kwargs['conf_view_url'])
     assert_absolute(call_kwargs['set_password_url'])
     assert_absolute(call_kwargs['profile_url'])
     assert_absolute(call_kwargs['file_url'])
     assert_absolute(call_kwargs['node_url'])
Пример #8
0
 def test_integration_wo_full_name(self, mock_upload, mock_send_mail):
     username = '******'
     title = 'no full name only email'
     conference = ConferenceFactory()
     body = 'dragon on my back'
     content = 'dragon attack'
     recipient = '{0}{1}[email protected]'.format(
         'test-' if settings.DEV_MODE else '',
         conference.endpoint,
     )
     self.app.post(
         api_url_for('meeting_hook'),
         {
             'X-Mailgun-Sscore':
             0,
             'timestamp':
             '123',
             'token':
             'secret',
             'signature':
             hmac.new(
                 key=settings.MAILGUN_API_KEY,
                 msg='{}{}'.format('123', 'secret'),
                 digestmod=hashlib.sha256,
             ).hexdigest(),
             'attachment-count':
             '1',
             'X-Mailgun-Sscore':
             0,
             'from':
             username,
             'recipient':
             recipient,
             'subject':
             title,
             'stripped-text':
             body,
         },
         upload_files=[
             ('attachment-1', 'attachment-1', content),
         ],
     )
     assert_true(mock_upload.called)
     users = OSFUser.find(Q('username', 'eq', username))
     assert_equal(users.count(), 1)
     nodes = AbstractNode.find(Q('title', 'eq', title))
     assert_equal(nodes.count(), 1)
     node = nodes[0]
     assert_equal(node.get_wiki_page('home').content, body)
     assert_true(mock_send_mail.called)
     call_args, call_kwargs = mock_send_mail.call_args
     assert_absolute(call_kwargs['conf_view_url'])
     assert_absolute(call_kwargs['set_password_url'])
     assert_absolute(call_kwargs['profile_url'])
     assert_absolute(call_kwargs['file_url'])
     assert_absolute(call_kwargs['node_url'])
    def test_add_poster_by_email(self, mock_upload_attachments):
        conference = ConferenceFactory()

        with self.make_context(data={'from': '*****@*****.**', 'subject': 'It\'s PARTY TIME!'}):
            msg = message.ConferenceMessage()
            views.add_poster_by_email(conference, msg)

        user = OSFUser.objects.get(username='******')
        assert user.email == '*****@*****.**'
        assert user.fullname == user._id  # user's shouldn't be able to use email as fullname, so we use the guid.
Пример #10
0
 def test_route_valid_alternate(self):
     conf = ConferenceFactory(endpoint='chocolate', active=True)
     conf.name = 'Chocolate Conference'
     conf.field_names['submission2'] = 'data'
     conf.save()
     recipient = '{0}[email protected]'.format('test-' if settings.DEV_MODE else '')
     with self.make_context(data={'recipient': recipient}):
         self.app.app.preprocess_request()
         msg = message.ConferenceMessage()
         assert_equal(msg.conference_name, 'chocolate')
         assert_equal(msg.conference_category, 'data')
     conf.__class__.remove_one(conf)
Пример #11
0
 def setUp(self):
     super(TestProvisionNode, self).setUp()
     self.node = ProjectFactory()
     self.user = self.node.creator
     self.conference = ConferenceFactory()
     self.body = 'dragon on my back'
     self.content = 'dragon attack'
     self.attachment = StringIO(self.content)
     self.recipient = '{0}{1}[email protected]'.format(
         'test-' if settings.DEV_MODE else '',
         self.conference.endpoint,
     )
Пример #12
0
    def test_create_conference_node_with_same_name_as_existing_node(
            self, mock_upload, mock_send_mail):
        conference = ConferenceFactory()
        user = UserFactory()
        title = 'Long Live Greg'
        ProjectFactory(creator=user, title=title)

        body = 'Greg is a good plant'
        content = 'Long may they reign.'
        recipient = '{0}{1}[email protected]'.format(
            'test-' if settings.DEV_MODE else '',
            conference.endpoint,
        )
        self.app.post(
            api_url_for('meeting_hook'),
            {
                'X-Mailgun-Sscore':
                0,
                'timestamp':
                '123',
                'token':
                'secret',
                'signature':
                hmac.new(
                    key=settings.MAILGUN_API_KEY.encode(),
                    msg='{}{}'.format('123', 'secret').encode(),
                    digestmod=hashlib.sha256,
                ).hexdigest(),
                'attachment-count':
                '1',
                'X-Mailgun-Sscore':
                0,
                'from':
                '{0} <{1}>'.format(user.fullname, user.username),
                'recipient':
                recipient,
                'subject':
                title,
                'stripped-text':
                body,
            },
            upload_files=[
                ('attachment-1', 'attachment-1', content.encode()),
            ],
        )

        assert AbstractNode.objects.filter(title=title,
                                           creator=user).count() == 2
        assert mock_upload.called
        assert mock_send_mail.called
Пример #13
0
 def test_integration_inactive(self, mock_send_mail):
     conference = ConferenceFactory(active=False)
     fullname = 'John Deacon'
     username = '******'
     title = 'good songs'
     body = 'dragon on my back'
     recipient = '{0}{1}[email protected]'.format(
         'test-' if settings.DEV_MODE else '',
         conference.endpoint,
     )
     res = self.app.post(
         api_url_for('meeting_hook'),
         {
             'X-Mailgun-Sscore':
             0,
             'timestamp':
             '123',
             'token':
             'secret',
             'signature':
             hmac.new(
                 key=settings.MAILGUN_API_KEY,
                 msg='{}{}'.format('123', 'secret'),
                 digestmod=hashlib.sha256,
             ).hexdigest(),
             'attachment-count':
             '1',
             'X-Mailgun-Sscore':
             0,
             'from':
             '{0} <{1}>'.format(fullname, username),
             'recipient':
             recipient,
             'subject':
             title,
             'stripped-text':
             body,
         },
         expect_errors=True,
     )
     assert_equal(res.status_code, 406)
     call_args, call_kwargs = mock_send_mail.call_args
     assert_equal(call_args, (username, views.CONFERENCE_INACTIVE))
     assert_equal(call_kwargs['fullname'], fullname)
     assert_equal_urls(
         call_kwargs['presentations_url'],
         web_url_for('conference_view', _absolute=True),
     )
Пример #14
0
    def test_conference_data_tag_upper(self):
        conference = ConferenceFactory()

        # Create conference nodes
        n_conference_nodes = 3
        create_fake_conference_nodes(
            n_conference_nodes,
            conference.endpoint.upper(),
        )
        # Create a non-conference node
        ProjectFactory()

        url = api_url_for('conference_data', meeting=conference.endpoint)
        res = self.app.get(url)
        assert_equal(res.status_code, 200)
        assert_equal(len(res.json), n_conference_nodes)
Пример #15
0
    def test_conference_bad_data(self):
        conference = ConferenceFactory()

        # Create conference nodes
        n_conference_nodes = 3
        n_conference_nodes_bad = 1
        create_fake_conference_nodes_bad_data(
            n_conference_nodes,
            n_conference_nodes_bad,
            conference.endpoint,
        )
        # Create a non-conference node
        ProjectFactory()

        url = api_url_for('conference_data', meeting=conference.endpoint)
        res = self.app.get(url)
        assert_equal(res.status_code, 200)
        assert_equal(len(res.json), n_conference_nodes - n_conference_nodes_bad)
    def test_conference_valid_submissions(self):
        conf = ConferenceFactory(endpoint='Hamburgers', name='Hamburger conference')
        conf.save()

        # 3 good nodes added
        create_fake_conference_nodes(3, conf)

        # Deleted node added
        deleted_node = ProjectFactory(is_public=True)
        deleted_node.is_deleted = True
        deleted_node.save()
        conf.submissions.add(deleted_node)

        # Private node added
        private_node = ProjectFactory(is_public=False)
        conf.submissions.add(private_node)

        assert_equal(conf.submissions.count(), 5)
        assert_equal(conf.valid_submissions.count(), 3)
 def meeting(self):
     return ConferenceFactory(name='OSF 2019', endpoint='osf2019')
Пример #18
0
 def test_default_field_names(self):
     conf = ConferenceFactory(endpoint='cookie', name='Cookies Conference')
     conf.save()
     assert_equal(conf.field_names['submission1'], 'poster')
     assert_equal(conf.field_names['mail_subject'], 'Presentation title')
Пример #19
0
 def test_name_is_required(self):
     with assert_raises(IntegrityError):
         ConferenceFactory(endpoint='spsp2014', name=None).save()
Пример #20
0
 def test_endpoint_is_required(self):
     with assert_raises(IntegrityError):
         ConferenceFactory(endpoint=None, name=fake.company()).save()
Пример #21
0
 def test_confererence_results_endpoint_is_case_insensitive(self):
     ConferenceFactory(endpoint='StudySwap')
     url = web_url_for('conference_results', meeting='studyswap')
     res = self.app.get(url)
     assert_equal(res.status_code, 200)
Пример #22
0
    def test_conference_results(self):
        conference = ConferenceFactory()

        url = web_url_for('conference_results', meeting=conference.endpoint)
        res = self.app.get(url)
        assert_equal(res.status_code, 200)
Пример #23
0
 def meeting_one(self):
     return ConferenceFactory()
Пример #24
0
 def meeting_two(self):
     return ConferenceFactory()