| 1 | # coding: utf-8
|
|---|
| 2 |
|
|---|
| 3 | from __future__ import absolute_import
|
|---|
| 4 | import unittest
|
|---|
| 5 |
|
|---|
| 6 | from flask import json
|
|---|
| 7 | from six import BytesIO
|
|---|
| 8 |
|
|---|
| 9 | from openapi_server.models.gauge import Gauge # noqa: E501
|
|---|
| 10 | from openapi_server.models.gauge_creation import GaugeCreation # noqa: E501
|
|---|
| 11 | from openapi_server.models.http_error import HttpError # noqa: E501
|
|---|
| 12 | from openapi_server.models.water import Water # noqa: E501
|
|---|
| 13 | from openapi_server.models.water_creation import WaterCreation # noqa: E501
|
|---|
| 14 | from openapi_server.test import BaseTestCase
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 | class TestWatersController(BaseTestCase):
|
|---|
| 18 | """WatersController integration test stubs"""
|
|---|
| 19 |
|
|---|
| 20 | def test_waters_create(self):
|
|---|
| 21 | """Test case for waters_create
|
|---|
| 22 |
|
|---|
| 23 | Add a new water
|
|---|
| 24 | """
|
|---|
| 25 | water_creation = {
|
|---|
| 26 | "osmId" : 0,
|
|---|
| 27 | "name" : "name"
|
|---|
| 28 | }
|
|---|
| 29 | headers = {
|
|---|
| 30 | 'Accept': 'application/json',
|
|---|
| 31 | 'Content-Type': 'application/json',
|
|---|
| 32 | 'X-API-KEY': 'test_key',
|
|---|
| 33 | 'Authorization': 'BasicZm9vOmJhcg==',
|
|---|
| 34 | }
|
|---|
| 35 | response = self.client.open(
|
|---|
| 36 | '/mapservice/v1/waters',
|
|---|
| 37 | method='POST',
|
|---|
| 38 | headers=headers,
|
|---|
| 39 | data=json.dumps(water_creation),
|
|---|
| 40 | content_type='application/json')
|
|---|
| 41 | self.assert200(response,
|
|---|
| 42 | 'Response body is : ' + response.data.decode('utf-8'))
|
|---|
| 43 |
|
|---|
| 44 | def test_waters_gauge_create(self):
|
|---|
| 45 | """Test case for waters_gauge_create
|
|---|
| 46 |
|
|---|
| 47 | Add a new water
|
|---|
| 48 | """
|
|---|
| 49 | gauge_creation = {
|
|---|
| 50 | "name" : "name",
|
|---|
| 51 | "location" : [ 0.8008281904610115, 0.8008281904610115 ],
|
|---|
| 52 | "comment" : "comment"
|
|---|
| 53 | }
|
|---|
| 54 | headers = {
|
|---|
| 55 | 'Accept': 'application/json',
|
|---|
| 56 | 'Content-Type': 'application/json',
|
|---|
| 57 | 'X-API-KEY': 'test_key',
|
|---|
| 58 | 'Authorization': 'BasicZm9vOmJhcg==',
|
|---|
| 59 | }
|
|---|
| 60 | response = self.client.open(
|
|---|
| 61 | '/mapservice/v1/waters/{water_id}/gauges'.format(water_id='56'),
|
|---|
| 62 | method='POST',
|
|---|
| 63 | headers=headers,
|
|---|
| 64 | data=json.dumps(gauge_creation),
|
|---|
| 65 | content_type='application/json')
|
|---|
| 66 | self.assert200(response,
|
|---|
| 67 | 'Response body is : ' + response.data.decode('utf-8'))
|
|---|
| 68 |
|
|---|
| 69 | def test_waters_gauge_get_by_id(self):
|
|---|
| 70 | """Test case for waters_gauge_get_by_id
|
|---|
| 71 |
|
|---|
| 72 | Represents a gauge
|
|---|
| 73 | """
|
|---|
| 74 | headers = {
|
|---|
| 75 | 'Accept': 'application/json',
|
|---|
| 76 | }
|
|---|
| 77 | response = self.client.open(
|
|---|
| 78 | '/mapservice/v1/waters/{water_id}/gauges/{gauge_id}'.format(water_id='56', gauge_id='56'),
|
|---|
| 79 | method='GET',
|
|---|
| 80 | headers=headers)
|
|---|
| 81 | self.assert200(response,
|
|---|
| 82 | 'Response body is : ' + response.data.decode('utf-8'))
|
|---|
| 83 |
|
|---|
| 84 | def test_waters_gauges_get(self):
|
|---|
| 85 | """Test case for waters_gauges_get
|
|---|
| 86 |
|
|---|
| 87 | Find gauges of water waterId by gaugeId
|
|---|
| 88 | """
|
|---|
| 89 | query_string = [('name', 'Missi'),
|
|---|
| 90 | ('manager', 'jane'),
|
|---|
| 91 | ('order_by', 'name'),
|
|---|
| 92 | ('offset', '0'),
|
|---|
| 93 | ('limit', '10')]
|
|---|
| 94 | headers = {
|
|---|
| 95 | 'Accept': 'application/json',
|
|---|
| 96 | }
|
|---|
| 97 | response = self.client.open(
|
|---|
| 98 | '/mapservice/v1/waters/{water_id}/gauges'.format(water_id='56'),
|
|---|
| 99 | method='GET',
|
|---|
| 100 | headers=headers,
|
|---|
| 101 | query_string=query_string)
|
|---|
| 102 | self.assert200(response,
|
|---|
| 103 | 'Response body is : ' + response.data.decode('utf-8'))
|
|---|
| 104 |
|
|---|
| 105 | def test_waters_get(self):
|
|---|
| 106 | """Test case for waters_get
|
|---|
| 107 |
|
|---|
| 108 | Find waters by id
|
|---|
| 109 | """
|
|---|
| 110 | query_string = [('name', 'Missi'),
|
|---|
| 111 | ('manager', 'jane'),
|
|---|
| 112 | ('order_by', 'name'),
|
|---|
| 113 | ('offset', '0'),
|
|---|
| 114 | ('limit', '10')]
|
|---|
| 115 | headers = {
|
|---|
| 116 | 'Accept': 'application/json',
|
|---|
| 117 | }
|
|---|
| 118 | response = self.client.open(
|
|---|
| 119 | '/mapservice/v1/waters',
|
|---|
| 120 | method='GET',
|
|---|
| 121 | headers=headers,
|
|---|
| 122 | query_string=query_string)
|
|---|
| 123 | self.assert200(response,
|
|---|
| 124 | 'Response body is : ' + response.data.decode('utf-8'))
|
|---|
| 125 |
|
|---|
| 126 | def test_waters_get_by_id(self):
|
|---|
| 127 | """Test case for waters_get_by_id
|
|---|
| 128 |
|
|---|
| 129 | Represents a water
|
|---|
| 130 | """
|
|---|
| 131 | headers = {
|
|---|
| 132 | 'Accept': 'application/json',
|
|---|
| 133 | }
|
|---|
| 134 | response = self.client.open(
|
|---|
| 135 | '/mapservice/v1/waters/{id}'.format(id='56'),
|
|---|
| 136 | method='GET',
|
|---|
| 137 | headers=headers)
|
|---|
| 138 | self.assert200(response,
|
|---|
| 139 | 'Response body is : ' + response.data.decode('utf-8'))
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 | if __name__ == '__main__':
|
|---|
| 143 | unittest.main()
|
|---|