예제 #1
0
    def test_create_pending_existing_release(self):
        userobj = User.objects.create_user(username='******',
                                           password='******',
                                           is_superuser=True)
        userobj.save()
        appobj = App.objects.create(name='someapp',
                                    fullname='SomeApp',
                                    active=True)
        appobj.save()

        jarfile = SimpleUploadedFile('SomeApp-1.0.0.jar',
                                     b'data',
                                     content_type='application/zip')

        myrel = Release.objects.create(app=appobj,
                                       version='1.0.0',
                                       release_file=jarfile,
                                       active=True)
        myrel.save()
        try:
            views._create_pending(userobj, 'SomeApp', '1.0.0', 'workswith', [],
                                  jarfile)
        except ValueError as ve:
            self.assertEqual(
                'cannot be accepted because the '
                'app SomeApp already has a release '
                'with version 1.0.0. You can delete '
                'this version by going to the Release '
                'History tab in the app edit page', str(ve))
예제 #2
0
    def test_submit_api_with_invalidjavadoc_and_invalid_pomfile(self):
        userobj = User.objects.create_user(username='******',
                                           password='******',
                                           is_superuser=True)
        userobj.save()

        javadocfile = SimpleUploadedFile('javadoc.jar',
                                         b'invalid',
                                         content_type='application/zip')
        jarfile = SimpleUploadedFile('SomeApp-1.0.0.jar',
                                     b'data',
                                     content_type='application/zip')
        testpomfile = SimpleUploadedFile('pom.xml',
                                         b'haha',
                                         content_type='text/xml')
        pending = views._create_pending(userobj, 'SomeApp', '1.0.0',
                                        'workswith', [], jarfile)
        res = self.client.login(username='******', password='******')
        self.assertTrue(res)

        response = self.client.post('/submit_app/submit_api/' +
                                    str(pending.id), {
                                        'submit': 'true',
                                        'pom_xml': testpomfile,
                                        'javadocs_jar': javadocfile
                                    },
                                    follow=True)
        self.assertEqual(200, response.status_code)
        self.assertTrue(b'Submit an API' in response.content)
        self.assertTrue(b'pom.xml is not valid; '
                        b'it must have' in response.content)
예제 #3
0
    def test_confirm_submission_success_noaction_withpom(self):
        userobj = User.objects.create_user(username='******',
                                           password='******',
                                           is_superuser=True)
        userobj.save()

        jarfile = SimpleUploadedFile('SomeApp-1.0.0.jar',
                                     b'data',
                                     content_type='application/zip')

        pending = views._create_pending(userobj, 'SomeApp', '1.0.0',
                                        'workswith', [], jarfile)

        testpomfile = SimpleUploadedFile('pom.xml',
                                         PomParseTest.get_valid_pom_as_bytes(),
                                         content_type='text/xml')
        testpomfile.open(mode='r')
        pending.pom_xml_file.save(os.path.basename(testpomfile.name),
                                  testpomfile)
        testpomfile.close()

        res = self.client.login(username='******', password='******')
        self.assertTrue(res)
        response = self.client.post('/submit_app/confirm/' + str(pending.id),
                                    follow=True)
        self.assertEqual(200, response.status_code)
        self.assertTrue(b'Cytoscape App Store - '
                        b'Confirm Submission' in response.content)
        self.assertTrue(b'es.imim' in response.content)
        self.assertTrue(b'DisGeNET' in response.content)
        self.assertTrue(b'6.3.2' in response.content)
예제 #4
0
 def test_create_pending_user_not_editor(self):
     userobj = User.objects.create_user(username='******',
                                        password='******',
                                        is_superuser=False)
     userobj.save()
     appobj = App.objects.create(name='someapp',
                                 fullname='SomeApp',
                                 active=True)
     appobj.save()
     jarfile = SimpleUploadedFile('SomeApp-1.0.0.jar',
                                  b'data',
                                  content_type='application/zip')
     try:
         views._create_pending(userobj, 'SomeApp', '1.0.0', 'workswith', [],
                               jarfile)
     except ValueError as ve:
         self.assertEqual(
             'cannot be accepted because '
             'you are not an editor', str(ve))
