!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache/2.2.16 (Debian). PHP/5.3.3-7+squeeze19 

uname -a: Linux mail.tri-specialutilitydistrict.com 2.6.32-5-amd64 #1 SMP Tue May 13 16:34:35 UTC
2014 x86_64
 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/usr/lib/python2.6/dist-packages/nevow/test/   drwxr-xr-x
Free 129.73 GB of 142.11 GB (91.29%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     test_consolejstest.py (5.56 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
# Copyright (c) 2006 Divmod.
# See LICENSE for details.

"""
Test the dependency tracking and javascript generation code in
L{nevow.jsutil}.
"""

from textwrap import dedent
from twisted.internet.utils import getProcessOutput
from twisted.trial.unittest import TestCase
from nevow.testutil import setJavascriptInterpreterOrSkip
from nevow.jsutil import getDependencies, generateTestScript
from nevow import athena

class _ConsoleJSTestMixin:
    """
    Things that might be useful for testing JavaScript interaction functions
    from L{nevow.testutil}.
    """

    def _getPackages(self):
        """
        @return: the mapping of all javascript packages plus some fake modules
        """
        packages = athena.allJavascriptPackages()
        packages.update(
            {'ConsoleJSTestFoo': self._outputToTempFile(
                        'print("hello from ConsoleJSTestFoo");'),
             'ConsoleJSTestFoo.Bar': self._outputToTempFile(
                            dedent(
                                '''
                                // import ConsoleJSTestFoo
                                print("hello from ConsoleJSTestFoo.Bar");
                                ''')),
             'ConsoleJSTestFoo.Baz': self._outputToTempFile(
                            dedent(
                                '''
                                // import ConsoleJSTestFoo
                                // import ConsoleJSTestFoo.Bar
                                print("hello from ConsoleJSTestFoo.Baz");
                                '''))})
        return packages

    def _outputToTempFile(self, s):
        """
        Write the contents of string C{s} to a tempfile and return the
        filename that was used

        @param s: file contents
        @type s: C{str}

        @return: filename
        @rtype: C{str}
        """
        fname = self.mktemp()
        fObj = file(fname, 'w')
        fObj.write(s)
        fObj.close()
        return fname

class DependenciesTestCase(TestCase, _ConsoleJSTestMixin):
    """
    Tests for L{getDependencies}
    """
    def test_getDependenciesNoModules(self):
        """
        Test that L{getDependencies} returns the empty list when the js module
        it's passed doesn't explicitly import anything and the C{bootstrap} and
        C{ignore} parameters are empty
        """
        deps = getDependencies(
                self._outputToTempFile(''), ignore=(), bootstrap=())
        self.assertEqual(len(deps), 0)


    def test_getDependenciesBootstrap(self):
        """
        Test that L{getDependencies} returns a list containing only the
        bootstrap modules when the js module it's passed doesn't explicitly
        import anything and the "ignore" parameter is empty.
        """
        bootstrap = ['ConsoleJSTestFoo.Bar', 'ConsoleJSTestFoo.Baz']

        deps = getDependencies(
                self._outputToTempFile(''),
                ignore=(),
                bootstrap=bootstrap,
                packages=self._getPackages())
        self.assertEqual([d.name for d in deps], bootstrap)


    def test_getDependenciesIgnore(self):
        """
        Test that L{getDependencies} observes the C{ignore} parameter
        """
        deps = getDependencies(
                self._outputToTempFile(
                    dedent(
                        '''
                        // import ConsoleJSTestFoo.Bar
                        // import ConsoleJSTestFoo.Baz
                        ''')),
                ignore=('ConsoleJSTestFoo.Bar',),
                bootstrap=(),
                packages=self._getPackages())

        self.assertEqual([d.name for d in deps], ['ConsoleJSTestFoo', 'ConsoleJSTestFoo.Baz'])

    def test_getDependenciesAll(self):
        """
        Test that L{getDependencies} works if we import a single module which
        in turn depends on multiple modules
        """
        fname = self._outputToTempFile(
            '// import ConsoleJSTestFoo.Baz')

        deps = getDependencies(
                fname,
                ignore=(),
                bootstrap=(),
                packages=self._getPackages())

        self.assertEqual([d.name for d in deps], ['ConsoleJSTestFoo', 'ConsoleJSTestFoo.Bar', 'ConsoleJSTestFoo.Baz'])



class JSGenerationTestCase(TestCase, _ConsoleJSTestMixin):
    """
    Tests for L{generateTestScript}
    """
    javascriptInterpreter = None

    def test_generateTestScript(self):
        """
        Test for L{generateTestScript}
        """
        fname = self._outputToTempFile(
                    dedent(
                        '''
                        // import ConsoleJSTestFoo.Bar
                        // import ConsoleJSTestFoo.Baz
                        print("hello from the test module");
                        '''))

        deps = getDependencies(
                fname,
                ignore=(),
                bootstrap=(),
                packages=self._getPackages())

        script = generateTestScript(
                    fname,
                    dependencies=deps)

        scriptfname = self._outputToTempFile(script)

        def gotResult(s):
            self.assertEqual(s.split('\n'),
                             ['hello from ConsoleJSTestFoo',
                              'hello from ConsoleJSTestFoo.Bar',
                              'hello from ConsoleJSTestFoo.Baz',
                              'hello from the test module',
                              ''])

        result = getProcessOutput(self.javascriptInterpreter, ('-f', scriptfname))
        result.addCallback(gotResult)
        return result

setJavascriptInterpreterOrSkip(JSGenerationTestCase)

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0113 ]--