示例#1
0
def integrate(args):
    from citools.pavement import djangonize_test_environment
    test_project_module="example_project"

    args.extend(['--with-selenium', '--with-cherrypyliveserver', '--with-django', '--with-mongo-database'])

    djangonize_test_environment(test_project_module)

    import nose

    os.chdir(join(options.rootdir, "tests", test_project_module))

    from django.conf import settings
    from djangosanetesting.utils import get_live_server_path, DEFAULT_URL_ROOT_SERVER_ADDRESS

    settings.BUILDMASTER_NETWORK_NAME = getattr(settings, "URL_ROOT_SERVER_ADDRESS", DEFAULT_URL_ROOT_SERVER_ADDRESS)

    settings.NETWORK_NAME = get_live_server_path() + "/"


    nose.run_exit(
        argv = ["nosetests"] + args,
        defaultTest = test_project_module,
        addplugins = [get_plugin()]
    )
示例#2
0
 def test_django_error_traceback(self):
     try:
         self.urlopen(url='%sreturn_django_error/' % get_live_server_path())
     except urllib2.HTTPError, err:
         self.assert_equals(500, err.code)
         self.assert_not_equals("500 Server error, traceback not found",
                                err.msg)
示例#3
0
 def test_owner_username_present(self):
     self.assert_equals(
         u"Testeřík",
         document_fromstring(urlopen(get_live_server_path()).read().decode("utf-8"))
         .xpath("//a[@id='menu-owner-name']")[0]
         .text,
     )
示例#4
0
    def startTest(self, test):
        """
        When preparing test, check whether to make our database fresh
        """

        from django.conf import settings

        test_case = get_test_case_class(test)

        enable_test(test_case, 'selenium_plugin_started')

        if getattr(test_case, "selenium_start", False):
            sel = selenium(
                getattr(settings, "SELENIUM_HOST", 'localhost'),
                int(getattr(settings, "SELENIUM_PORT", 4444)),
                getattr(settings, "SELENIUM_BROWSER_COMMAND", '*opera'),
                getattr(settings, "SELENIUM_URL_ROOT", get_live_server_path()),
            )
            try:
                sel.start()
                test_case.selenium_started = True
            except Exception, err:
                # we must catch it all as there is untyped socket exception on Windows :-]]]
                if getattr(settings, "FORCE_SELENIUM_TESTS", False):
                    raise
                else:
                    test_case.skipped = True
                    #raise SkipTest(err)
            else:
                if isinstance(test.test, nose.case.MethodTestCase):
                    test.test.test.im_self.selenium = sel
                else:
    def startTest(self, test):
        """
        When preparing test, check whether to make our database fresh
        """

        from django.conf import settings
        
        test_case = get_test_case_class(test)

        enable_test(test_case, 'selenium_plugin_started')
        
        if getattr(test_case, "selenium_start", False):
            sel = selenium(
                      getattr(settings, "SELENIUM_HOST", 'localhost'),
                      int(getattr(settings, "SELENIUM_PORT", 4444)),
                      getattr(settings, "SELENIUM_BROWSER_COMMAND", '*opera'),
                      getattr(settings, "SELENIUM_URL_ROOT", get_live_server_path()),
                  )
            try:
                sel.start()
                test_case.selenium_started = True
            except Exception, err:
                # we must catch it all as there is untyped socket exception on Windows :-]]]
                if getattr(settings, "FORCE_SELENIUM_TESTS", False):
                    raise
                else:
                    test_case.skipped = True
                    #raise SkipTest(err)
            else:
                if isinstance(test.test, nose.case.MethodTestCase):
                    test.test.test.im_self.selenium = sel
                else:
                    test_case.skipped = True
 def test_not_authorized_not_resetable(self):
     # This is lame, but condition is non-deterministic and reveals itself
     # when repeating request often...
     for i in xrange(1, 10):
         try:
             response = self.urlopen(url='%sreturn_not_authorized/' % get_live_server_path(), data='data')
             #response = opener.open(request)
         except urllib2.HTTPError, err:
             self.assert_equals(401, err.code)
         else:
             assert False, "401 expected"
示例#7
0
 def test_not_authorized_not_resetable(self):
     # This is lame, but condition is non-deterministic and reveals itself
     # when repeating request often...
     for i in xrange(1, 10):
         try:
             response = self.urlopen(url='%sreturn_not_authorized/' %
                                     get_live_server_path(),
                                     data='data')
             #response = opener.open(request)
         except urllib2.HTTPError, err:
             self.assert_equals(401, err.code)
         else:
             assert False, "401 expected"
    def startTest(self, test):
        """
        When preparing test, check whether to make our database fresh
        """

        from django.conf import settings
        from django.utils.importlib import import_module

        test_case = get_test_case_class(test)

        enable_test(test_case, 'selenium_plugin_started')

        # import selenium class to use
        selenium_import = getattr(settings, "DST_SELENIUM_DRIVER",
                            "djangosanetesting.selenium.driver.selenium").split(".")
        selenium_module, selenium_cls = ".".join(selenium_import[:-1]), selenium_import[-1]
        selenium = getattr(import_module(selenium_module), selenium_cls)
        
        if getattr(test_case, "selenium_start", False):
            browser = getattr(test_case, 'selenium_browser_command', None)
            if browser is None:
                browser = getattr(settings, "SELENIUM_BROWSER_COMMAND", '*opera')

            sel = selenium(
                      getattr(settings, "SELENIUM_HOST", 'localhost'),
                      int(getattr(settings, "SELENIUM_PORT", 4444)),
                      browser,
                      getattr(settings, "SELENIUM_URL_ROOT", get_live_server_path()),
                  )
            try:
                sel.start()
                test_case.selenium_started = True
            except Exception, err:
                # we must catch it all as there is untyped socket exception on Windows :-]]]
                if getattr(settings, "FORCE_SELENIUM_TESTS", False):
                    raise
                else:
                    test_case.skipped = True
                    #raise SkipTest(err)
            else:
                if isinstance(test.test, nose.case.MethodTestCase):
                    test.test.test.im_self.selenium = sel
                else:
                    test_case.skipped = True
