예제 #1
0
    def test(self):
        """Test. note that all test method names must begin with 'test.'"""
        """WARNING: IT IS HIGHLY RECOMMENDED TO HAVE ONE TEST ONLY TO ISOLATE FUNCTIONAL TESTS FROM EACH OTHER. i.e. 
        Start a new Python Interpreter and JVM for each test. In the end, it means only one test in this class. """
        from dataclay.api import init

        logger.debug('**Starting init**')
        init()
        """ 
        Imports. Imports must be located here in order to simulate "import" order in a real scenario. 
        VERY IMPORTANT: Imports must be located AFTER init
        """
        from model.classes import WebSite, WebPage, URI

        self.session_initialized = True
        """
        Test. From now on, the Functional Test itself. 
        """

        host = "bsc.es"
        web_site = WebSite(host)

        # Verify object_iD is not null
        object_id = web_site.get_object_id()

        self.assertTrue(object_id != None)

        # Test make_persistent
        web_site.make_persistent()

        self.assertTrue(web_site.is_persistent)

        web_site.make_persistent("testAlias")

        web_site2 = WebSite.get_by_alias("testAlias")

        self.assertEqual(web_site, web_site2)

        web_site.make_persistent("otherAlias")

        web_site3 = WebSite.get_by_alias("otherAlias")
        web_site4 = WebSite.get_by_alias("testAlias")

        self.assertEqual(web_site3, web_site4)
        self.assertEqual(web_site3, web_site)
        self.assertEqual(web_site3, web_site2)

        logger.debug("Test OK!")
예제 #2
0
    def client_process2(self, q, web_sites_ids_str):
        try:
            from dataclay.api import init, finish
            logger.debug('**Starting init 2 **')
            init()
            """ 
            Imports. Imports must be located here in order to simulate "import" order in a real scenario. 
            VERY IMPORTANT: Imports must be located AFTER init
            """
            from model.classes import WebSite, WebPage, URI

            for i in range(0, 10):
                web_site_2 = WebSite.get_by_alias("bsc%s" % str(i))
                self.assertEqual(web_sites_ids_str[i],
                                 str(web_site_2.get_object_id()))

            finish()
            q.put("OK")
        except:
            q.put("FAIL")
예제 #3
0
    def test(self):
        """Test. note that all test method names must begin with 'test.'"""
        """WARNING: IT IS HIGHLY RECOMMENDED TO HAVE ONE TEST ONLY TO ISOLATE FUNCTIONAL TESTS FROM EACH OTHER. i.e. 
        Start a new Python Interpreter and JVM for each test. In the end, it means only one test in this class. """
        from dataclay.api import init

        logger.debug('**Starting init**')
        init()
        
        """ 
        Imports. Imports must be located here in order to simulate "import" order in a real scenario. 
        VERY IMPORTANT: Imports must be located AFTER init
        """
        from model.classes import WebSite, WebPage, URI
        
        self.session_initialized = True
    
        """
        Test. From now on, the Functional Test itself. 
        """

        host = "bsc.es"
        web_site = WebSite(host)
        web_page = WebPage(host + "/page.html")
        web_page2 = WebPage(host + "/page2.html")
        web_page3 = WebPage(host + "/page3.html")
        web_page4 = WebPage(host + "/page4.html")

        # Verify object_iD is not null
        object_id = web_site.get_object_id()

        self.assertTrue(object_id != None)

        web_site.add_web_page(web_page)

        # Test make_persistent

        web_site.make_persistent("BSCwebsite")

        # Not added (yet!) to the web_site
        web_page3.make_persistent("page3")
        web_page4.make_persistent("page4")
        
        self.assertTrue(web_site.is_persistent())

        # Add another page after persistence 
        web_site.add_web_page(web_page2)
        self.assertEqual(len(web_site.pages), 2)

        web_site_bis = WebSite.get_by_alias("BSCwebsite")
        self.assertEqual(len(web_site_bis.pages), 2)

        web_site_bis.add_web_page(WebPage.get_by_alias("page3"))
        web_site_bis.add_web_page(WebPage.get_by_alias("page4"))

        self.assertEqual(len(web_site.pages), 4)
        self.assertEqual(len(web_site_bis.pages), 4)

        # Test recursive make_persistent
        for page in web_site.pages:
            self.assertTrue(page.is_persistent())
            self.assertTrue(page.uri.is_persistent())

        self.assertTrue(web_site.uri.is_persistent())

        logger.debug("Test OK!")