Exemple #1
0
    def request_equity(self, equity):
        req = webtest.HttpRequest()
        req.method = webtest._method_GET
        req.host = 'www.google.com'
        req.ssl = True
        req.url = '/finance?q=' + equity.exchange + '%3A' + equity.ticker

        response = webtest.WebService.send_request(req)
        return response
Exemple #2
0
    def create_snapshot(self, snapshot):
        req = webtest.HttpRequest()
        req.host = self.host + ':' + str(self.port)
        req.method = webtest._method_POST
        req.url = self.snapshots_root

        req.headers = {webtest._header_content_type: webtest._accept_JSON}

        req.body = json.dumps(snapshot.__dict__)
        print('About to send ' + req.body + ' to ' + self.host + ":" + str(self.port) + self.snapshots_root)

        resp = webtest.WebService.send_request(req)
        print('response = ' + resp)
Exemple #3
0
    def get_jira(self, ticket):
        req = webtest.HttpRequest()

        req.ssl = True
        req.headers[webtest._header_authorization] = 'Basic ' + self.encoded_credentials
        req.headers[webtest._header_accept] = webtest._accept_JSON
        req.host = self.jira_host
        req.url = issue_path + ticket
        req.method = webtest._method_GET

        response = webtest.WebService.send_request(req)
        if response['code'] > 299:
            raise Exception('Warning - response code = ' + str(response['code']) + '. You could get locked out after three attempts with the wrong password')
        return json.loads(response['data'])
Exemple #4
0
    def cleanup_cloned_link(self, issue_id, link_id, link_url):
        parsed_url = Jira.parse_host_and_uri(link_url)

        # Path to the actual link resource to delete
        del_path = issue_link_path + link_id

        req = webtest.HttpRequest()
        req.ssl = True
        req.method = 'DELETE'
        req.headers[webtest._header_authorization] = 'Basic ' + self.encoded_credentials
        req.headers[webtest._header_accept] = webtest._accept_JSON
        req.host = parsed_url['host']
        req.url = del_path

        response = webtest.WebService.send_request(req)
        if response['code'] > 299:
            raise Exception('Warning - response code = ' + str(response['code']) + '. You could get locked out after three attempts with the wrong password')
        elif response['code'] == 204:
            print('Deletion successful')
Exemple #5
0
    def create_equity(self, equity):
        req = webtest.HttpRequest()
        req.host = self.host + ':' + str(self.port)
        req.method = webtest._method_POST
        req.url = self.equities_root

        del equity.equity_id
        del equity.snapshots
        del equity.aggregates

        req.body = json.dumps(equity.__dict__)

        req.headers = {
            webtest._header_content_type: webtest._accept_JSON,
            webtest._header_accept: webtest._accept_JSON
        }

        resp = webtest.WebService.send_request(req)
        print('response = ' + resp)

        return self.map_equity_to_domain(json.loads(resp))
Exemple #6
0
    def get_all_equities(self, filter=None):
        req = webtest.HttpRequest()
        req.host = self.host + ':' + str(self.port)
        req.method = webtest._method_GET

        if filter is not None:
            req.url = self.equities_root + '?filter=' + filter
        else:
            req.url = self.equities_root

        req.headers = {webtest._header_accept: webtest._accept_JSON}

        resp = webtest.WebService.send_request(req)
        print('response = ' + resp)

        equities_json = json.loads(resp)
        equities = []

        for e in equities_json:
            equities.append(self.map_equity_to_domain(e))

        return equities
Exemple #7
0
    def update_jira_summary(self, jira, new_summary):
        parsed_url = Jira.parse_host_and_uri(jira['self'])

        summary_json = {
            "fields": {
                "summary": new_summary
            }
        }

        req = webtest.HttpRequest()
        req.ssl = True
        req.body = json.dumps(summary_json)
        req.headers[webtest._header_authorization] = 'Basic ' + self.encoded_credentials
        req.headers[webtest._header_content_type] = webtest._accept_JSON
        req.headers[webtest._header_accept] = webtest._accept_JSON
        req.host = parsed_url['host']
        req.url = parsed_url['path']
        req.method = 'PUT'

        response = webtest.WebService.send_request(req)
        if response['code'] > 299:
            raise Exception('Warning - response code = ' + str(response['code']) + '. You could get locked out after three attempts with the wrong password')
Exemple #8
0
    def assign_label(self, cloned_jira, label):
        parsed_url = Jira.parse_host_and_uri(cloned_jira['self'])
        label_json = {
            'fields': {
                'labels': [
                    label
                ]
            }
        }

        req = webtest.HttpRequest()
        req.ssl = True
        req.body = json.dumps(label_json)
        req.headers[webtest._header_authorization] = 'Basic ' + self.encoded_credentials
        req.headers[webtest._header_content_type] = webtest._accept_JSON
        req.headers[webtest._header_accept] = webtest._accept_JSON
        req.host = parsed_url['host']
        req.url = parsed_url['path']
        req.method = 'PUT'

        response = webtest.WebService.send_request(req)
        if response['code'] > 299:
            raise Exception('Warning - response code = ' + str(response['code']) + '. You could get locked out after three attempts with the wrong password')