Пример #1
0
    def setUpClass(self):
        """Setting up the globalization pipeline for testing"""
        acc = common.get_admin_gpserviceaccount()
        client = GPClient(acc)
        try:
            client.delete_bundle(common.bundleId1)
            client.delete_bundle(common.bundleId2)

            data = {}
            data['sourceLanguage'] = "en"
            data['targetLanguages'] = ["fr", "es-mx"]
            data['notes'] = ["string"]
            data['metadata'] = {}
            data['partner'] = ''
            data['segmentSeparatorPattern'] = 'string'
            data['noTranslationPattern'] = 'string'

            client.create_bundle(common.bundleId1, data=data)
            bundle1_entries = {}
            bundle1_entries['greet'] = "Hello"
            bundle1_entries['weather'] = "It is snowing"
            client.upload_resource_entries(common.bundleId1,
                                           "en",
                                           data=bundle1_entries)

            client.create_bundle(common.bundleId2, data=data)
            bundle2_entries = {}
            bundle2_entries['exit'] = "Goodbye"
            bundle2_entries['show'] = "The Wire"
            client.upload_resource_entries(common.bundleId2,
                                           "en",
                                           data=bundle2_entries)
        except:
            pass
Пример #2
0
    def test_admin_basic_auth(self):
        """Verify basic auth fails with admin account"""
        acc = common.get_admin_gpserviceaccount()
        client = GPClient(acc, auth=GPClient.BASIC_AUTH)
        ids = client.get_bundles()

        self.assertEqual(0, len(ids),
                         "Admin account can not use basic authentication")
Пример #3
0
    def test_delete_bundle_success(self):
        """Test to delete a specific bundle which exists"""
        acc = common.get_admin_gpserviceaccount()
        client = GPClient(acc)

        tresp = client.delete_bundle("test-bundle")

        common.my_assert_equal(self, "SUCCESS", tresp["status"],
                               'bundle could not be deleted')
Пример #4
0
    def test_create_bundle(self):
        """Test to create a new bundle"""
        acc = common.get_admin_gpserviceaccount()
        client = GPClient(acc)

        tresp = client.create_bundle("test-bundle")

        common.my_assert_equal(self, "SUCCESS", tresp["status"],
                               'bundle could not be created')
Пример #5
0
    def test_delete_bundle_fail(self):
        """Test to delete a specific bundle which doesn't exist"""
        acc = common.get_admin_gpserviceaccount()
        client = GPClient(acc)

        tresp = client.delete_bundle("test-bundle-notexists")

        common.my_assert_equal(
            self, "ERROR", tresp["status"],
            'a bundle which does not exist can not be deleted')
Пример #6
0
 def test_upload_resource_entries(self):
     """Test to upload resource entries"""
     acc = common.get_admin_gpserviceaccount()
     client = GPClient(acc)
     data = {}
     data["welcome"] = "Hello"
     tresp = client.upload_resource_entries(common.bundleId1,
                                            "en",
                                            data=data)
     common.my_assert_equal(
         self, "SUCCESS", tresp["status"],
         'bundle resource entries could not be uploaded')
Пример #7
0
 def test_update_resource_entries(self):
     """Test to update resource entries"""
     acc = common.get_admin_gpserviceaccount(True)
     client = GPClient(acc)
     data = {}
     data["welcome"] = "Welcome"
     tresp = client.update_resource_entries(common.bundleId1,
                                            "en",
                                            data=data)
     common.my_assert_equal(
         self, "SUCCESS", tresp["status"],
         'bundle resource entries for the language could not be updated')
Пример #8
0
 def test_update_resource_entry(self):
     """Test to update a resource entry"""
     acc = common.get_admin_gpserviceaccount()
     client = GPClient(acc)
     data = {}
     data['value'] = "weather in spanish"
     tresp = client.update_resource_entry(common.bundleId1,
                                          "es-mx",
                                          "weather",
                                          data=data)
     common.my_assert_equal(
         self, "SUCCESS", tresp["status"],
         'bundle resource entry for the language could not be updated')
Пример #9
0
    def test_admin_basic_auth(self):
        """Verify basic auth fails with admin account"""
        acc = common.get_admin_gpserviceaccount()
        client = GPClient(acc, auth=GPClient.BASIC_AUTH)

        languages=['es-mx']

        t = client.gp_translation(bundleId=common.bundleId2,
            languages=languages)
        _ = t.gettext

        value = _('show')

        common.my_assert_equal(self, 'show', value,
            'admin acc can not use basic auth')