示例#1
0
    def test_upload_tool(self):
        """
    Actual upload paper functionality
    """
        payload = {
            'authoremail': '*****@*****.**',
            'papername': 'Testing Paper'
        }
        token = get_email_token(payload)

        form_data = {
            'papername': 'Test Paper',
            'authoremail': '*****@*****.**',
            'linktoarchive': 'http://test.com',
            'description': 'This paper is for unit testing',
            'tags': 'test,paper',
            'useragreement': True,
            'dropdown_choices': 'Binary',
            'file_types': 'Binary',
            'bibtex': 'Test'
        }

        form_data['all_files'] = [(io.BytesIO(b"abcdef"), 'test.pdf')]
        response = self.app.post('/tool_upload/{}'.format(token),
                                 content_type='multipart/form-data',
                                 data=form_data)
        # print(response.get_data())
        self.assertEqual(response.status, "302 FOUND")
示例#2
0
    def test_update_tool_submit(self):
        """
    Testing the editing functionality
    """
        paper = self.create_paper()
        payload = {'paper_id': paper.id}
        token = get_email_token(payload)

        form_data = {
            'papername': 'Test Paper',
            'authoremail': '*****@*****.**',
            'linktoarchive': 'http://test.com',
            'description': 'This paper is for unit testing',
            'tags': 'test,paper',
            'useragreement': True,
            'dropdown_choices': 'Binary',
            'file_types': 'Binary',
            'bibtex': 'Test'
        }

        form_data['all_files'] = [(io.BytesIO(b"abcdef"), 'test.pdf')]

        response = self.app.post('/update_tool/{}'.format(token),
                                 content_type='multipart/form-data',
                                 data=form_data)
        self.assertEqual(response.status, "200 OK")
示例#3
0
    def test_update_tool(self):
        """
    Testing the editing functionality
    """
        paper = self.create_paper()
        payload = {'paper_id': paper.id}
        token = get_email_token(payload)

        response = self.app.get('/update_tool/{}'.format(token))
        self.assertEqual(response.status, "200 OK")
示例#4
0
    def test_get_email_token(self):
        email = '*****@*****.**'
        salt = 'salt'
        secret = 'secret'
        token = utils.get_email_token(email, salt, secret)
        self.assertEquals('ImFAYS5jb20i', token[0:12])
        decoded = utils.get_email_from_token(token, salt, secret)
        self.assertEquals(email, decoded)
        time.sleep(2)

        with self.assertRaises(Exception) as context:
            decoded = utils.get_email_from_token(token, salt,
                                                 secret, max_age=1)
        self.assertTrue('Signature age 2 > 1 seconds' in context.exception)
 def get_email_verification_token(self, salt, secret):
     """
     :rtype string
     :return the email verification token stored in the
     """
     return utils.get_email_token(self.email, salt, secret)
示例#6
0
 def get_email_verification_token(self, salt, secret):
     """
     :rtype string
     :return the email verification token stored in the
     """
     return utils.get_email_token(self.email, salt, secret)