Exemplo n.º 1
0
    def test_repo_feed_all_launched_repos(self):
        config.set_for_repo('haiti',
                            deactivated=True,
                            launched=True,
                            test_mode=False)
        config.set_for_repo('japan',
                            deactivated=False,
                            launched=True,
                            test_mode=True,
                            updated_date=utils.get_timestamp(
                                datetime.datetime(2012, 03, 11)))
        config.set_for_repo('pakistan',
                            deactivated=False,
                            launched=False,
                            test_mode=False)

        # 'haiti', 'japan', and 'pakistan' exist in the datastore. Only those
        # which are 'launched' and not 'deactivated' i.e., only 'japan' should
        # appear in the feed.
        doc = self.go('/global/feeds/repo')
        expected_content = u'''\
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
      xmlns:gpf="http://schemas.google.com/personfinder/2012"
      xmlns:georss="http://www.georss.org/georss">
  <id>http://%s/personfinder/global/feeds/repo</id>
  <title>Person Finder Repository Feed</title>
  <updated>2012-03-11T00:00:00Z</updated>
  <entry>
    <id>%s/japan</id>
    <published>2011-03-11T00:00:00Z</published>
    <updated>2012-03-11T00:00:00Z</updated>
    <title xml:lang="ja">2011 日本地震</title>
    <content type="text/xml">
      <gpf:repo>
        <gpf:title xml:lang="ja">2011 日本地震</gpf:title>
        <gpf:title xml:lang="en">2011 Japan Earthquake</gpf:title>
        <gpf:title xml:lang="ko"></gpf:title>
        <gpf:title xml:lang="zh-CN">2011 日本地震</gpf:title>
        <gpf:title xml:lang="zh-TW">2011 日本地震</gpf:title>
        <gpf:title xml:lang="pt-BR">2011 Terremoto no Japão</gpf:title>
        <gpf:title xml:lang="es">2011 Terremoto en Japón</gpf:title>
        <gpf:read_auth_key_required>true</gpf:read_auth_key_required>
        <gpf:search_auth_key_required>true</gpf:search_auth_key_required>
        <gpf:test_mode>true</gpf:test_mode>
        <gpf:location>
          <georss:point>38 140.7</georss:point>
        </gpf:location>
      </gpf:repo>
    </content>
  </entry>
</feed>
''' % (self.hostport, ROOT_URL)
        assert expected_content == doc.content, \
            text_diff(expected_content, doc.content)

        # verify we logged the repo read.
        self.verify_api_log(ApiActionLog.REPO, api_key='')
Exemplo n.º 2
0
    def test_repo_feed_all_launched_repos(self):
        config.set_for_repo('haiti',
                deactivated=True, launched=True, test_mode=False)
        config.set_for_repo('japan',
                deactivated=False, launched=True, test_mode=True,
                updated_date=utils.get_timestamp(
                        datetime.datetime(2012, 03, 11)))
        config.set_for_repo('pakistan',
                deactivated=False, launched=False, test_mode=False)

        # 'haiti', 'japan', and 'pakistan' exist in the datastore. Only those
        # which are 'launched' and not 'deactivated' i.e., only 'japan' should
        # appear in the feed.
        doc = self.go('/global/feeds/repo')
        expected_content = u'''\
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
      xmlns:gpf="http://schemas.google.com/personfinder/2012"
      xmlns:georss="http://www.georss.org/georss">
  <id>http://%s/personfinder/global/feeds/repo</id>
  <title>Person Finder Repository Feed</title>
  <updated>2012-03-11T00:00:00Z</updated>
  <entry>
    <id>%s/japan</id>
    <published>2011-03-11T00:00:00Z</published>
    <updated>2012-03-11T00:00:00Z</updated>
    <title xml:lang="ja">2011 日本地震</title>
    <content type="text/xml">
      <gpf:repo>
        <gpf:title xml:lang="ja">2011 日本地震</gpf:title>
        <gpf:title xml:lang="en">2011 Japan Earthquake</gpf:title>
        <gpf:title xml:lang="ko"></gpf:title>
        <gpf:title xml:lang="zh-CN">2011 日本地震</gpf:title>
        <gpf:title xml:lang="zh-TW">2011 日本地震</gpf:title>
        <gpf:title xml:lang="pt-BR">2011 Terremoto no Japão</gpf:title>
        <gpf:title xml:lang="es">2011 Terremoto en Japón</gpf:title>
        <gpf:read_auth_key_required>true</gpf:read_auth_key_required>
        <gpf:search_auth_key_required>true</gpf:search_auth_key_required>
        <gpf:test_mode>true</gpf:test_mode>
        <gpf:location>
          <georss:point>38 140.7</georss:point>
        </gpf:location>
      </gpf:repo>
    </content>
  </entry>
</feed>
''' % (self.hostport, ROOT_URL)
        assert expected_content == doc.content, \
            text_diff(expected_content, doc.content)

        # verify we logged the repo read.
        self.verify_api_log(ApiActionLog.REPO, api_key='')
