예제 #1
0
    def test_parse_gadget_code_from_wgt(self):
        self._create_gadget_code('test/Morfeo/Test_Gadget1/0.1/gcp_test.html', 'gadget code')
        xhtml = parse_gadget_code('http://example.com',
                                  'deployment/gadgets/test/Morfeo/Test_Gadget1/0.1/gcp_test.html',
                                  'http://example.com/gadget1',
                                  'text/html', True)
        self.assertEquals(xhtml.uri, 'http://example.com/gadget1/xhtml')
        self.assertEquals(xhtml.code, 'gadget code')
        self.assertEquals(xhtml.url, 'deployment/gadgets/test/Morfeo/Test_Gadget1/0.1/gcp_test.html')
        self.assertEquals(xhtml.content_type, 'text/html')

        # now with an absolute path
        self._create_gadget_code('test/Morfeo/Test_Gadget2/0.1/gcp_test.html', 'gadget code')
        xhtml = parse_gadget_code('http://example.com',
                                  '/deployment/gadgets/test/Morfeo/Test_Gadget2/0.1/gcp_test.html',  # absolute path
                                  'http://example.com/gadget2',
                                  'text/html', True)
        self.assertEquals(xhtml.uri, 'http://example.com/gadget2/xhtml')
        self.assertEquals(xhtml.code, 'gadget code')
        self.assertEquals(xhtml.url, '/deployment/gadgets/test/Morfeo/Test_Gadget2/0.1/gcp_test.html')
        self.assertEquals(xhtml.content_type, 'text/html')

        # now with a non existing file
        self.assertRaises(TemplateParseException, parse_gadget_code,
                          'http://example.com',
                          '/deployment/gadgets/non_existing_file.html',
                          'http://example.com/gadget2',
                          'text/html', True)
예제 #2
0
    def test_parse_gadget_code_from_wgt(self):
        self._create_gadget_code('test/Morfeo/Test_Gadget1/0.1/gcp_test.html',
                                 'gadget code')
        xhtml = parse_gadget_code(
            'http://example.com',
            'deployment/gadgets/test/Morfeo/Test_Gadget1/0.1/gcp_test.html',
            'http://example.com/gadget1', 'text/html', True)
        self.assertEquals(xhtml.uri, 'http://example.com/gadget1/xhtml')
        self.assertEquals(xhtml.code, 'gadget code')
        self.assertEquals(
            xhtml.url,
            'deployment/gadgets/test/Morfeo/Test_Gadget1/0.1/gcp_test.html')
        self.assertEquals(xhtml.content_type, 'text/html')

        # now with an absolute path
        self._create_gadget_code('test/Morfeo/Test_Gadget2/0.1/gcp_test.html',
                                 'gadget code')
        xhtml = parse_gadget_code(
            'http://example.com',
            '/deployment/gadgets/test/Morfeo/Test_Gadget2/0.1/gcp_test.html',  # absolute path
            'http://example.com/gadget2',
            'text/html',
            True)
        self.assertEquals(xhtml.uri, 'http://example.com/gadget2/xhtml')
        self.assertEquals(xhtml.code, 'gadget code')
        self.assertEquals(
            xhtml.url,
            '/deployment/gadgets/test/Morfeo/Test_Gadget2/0.1/gcp_test.html')
        self.assertEquals(xhtml.content_type, 'text/html')

        # now with a non existing file
        self.assertRaises(TemplateParseException, parse_gadget_code,
                          'http://example.com',
                          '/deployment/gadgets/non_existing_file.html',
                          'http://example.com/gadget2', 'text/html', True)
예제 #3
0
    def test_parse_gadget_code(self):
        http_utils.download_http_content.set_response("http://example.com/code", "gadget code")

        xhtml = parse_gadget_code('http://example.com/',
                                  'http://example.com/code',
                                  'http://example.com/gadget',
                                  'text/html', False)
        self.assertEquals(xhtml.uri, 'http://example.com/gadget/xhtml')
        self.assertEquals(xhtml.code, 'gadget code')
        self.assertEquals(xhtml.url, 'http://example.com/code')
        self.assertEquals(xhtml.content_type, 'text/html')

        # simulate an HTTP Error
        http_utils.download_http_content.reset()
        http_utils.download_http_content.set_http_error("http://example.com/code")
        self.assertRaises(TemplateParseException, parse_gadget_code,
                          'http://example.com',
                          'http://example.com/code',
                          'http://example.com/gadget',
                          'text/html', False)

        # simulate an URL Error
        http_utils.download_http_content.reset()
        http_utils.download_http_content.set_url_error("http://example.com/code")
        self.assertRaises(TemplateParseException, parse_gadget_code,
                          'http://example.com',
                          'http://example.com/code',
                          'http://example.com/gadget',
                          'text/html', False)
예제 #4
0
    def test_parse_gadget_code(self):
        http_utils.download_http_content.set_response(
            "http://example.com/code", "gadget code")

        xhtml = parse_gadget_code('http://example.com/',
                                  'http://example.com/code',
                                  'http://example.com/gadget', 'text/html',
                                  False)
        self.assertEquals(xhtml.uri, 'http://example.com/gadget/xhtml')
        self.assertEquals(xhtml.code, 'gadget code')
        self.assertEquals(xhtml.url, 'http://example.com/code')
        self.assertEquals(xhtml.content_type, 'text/html')

        # simulate an HTTP Error
        http_utils.download_http_content.reset()
        http_utils.download_http_content.set_http_error(
            "http://example.com/code")
        self.assertRaises(TemplateParseException, parse_gadget_code,
                          'http://example.com', 'http://example.com/code',
                          'http://example.com/gadget', 'text/html', False)

        # simulate an URL Error
        http_utils.download_http_content.reset()
        http_utils.download_http_content.set_url_error(
            "http://example.com/code")
        self.assertRaises(TemplateParseException, parse_gadget_code,
                          'http://example.com', 'http://example.com/code',
                          'http://example.com/gadget', 'text/html', False)