示例#1
0
    def test_to_manifest(self):
        for manifest, credentials in TEST_SMART_MANIFESTS:
            app = PHA.from_manifest(manifest, credentials, save=False)
            parsed_m = simplejson.loads(manifest)
            reparsed_m = simplejson.loads(app.to_manifest(smart_only=True))

            # The reparsed manifest should contain AT LEAST as much info as the original
            for k, v in parsed_m.iteritems():
                
                # URIs might have been expanded if they were relative
                if k in ['index', 'oauth_callback_url', 'icon']:
                    self.assertTrue(reparsed_m.get(k, None).endswith(v))
                else:
                    self.assertEqual(v, reparsed_m.get(k, None))

        for manifest, credentials in TEST_USERAPP_MANIFESTS:
            app = PHA.from_manifest(manifest, credentials, save=False)
            parsed_m = simplejson.loads(manifest)
            reparsed_m = simplejson.loads(app.to_manifest())

            # The reparsed manifest should contain AT LEAST as much info as the original
            for k, v in parsed_m.iteritems():

                # URIs might have been expanded if they were relative
                if k in ['index', 'oauth_callback_url', 'icon']:
                    self.assertTrue(reparsed_m.get(k, None).endswith(v))
                else:
                    self.assertEqual(v, reparsed_m.get(k, None))
示例#2
0
    def test_from_manifest(self):    
        all_manifests = TEST_SMART_MANIFESTS + TEST_USERAPP_MANIFESTS
        
        # test that save=False works
        for manifest, credentials in all_manifests:
            num_phas = PHA.objects.count()
            app = PHA.from_manifest(manifest, credentials, save=False)
            self.assertEqual(num_phas, PHA.objects.count())
            
        # should work with a SMART manifest
        for manifest, credentials in TEST_SMART_MANIFESTS:
            parsed_m, parsed_c, app = self.buildAppFromManifest(PHA, manifest, credentials)
            self.assertValidUserAppManifest(parsed_m, parsed_c, app)

        # Or with Indivo-specific manifest extensions
        for manifest, credentials in TEST_USERAPP_MANIFESTS:
            parsed_m, parsed_c, app = self.buildAppFromManifest(PHA, manifest, credentials)
            self.assertValidUserAppManifest(parsed_m, parsed_c, app)