Пример #1
0
 def test_13_Json_Decode(self):
     """
     Expect this to fail and return None (missing ']')
     """
     x = '[{"de4" : "D E F"}'
     y = web_utils.JsonUnicode().decode_json(x)
     self.assertEqual(y, None)
Пример #2
0
 def saveWebData(self, p_json):
     """A new/changed web is returned.  Process it and update the internal data via ???.py
     """
     l_json = web_utils.JsonUnicode().decode_json(p_json)
     l_obj = WebData()
     l_obj.Port = l_json['Port']
     self.m_pyhouse_obj.APIs.Computer.WebAPI.SaveXml(l_obj)
Пример #3
0
    def doLogin(self, p_json):
        """ This will receive json of username, password when the user clicks on the login button in the browser.

            First, we validate the user
            If valid, display the user and then the root menu.
            If not - allow the user to retry the login.

            also

            allow user to check the change button and apply the change after logging in the user.

            @param p_json: is the username and password passed back by the client.
        """
        LOG.info("doLogin called {}.".format(
            PrettyFormatAny.form(p_json, 'Login From Browser')))
        l_obj = web_utils.JsonUnicode().decode_json(p_json)
        l_login_obj = self.validate_user(l_obj)
        l_json = json_tools.encode_json(l_login_obj)
        return unicode(l_json)
Пример #4
0
 def test_12_Json_Decode(self):
     x = '[{"de4" : "D E F"}]'
     y = web_utils.JsonUnicode().decode_json(x)
     self.assertNotEqual(y, None)
Пример #5
0
 def test_02_Decode(self):
     y = web_utils.JsonUnicode().convert_from_unicode(u'ABC')
     self.assertEquals(y, 'ABC', "Convert from unicode failed.")
Пример #6
0
 def test_01_Encode(self):
     y = web_utils.JsonUnicode().convert_to_unicode('abc')
     self.assertEquals(y, u'abc')