Ejemplo n.º 1
0
    def test_amd_init_with_spec_url(self):
        from ptah.amd import amd_init, ID_AMD_MODULE, ID_AMD_SPEC

        self.registry[ID_AMD_MODULE] = {'ptah': 'ptah:static/ptah.js'}
        self.registry[ID_AMD_SPEC] = \
            {'test': {'ptah': {'url': 'http://test.com/example.js'}}}

        self.request.matchdict['specname'] = 'test'

        resp = amd_init(self.request)
        self.assertEqual(resp.status, '200 OK')

        self.registry[ID_AMD_SPEC] = \
            {'test': {'ptah': {'name':'test', 'path':'ptah:static/example.js'}}}
        resp = amd_init(self.request)
        self.assertIn('"ptah": "http://example.com/_amd_test/t"', resp.text)
Ejemplo n.º 2
0
    def test_amd_init_no_spec(self):
        from ptah.amd import amd_init

        self.config.register_amd_module(
            'test-mod', 'ptah:tests/dir/test.js')

        self.request.matchdict['specname'] = 'unknown'

        resp = amd_init(self.request)
        self.assertIsInstance(resp, HTTPNotFound)
Ejemplo n.º 3
0
    def test_amd_init_with_spec_mustache(self):
        from ptah.amd import amd_init, ID_AMD_MODULE, ID_AMD_SPEC

        self.request.matchdict['specname'] = 'test'
        self.registry[ID_AMD_SPEC] = \
            {'test': {'ptah-templates':
                      {'name':'test', 'path':'ptah:static/example.js'}}}
        resp = amd_init(self.request)
        self.assertIn(
            '"ptah-templates":"http://example.com/_amd_test/t"', resp.text)
Ejemplo n.º 4
0
    def test_bundles_amd(self):
        from ptah.amd import amd_init

        self.config.register_mustache_bundle(
            'test-bundle', 'ptah:tests/bundle/')

        self.request.matchdict['specname'] = '_'

        res = amd_init(self.request)
        self.assertIn(
            '"test-bundle":"http://example.com/_mustache/test-bundle"',res.text)
Ejemplo n.º 5
0
    def test_amd_mod_paths(self):
        from ptah.amd import amd_init

        self.config.register_amd_module(
            'test-mod', 'ptah:tests/dir/test.js')

        self.request.matchdict['specname'] = '_'

        resp = amd_init(self.request)
        self.assertIn('var ptah_amd_modules = {', resp.text)
        self.assertIn(
            '"test-mod": "http://example.com/_tests/test"', resp.text)