def client_to_existing_content(running_server): client = ServerClient(running_server) client.post_point( "f-score", Point.create(0.72, timestamp=FIXED_TIMESTAMP), ) client.post_point( "f-score", Point.create(0.75, timestamp=FIXED_TIMESTAMP), ) client.post_point( "cost", Point.create(19.0, params={"team": "vege"}), ) client.post_point( "cost", Point.create(20.0, params={"team": "burgery"}), ) client.post_point( "cost", Point.create(20, params={"team": "vege"}), ) first_view = [ ChartConfig(metric_id="cost", x_accessor="timestamp", restrictions={"team": "vege"}), ChartConfig(metric_id="cost", x_accessor="timestamp", restrictions={"team": "burgery"}), ] client._post_view("sample-view", first_view) client._post_view( "sample-view", [ *first_view, ChartConfig(metric_id="cost", x_accessor="timestamp", restrictions={"team": "olimp"}), ], ) return client
def test_existing_points(client_to_existing_content: ServerClient): client = client_to_existing_content actual = client.get_points("f-score") assert actual == [ Point( value=0.75, params={}, timestamp=datetime.fromisoformat("2020-04-29T12:06:23"), version=None, ), Point( value=0.72, params={}, timestamp=datetime.fromisoformat("2020-04-29T12:06:23"), version=None, ), ]
def init_ui(self): main_layout = QVBoxLayout() button_layout = QHBoxLayout() address_layout = QVBoxLayout() input_address_layout = QHBoxLayout() self.image = QLabel() self.image.setMinimumSize(600, 450) self.api.add_point(Point(self.api.return_coordinates())) self.put_image_in_label() self.address = QLabel() self.set_address_text() self.address_input = QLineEdit() search_address_button = QPushButton('Найти адрес') search_address_button.clicked.connect(self.search_address) show_postal_code_checkbox = QCheckBox('Показывать индекс') show_postal_code_checkbox.clicked.connect(self.change_show_postal_code) clear_address_button = QPushButton('Сбросить результат поиска') clear_address_button.clicked.connect(self.clear_address) scheme_map_style_button = QPushButton('Схема') scheme_map_style_button.setObjectName('map') scheme_map_style_button.clicked.connect(self.set_map_style) satellite_map_style_button = QPushButton('Спутник') satellite_map_style_button.setObjectName('sat') satellite_map_style_button.clicked.connect(self.set_map_style) hybrid_map_style_button = QPushButton('Гибрид') hybrid_map_style_button.setObjectName('sat,skl') hybrid_map_style_button.clicked.connect(self.set_map_style) # Set up layouts input_address_layout.addWidget(self.address_input) input_address_layout.addWidget(search_address_button) address_layout.addLayout(input_address_layout) address_layout.addWidget(show_postal_code_checkbox) address_layout.addWidget(clear_address_button) main_layout.addLayout(address_layout) main_layout.addWidget(self.image) button_layout.addWidget(scheme_map_style_button) button_layout.addWidget(satellite_map_style_button) button_layout.addWidget(hybrid_map_style_button) main_layout.addLayout(button_layout) main_layout.addWidget(self.address) self.setLayout(main_layout) self.setMaximumSize(self.sizeHint())
def test_posting_points_with_different_schema( client_to_existing_content: ServerClient, p2: Point, ): p1 = Point( value=0.75, params={"lang": "suahili"}, timestamp=None, version=None, ) # first post should be OK - it defines the schema client_to_existing_content.post_point("blabla", p1) with pytest.raises(KPYayError): client_to_existing_content.post_point("blabla", p2)
def test_datestamp_serialization(variant: datetime, formatted): assert Point._fmt_ts(variant) == formatted
def test_point_serialization(p: Point, json_str): assert p.to_json() == json_str
"sample-view", [ *first_view, ChartConfig(metric_id="cost", x_accessor="timestamp", restrictions={"team": "olimp"}), ], ) return client @pytest.mark.parametrize( "p, json_str", [ (Point.create(0.5), """{"value": 0.5, "params": {}}"""), ( Point.create(1, params={"team": "vege"}), """{"value": 1.0, "params": {"team": "vege"}}""", ), ( Point.create(1, version="1.2.0"), """{"value": 1.0, "params": {}, "version": [1, 2, 0]}""", ), ( Point.create(1, version="2012.5.12"), """{"value": 1.0, "params": {}, "version": [2012, 5, 12]}""", ), ( Point.create(1, timestamp=FIXED_TIMESTAMP), """{"value": 1.0, "params": {}, "timestamp": "%s"}""" %