示例#1
0
    def handle(self, *args, **options):
        TEST = options.get('test')
        SITE = options.get('site')
        TYPE = options.get('type')
        LIST = options.get('list')

        passed =  True
        if TEST:
            print "Running test: %s" % TEST
            test = Test.objects.get(slug=TEST)
            passed = run_test(test)
        elif TYPE:
            print "Running tests for type : %s" % TYPE
            type = Type.objects.get(slug=TYPE)
            passed = run_tests_for_type(type)
        elif SITE:
            print "Running tests for site : %s" % SITE
            site = Site.objects.get(slug=SITE)
            passed = run_tests_for_site(site)
        elif LIST:
            print "All Sites:"
            for site in Site.objects.all():
                print site.slug
            print "All Tests:"
            for test in Test.objects.all():
                print test.slug
        else:
            print "No action"
            return 0

        if passed:
            return 0
        else:
            return 2
示例#2
0
    def test_basic_twill_script(self):
        """
        Test that the twill script is being run.
        Mock out the results so that network access
        isn't required.
        """

        from twill.browser import TwillBrowser

        # Mock out the test we want to run.
        html_func = lambda url: "Awesome HTML Output"
        TwillBrowser.get_html = html_func
        code_func = lambda url: 200
        TwillBrowser.get_code = code_func
        url_func = lambda url: "http://example.com"
        TwillBrowser.get_url = url_func

        test = Test.objects.all()[0]
        passed = run_test(test)
        self.assertEqual(passed, True)
示例#3
0
    def test_basic_twill_script(self):
        """
        Test that the twill script is being run.
        Mock out the results so that network access
        isn't required.
        """

        from twill.browser import TwillBrowser

        #Mock out the test we want to run.
        html_func = lambda url: "Awesome HTML Output"
        TwillBrowser.get_html = html_func
        code_func = lambda url: 200
        TwillBrowser.get_code = code_func
        url_func = lambda url: 'http://example.com'
        TwillBrowser.get_url = url_func

        test = Test.objects.create(
            body="go awesome.com/\r\ncode 200\r\nfind Awesome",
            name="My Awesome Test",
            slug="my-awesome-test",
        )
        passed = run_test(test)
        self.assertEqual(passed, True)