Ejemplo n.º 1
0
    def testQueriesDirectFromClaim(self):
        """Test construction of the right Query from a page.Claim."""
        # Datatype: item
        claim = Claim(self.repo, 'P17')
        claim.setTarget(pywikibot.ItemPage(self.repo, 'Q35'))
        q = query.fromClaim(claim)
        self.assertEqual(str(q), 'claim[17:35]')

        # Datatype: string
        claim = Claim(self.repo, 'P225')
        claim.setTarget('somestring')
        q = query.fromClaim(claim)
        self.assertEqual(str(q), 'string[225:"somestring"]')

        # Datatype: external-id
        claim = Claim(self.repo, 'P268')
        claim.setTarget('somestring')
        q = query.fromClaim(claim)
        self.assertEqual(str(q), 'string[268:"somestring"]')

        # Datatype: commonsMedia
        claim = Claim(self.repo, 'P18')
        claim.setTarget(
            pywikibot.FilePage(pywikibot.Site(self.family, self.code),
                               'Foo.jpg'))
        q = query.fromClaim(claim)
        self.assertEqual(str(q), 'string[18:"Foo.jpg"]')
    def testQueriesDirectFromClaim(self):
        """Test construction of the right Query from a page.Claim."""
        # Datatype: item
        claim = Claim(self.repo, 'P17')
        claim.setTarget(pywikibot.ItemPage(self.repo, 'Q35'))
        q = query.fromClaim(claim)
        self.assertEqual(str(q), 'claim[17:35]')

        # Datatype: string
        claim = Claim(self.repo, 'P225')
        claim.setTarget('somestring')
        q = query.fromClaim(claim)
        self.assertEqual(str(q), 'string[225:"somestring"]')

        # Datatype: external-id
        claim = Claim(self.repo, 'P268')
        claim.setTarget('somestring')
        q = query.fromClaim(claim)
        self.assertEqual(str(q), 'string[268:"somestring"]')

        # Datatype: commonsMedia
        claim = Claim(self.repo, 'P18')
        claim.setTarget(
            pywikibot.FilePage(
                pywikibot.Site(self.family, self.code),
                'Foo.jpg'))
        q = query.fromClaim(claim)
        self.assertEqual(str(q), 'string[18:"Foo.jpg"]')
    def testQueriesDirectFromClaim(self):
        """Test construction of the right Query from a page.Claim."""
        claim = Claim(self.repo, 'P17')
        claim.setTarget(pywikibot.ItemPage(self.repo, 'Q35'))

        q = query.fromClaim(claim)
        self.assertEqual(str(q), 'claim[17:35]')

        claim = Claim(self.repo, 'P268')
        claim.setTarget('somestring')

        q = query.fromClaim(claim)
        self.assertEqual(str(q), 'string[268:"somestring"]')
Ejemplo n.º 4
0
    def testQueriesDirectFromClaim(self):
        """Test construction of the right Query from a page.Claim."""
        claim = Claim(self.repo, 'P17')
        claim.setTarget(pywikibot.ItemPage(self.repo, 'Q35'))

        q = query.fromClaim(claim)
        self.assertEqual(str(q), 'claim[17:35]')

        claim = Claim(self.repo, 'P268')
        claim.setTarget('somestring')

        q = query.fromClaim(claim)
        self.assertEqual(str(q), 'string[268:"somestring"]')
Ejemplo n.º 5
0
    def testQueriesDirectFromClaim(self):
        """
        Test construction of the  the right Query from a page.Claim
        """

        repo = pywikibot.Site('wikidata', 'wikidata').data_repository()

        claim = Claim(repo, 'P17')
        claim.setTarget(pywikibot.ItemPage(repo, 'Q35'))

        q = query.fromClaim(claim)
        self.assertEqual(str(q), 'claim[17:35]')

        claim = Claim(repo, 'P268')
        claim.setTarget('somestring')

        q = query.fromClaim(claim)
        self.assertEqual(str(q), 'string[268:"somestring"]')