示例#9
0
    def setUp(self):
        super(BuildmasterTestCase, self).setUp()

        self._old_builddir = getattr(settings, "CTHULHUBOT_BUILDMASTER_BASEDIR", None)

        self.base_directory = mkdtemp()

        settings.CTHULHUBOT_BUILDMASTER_BASEDIR = self.base_directory

        self.url_root = get_live_server_path()

        self.network_root = settings.NETWORK_ROOT
        settings.NETWORK_ROOT = self.url_root


        self.project_name = u"project"
        self.project = create_project(self)
        self.buildmaster = self.project.buildmaster_set.all()[0]

        self.transaction.commit()
示例#10
0
    def startTest(self, test):
        """
        When preparing test, check whether to make our database fresh
        """

        from django.conf import settings
        from django.utils.importlib import import_module

        test_case = get_test_case_class(test)

        enable_test(test_case, 'selenium_plugin_started')

        # import selenium class to use
        selenium_import = getattr(
            settings, "DST_SELENIUM_DRIVER",
            "djangosanetesting.selenium.driver.selenium").split(".")
        selenium_module, selenium_cls = ".".join(
            selenium_import[:-1]), selenium_import[-1]
        selenium = getattr(import_module(selenium_module), selenium_cls)

        if getattr(test_case, "selenium_start", False):
            sel = selenium(
                getattr(settings, "SELENIUM_HOST", 'localhost'),
                int(getattr(settings, "SELENIUM_PORT", 4444)),
                getattr(settings, "SELENIUM_BROWSER_COMMAND", '*opera'),
                getattr(settings, "SELENIUM_URL_ROOT", get_live_server_path()),
            )
            try:
                sel.start()
                test_case.selenium_started = True
            except Exception, err:
                # we must catch it all as there is untyped socket exception on Windows :-]]]
                if getattr(settings, "FORCE_SELENIUM_TESTS", False):
                    raise
                else:
                    test_case.skipped = True
                    #raise SkipTest(err)
            else:
                if isinstance(test.test, nose.case.MethodTestCase):
                    test.test.test.im_self.selenium = sel
                else:
示例#11
0
 def test_ok_retrieved(self):
     self.twill.go("%stesttwohundred/" % get_live_server_path())
     self.assert_equals(200, self.twill.get_code())
示例#12
0
 def get_ok(self):
     self.assertEquals(
         u'OKidoki',
         self.urlopen('%stesttwohundred/' % get_live_server_path()).read())
示例#13
0
 def test_available_in_another_thread(self):
     self.assertEquals(
         u'OKidoki',
         self.urlopen('%sassert_two_example_models/' %
                      get_live_server_path()).read())
 def get_ok(self):
     self.assertEquals(u'OKidoki', self.urlopen('%stesttwohundred/' % get_live_server_path()).read())
示例#15
0
 def test_without_fixture_there_is_no_site_in_root(self):
     try:
         res = urlopen(get_live_server_path())
     except HTTPError, e:
         self.assert_equals(404, e.code)
 def test_django_error_traceback(self):
     try:
         self.urlopen(url='%sreturn_django_error/' % get_live_server_path())
     except urllib2.HTTPError, err:
         self.assert_equals(500, err.code)
         self.assert_not_equals("500 Server error, traceback not found", err.msg)
 def test_ok_prage_loaded(self):
     from lxml import etree
     self.spynner.load("%stesttwohundred/" % get_live_server_path())
     self.assert_equals(
         'OKidoki',
         etree.parse(StringIO(self.spynner.html)).xpath("//body")[0].text)
 def test_ok_prage_loaded(self):
     from lxml import etree
     self.spynner.load("%stesttwohundred/" % get_live_server_path())
     self.assert_equals('OKidoki', etree.parse(StringIO(self.spynner.html)).xpath("//body")[0].text)
 def test_ok_loaded(self):
     self.assert_true(True, self.spynner.load("%stesttwohundred/" % get_live_server_path()))
示例#20
0
 def get_live_server_url(self):
     return get_live_server_path()
 def test_ok_retrieved(self):
     self.twill.go("%stesttwohundred/" % get_live_server_path())
     self.assert_equals(200, self.twill.get_code())
示例#22
0
def mock_url_root(case):
    case.url_root = get_live_server_path()

    case.network_root = settings.NETWORK_ROOT
    settings.NETWORK_ROOT = case.url_root
示例#23
0
    def test_available_to_created_and_forced(self):
        create_user("tester", "xxx", "*****@*****.**")
        self.transaction.commit()

        res = urlopen(get_live_server_path())
        self.assert_equals(200, res.code)
示例#24
0
 def test_available_in_another_thread(self):
     self.assertEquals(u'OKidoki', self.urlopen('%sassert_two_example_models/' % get_live_server_path()).read())
 def test_ok_loaded(self):
     self.assert_true(
         True,
         self.spynner.load("%stesttwohundred/" % get_live_server_path()))