예제 #5
0
    def test_create_pending_app_not_found(self):
        userobj = User.objects.create_user(username='******',
                                           password='******',
                                           is_superuser=True)
        jarfile = SimpleUploadedFile('SomeApp-1.0.0.jar',
                                     b'data',
                                     content_type='application/zip')
        pending = views._create_pending(userobj, 'SomeApp', '1.0.0',
                                        'workswith', [], jarfile)

        self.assertEqual(userobj, pending.submitter)
        self.assertEqual('SomeApp', pending.fullname)
        self.assertEqual('1.0.0', pending.version)
예제 #6
0
    def test_confirm_submission_success_noaction_nopom(self):
        userobj = User.objects.create_user(username='******',
                                           password='******',
                                           is_superuser=True)
        userobj.save()

        jarfile = SimpleUploadedFile('SomeApp-1.0.0.jar',
                                     b'data',
                                     content_type='application/zip')
        pending = views._create_pending(userobj, 'SomeApp', '1.0.0',
                                        'workswith', [], jarfile)
        res = self.client.login(username='******', password='******')
        self.assertTrue(res)
        response = self.client.post('/submit_app/confirm/' + str(pending.id),
                                    follow=True)
        self.assertEqual(200, response.status_code)
        self.assertTrue(b'Cytoscape App Store - '
                        b'Confirm Submission' in response.content)
예제 #7
0
    def test_confirm_submission_user_accept_no_existing_app(self):
        userobj = User.objects.create_user(username='******',
                                           password='******',
                                           is_superuser=True)
        userobj.save()

        jarfile = SimpleUploadedFile('SomeApp-1.0.0.jar',
                                     b'data',
                                     content_type='application/zip')
        pending = views._create_pending(userobj, 'SomeApp', '1.0.0',
                                        'workswith', [], jarfile)
        res = self.client.login(username='******', password='******')
        self.assertTrue(res)
        response = self.client.post('/submit_app/confirm/' + str(pending.id),
                                    {'action': 'accept'},
                                    follow=True)
        self.assertEqual(200, response.status_code)
        self.assertTrue(b'Submit an App' in response.content)
        checkpending = AppPending.objects.filter(id=pending.id).first()
        self.assertEqual(pending, checkpending)
예제 #8
0
    def test_confirm_submission_user_not_authorized(self):
        userobj = User.objects.create_user(username='******',
                                           password='******',
                                           is_superuser=True)
        userobj.save()

        testuser = User.objects.create_user(username='******',
                                            password='******',
                                            is_superuser=False)
        testuser.save()
        jarfile = SimpleUploadedFile('SomeApp-1.0.0.jar',
                                     b'data',
                                     content_type='application/zip')
        pending = views._create_pending(userobj, 'SomeApp', '1.0.0',
                                        'workswith', [], jarfile)
        res = self.client.login(username='******', password='******')
        self.assertTrue(res)
        response = self.client.post('/submit_app/confirm/' + str(pending.id),
                                    follow=True)
        self.assertEqual(403, response.status_code)
예제 #9
0
    def test_submit_api_with_javadoc_and_pom(self):
        temp_dir = tempfile.mkdtemp()
        try:
            userobj = User.objects.create_user(username='******',
                                               password='******',
                                               is_superuser=True)
            userobj.save()

            temp_zip = os.path.join(temp_dir, 'foo.jar')
            zf = zipfile.ZipFile(temp_zip, mode='w')
            zf.writestr('hi.xml', 'somedata')
            zf.close()
            with open(temp_zip, 'rb') as f:
                zipdata = f.read()
            javadocfile = SimpleUploadedFile('javadoc.jar',
                                             zipdata,
                                             content_type='application/zip')
            jarfile = SimpleUploadedFile('SomeApp-1.0.0.jar',
                                         b'data',
                                         content_type='application/zip')
            testpomfile = SimpleUploadedFile(
                'pom.xml',
                PomParseTest.get_valid_pom_as_bytes(),
                content_type='text/xml')
            pending = views._create_pending(userobj, 'SomeApp', '1.0.0',
                                            'workswith', [], jarfile)
            res = self.client.login(username='******', password='******')
            self.assertTrue(res)

            response = self.client.post('/submit_app/submit_api/' +
                                        str(pending.id), {
                                            'submit': 'true',
                                            'pom_xml': testpomfile,
                                            'javadocs_jar': javadocfile
                                        },
                                        follow=True)
            self.assertEqual(200, response.status_code)
            self.assertTrue(b'Confirm Submission' in response.content)
        finally:
            shutil.rmtree(temp_dir)