Exemplo n.º 3
0
    def test_repo_feed_deactivated_repo(self):
        config.set_for_repo('haiti', deactivated=True)
        doc = self.go('/haiti/feeds/repo')
        expected_content = '''\
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
      xmlns:gpf="http://schemas.google.com/personfinder/2012"
      xmlns:georss="http://www.georss.org/georss">
  <id>http://%s/personfinder/haiti/feeds/repo</id>
  <title>Person Finder Repository Feed</title>
</feed>
''' % self.hostport
        assert expected_content == doc.content, \
            text_diff(expected_content, doc.content)
Exemplo n.º 4
0
    def test_repo_feed_deactivated_repo(self):
        config.set_for_repo('haiti', deactivated=True)
        doc = self.go('/haiti/feeds/repo')
        expected_content = '''\
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
      xmlns:gpf="http://schemas.google.com/personfinder/2012"
      xmlns:georss="http://www.georss.org/georss">
  <id>http://%s/personfinder/haiti/feeds/repo</id>
  <title>Person Finder Repository Feed</title>
</feed>
''' % self.hostport
        assert expected_content == doc.content, \
            text_diff(expected_content, doc.content)
Exemplo n.º 5
0
    def test_repo_feed_activated_repo(self):
        doc = self.go('/haiti/feeds/repo')
        expected_content = u'''\
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
      xmlns:gpf="http://schemas.google.com/personfinder/2012"
      xmlns:georss="http://www.georss.org/georss">
  <id>http://%s/personfinder/haiti/feeds/repo</id>
  <title>Person Finder Repository Feed</title>
  <updated>2010-01-12T00:00:00Z</updated>
  <entry>
    <id>%s/haiti</id>
    <published>2010-01-12T00:00:00Z</published>
    <updated>2010-01-12T00:00:00Z</updated>
    <title xml:lang="en">Haiti Earthquake</title>
    <content type="text/xml">
      <gpf:repo>
        <gpf:title xml:lang="en">Haiti Earthquake</gpf:title>
        <gpf:title xml:lang="ht">Tranbleman Tè an Ayiti</gpf:title>
        <gpf:title xml:lang="fr">Séisme en Haïti</gpf:title>
        <gpf:title xml:lang="es">Terremoto en Haití</gpf:title>
        <gpf:read_auth_key_required>false</gpf:read_auth_key_required>
        <gpf:search_auth_key_required>false</gpf:search_auth_key_required>
        <gpf:test_mode>false</gpf:test_mode>
        <gpf:location>
          <georss:point>18.968637 -72.284546</georss:point>
        </gpf:location>
      </gpf:repo>
    </content>
  </entry>
</feed>
''' % (self.hostport, ROOT_URL)
        assert expected_content == doc.content, \
            text_diff(expected_content, doc.content)

        # verify we logged the repo read.
        self.verify_api_log(ApiActionLog.REPO, api_key='')
