Exemple #1
0
    def test_json_parse__json_format__json_dumps__json_loads(self):
        data = {'answer': 42}
        assert json_dumps(data) == '{\n    "answer": 42\n}'
        assert json_format(data) == '{\n    "answer": 42\n}'
        assert json_parse(json_dumps(data)) == data
        assert json_loads(json_dumps(data)) == data

        assert json_dumps(None) is None
        assert json_format(None) is None
        assert json_parse(None) == {}
        assert json_loads(None) == {}
Exemple #2
0
 def issue_status_available(self, issue_id):
     items = {}
     if issue_id:
         path = 'issue/{0}/transitions'.format(issue_id)
         data = self.request_get(path)
         if data:
             for transition in json_loads(data).get('transitions'):
                 to_data = transition.get('to')
                 items[to_data.get('name')] = to_data.get('id')
     return items
Exemple #3
0
 def create(self, manifest):
     try:
         pod_info = self.api_core().create_namespaced_pod(
             body=manifest, namespace=self.cluster.namespace().name)
         return status_ok(message="pod created", data=pod_info)
     except ApiException as exception:
         exception_body = json_loads(exception.body)
         return status_error(message=exception_body.get('message'),
                             error=exception)
     except Exception as exception:
         return status_error(error=exception)
Exemple #4
0
    def test_push_pull(self):
        self.queue.push({'var_1': 'value_1', 'var_2': 'value_2'})
        assert json_loads(self.queue.get_message()) == {
            "var_1": "value_1",
            "var_2": "value_2"
        }

        self.queue.push({'var_3': 'value_3', 'var_4': 'value_4'})
        assert self.queue.pull() == {
            'var_3': 'value_3',
            'var_4': 'value_4'
        }  # is python object

        self.queue.push([{
            'var_5': 'value_5'
        }, {
            'var_6': 'value_7'
        }])  # push an array
        assert self.queue.pull() == [{
            'var_5': 'value_5'
        }, {
            'var_6': 'value_7'
        }]  # comes back as an array
Exemple #5
0
 def invoke(self, method):
     username, password = self.secrets()
     command = 'gsbot_jira'
     url = "{0}/{1}/{2}".format(self.ngrok_url, command, method)
     return json_loads(requests.get(url, auth=(username, password)).text)
Exemple #6
0
 def lambda_invoke(self, params):
     result = self.lambda_graph.invoke({'params': params, 'data': {}})
     return json_loads(result)
Exemple #7
0
 def pop(self, delete_message=True):
     data_json = self.get_message(delete_message=delete_message)
     if data_json:
         return json_loads(data_json)
     return None
Exemple #8
0
 def test_json_loads__bad_json(self):
     bad_json = "{ bad : json }"
     expected_message = 'json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 3 (char 2)\n'
     with Log_To_String(logger_json) as log_to_string:
         assert json_loads(bad_json) == {}
         assert expected_message in log_to_string.contents()
Exemple #9
0
 def policy(self, queue_url):
     value = self.queue_attributes(queue_url=queue_url).get('Policy')
     if value:
         return json_loads(value)
     return {}
Exemple #10
0
 def issue_delete(self, issue_id):
     if issue_id:
         path = f'issue/{issue_id}'
         data = self.request_delete(path)
         return json_loads(data)
Exemple #11
0
 def fields(self):
     if self._fields is None:
         self._fields = json_loads(self.request_get('field'))
     return self._fields
Exemple #12
0
 def projects(self):
     projects = {}
     data = json_loads(self.request_get('issue/createmeta')).get('projects')
     for item in data:
         projects[item.get('key')] = item
     return projects
Exemple #13
0
 def issue_raw(self, issue_id, fields='*all'):
     if issue_id:
         path = 'issue/{0}?fields={1}'.format(issue_id, fields)
         data = self.request_get(path)
         return json_loads(data)