Exemplo n.º 6
0
    def test_repo_feed_activated_repo(self):
        doc = self.go('/haiti/feeds/repo')
        expected_content = u'''\
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
      xmlns:gpf="http://schemas.google.com/personfinder/2012"
      xmlns:georss="http://www.georss.org/georss">
  <id>http://%s/personfinder/haiti/feeds/repo</id>
  <title>Person Finder Repository Feed</title>
  <updated>2010-01-12T00:00:00Z</updated>
  <entry>
    <id>%s/haiti</id>
    <published>2010-01-12T00:00:00Z</published>
    <updated>2010-01-12T00:00:00Z</updated>
    <title xml:lang="en">Haiti Earthquake</title>
    <content type="text/xml">
      <gpf:repo>
        <gpf:title xml:lang="en">Haiti Earthquake</gpf:title>
        <gpf:title xml:lang="ht">Tranbleman Tè an Ayiti</gpf:title>
        <gpf:title xml:lang="fr">Séisme en Haïti</gpf:title>
        <gpf:title xml:lang="es">Terremoto en Haití</gpf:title>
        <gpf:read_auth_key_required>false</gpf:read_auth_key_required>
        <gpf:search_auth_key_required>false</gpf:search_auth_key_required>
        <gpf:test_mode>false</gpf:test_mode>
        <gpf:location>
          <georss:point>18.968637 -72.284546</georss:point>
        </gpf:location>
      </gpf:repo>
    </content>
  </entry>
</feed>
''' % (self.hostport, ROOT_URL)
        assert expected_content == doc.content, \
            text_diff(expected_content, doc.content)

        # verify we logged the repo read.
        self.verify_api_log(ApiActionLog.REPO, api_key='')
Exemplo n.º 7
0
from test_pfif import text_diff

if __name__ == '__main__':
    filename = get_po_filename('en')
    english = pofile.read_po(open(filename))
    count = 0

    def printsep():
        if count > 0:
            print '-------------------------------------'

    for msg in english:
        # Each newly translated string will have msg.string set
        # to the 'translated' english value.
        if msg.id and msg.string and msg.string != msg.id:
            if isinstance(msg.id, tuple):
                # TODO(lschumacher): deal with plurals properly,
                if msg.string[0] or msg.string[1]:
                    printsep()
                    print 'msg id: %s\nmsgstr: %s' % (msg.id, msg.string)
                    count += 1
            else:
                printsep()
                print text_diff(msg.id, msg.string)
                count += 1
    if count:
        printsep()
        print 'Found %s bad translations' % count
    else:
        print 'Translation OK'
Exemplo n.º 8
0
from find_missing_translations import get_po_filename
from test_pfif import text_diff

if __name__ == '__main__':
    filename = get_po_filename('en')
    english = pofile.read_po(open(filename))
    count = 0
    def printsep():
        if count > 0:
            print('-------------------------------------')

    for msg in english: 
        # Each newly translated string will have msg.string set
        # to the 'translated' english value.        
        if msg.id and msg.string and msg.string != msg.id:
            if isinstance(msg.id, tuple):
                # TODO(lschumacher): deal with plurals properly, 
                if msg.string[0] or msg.string[1]:
                    printsep()
                    print('msg id: %s\nmsgstr: %s' % (msg.id, msg.string))
                    count += 1
            else:
                printsep()
                print(text_diff(msg.id, msg.string))
                count += 1
    if count:
        printsep()
        print('Found %s bad translations' % count)
    else:
        print('Translation OK')
from test_pfif import text_diff

if __name__ == "__main__":
    filename = get_po_filename("en")
    english = pofile.read_po(open(filename))
    count = 0

    def printsep():
        if count > 0:
            print "-------------------------------------"

    for msg in english:
        # Each newly translated string will have msg.string set
        # to the 'translated' english value.
        if msg.id and msg.string and msg.string != msg.id:
            if isinstance(msg.id, tuple):
                # TODO(lschumacher): deal with plurals properly,
                if msg.string[0] or msg.string[1]:
                    printsep()
                    print "msg id: %s\nmsgstr: %s" % (msg.id, msg.string)
                    count += 1
            else:
                printsep()
                print text_diff(msg.id, msg.string)
                count += 1
    if count:
        printsep()
        print "Found %s bad translations" % count
    else:
        print "Translation OK"
Exemplo n.º 10
0
from find_missing_translations import get_po_filename
from test_pfif import text_diff

if __name__ == '__main__':
    filename = get_po_filename('en')
    english = pofile.read_po(open(filename))
    count = 0
    def printsep():
        if count > 0:
            print('-------------------------------------')

    for msg in english: 
        # Each newly translated string will have msg.string set
        # to the 'translated' english value.        
        if msg.id and msg.string and msg.string != msg.id:
            if isinstance(msg.id, tuple):
                # TODO(lschumacher): deal with plurals properly, 
                if msg.string[0] or msg.string[1]:
                    printsep()
                    print('msg id: %s\nmsgstr: %s' % (msg.id, msg.string))
                    count += 1
            else:
                printsep()
                print(text_diff(msg.id, msg.string))
                count += 1
    if count:
        printsep()
        print('Found %s bad translations' % count)
    else:
        print('Translation OK')