From 729318bb61c26016e892c18c29639f638d4da954 Mon Sep 17 00:00:00 2001 From: Guillaume Grossetie Date: Mon, 21 Aug 2023 10:22:35 +0200 Subject: [PATCH] Use native binary for WireViz (#1591) Built using Nuitka on https://github.com/yuzutech/WireViz --- ci/tasks/update-versions.js | 16 +- ci/tests/docker-compose.yaml | 6 - docker-bake-release.hcl | 4 - docker-bake.hcl | 7 +- .../k8s-multi-pod/wireviz-deployment.yaml | 23 --- .../k8s-multi-pod/wireviz-service.yaml | 15 -- server/ops/docker/jdk11-jammy/Dockerfile | 6 +- .../src/main/java/io/kroki/server/Server.java | 2 +- .../io/kroki/server/service/Wavedrom.java | 6 +- .../java/io/kroki/server/service/Wireviz.java | 33 ++-- wireviz/.dockerignore | 3 - wireviz/.editorconfig | 14 -- wireviz/.gitignore | 2 - wireviz/Dockerfile | 25 --- wireviz/Makefile | 12 -- wireviz/README.adoc | 35 ---- wireviz/examples.py | 52 ------ wireviz/requirements.txt | 11 -- wireviz/src/backend/__init__.py | 0 wireviz/src/backend/error.py | 14 -- wireviz/src/server.py | 108 ----------- wireviz/src/wsgi.py | 5 - wireviz/test/__init__.py | 0 wireviz/test/fixtures/wireviz_expected.svg | 172 ------------------ wireviz/test/fixtures/wireviz_source.txt | 26 --- wireviz/test/test_wireviz.py | 31 ---- 26 files changed, 34 insertions(+), 594 deletions(-) delete mode 100644 docs/modules/setup/examples/k8s-multi-pod/wireviz-deployment.yaml delete mode 100644 docs/modules/setup/examples/k8s-multi-pod/wireviz-service.yaml delete mode 100644 wireviz/.dockerignore delete mode 100644 wireviz/.editorconfig delete mode 100644 wireviz/.gitignore delete mode 100644 wireviz/Dockerfile delete mode 100644 wireviz/Makefile delete mode 100644 wireviz/README.adoc delete mode 100644 wireviz/examples.py delete mode 100644 wireviz/requirements.txt delete mode 100644 wireviz/src/backend/__init__.py delete mode 100644 wireviz/src/backend/error.py delete mode 100644 wireviz/src/server.py delete mode 100644 wireviz/src/wsgi.py delete mode 100644 wireviz/test/__init__.py delete mode 100644 wireviz/test/fixtures/wireviz_expected.svg delete mode 100644 wireviz/test/fixtures/wireviz_source.txt delete mode 100644 wireviz/test/test_wireviz.py diff --git a/ci/tasks/update-versions.js b/ci/tasks/update-versions.js index c2bb53ce8..f9906cc71 100755 --- a/ci/tasks/update-versions.js +++ b/ci/tasks/update-versions.js @@ -126,17 +126,6 @@ const diagramLibraryNames = [ ] try { - const wirevizRequirementsContent = await fs.readFile(ospath.join(rootDir, 'wireviz', 'requirements.txt'), 'utf8') - for (const line of wirevizRequirementsContent.split('\n')) { - const found = line.match(/^(?[a-zA-Z]+)==(?.*)$/) - if (found) { - const { name, version } = found.groups - if (diagramLibraryNames.includes(name)) { - diagramLibraryVersions[name] = version - } - } - } - addDiagramLibraryPackageVersion('bpmn', 'bpmn-js') addDiagramLibraryPackageVersion('bytefield', 'bytefield-svg') addDiagramLibraryPackageVersion('dbml', '@softwaretechnik/dbml-renderer') @@ -209,6 +198,11 @@ try { diagramLibraryVersions.nwdiag = version diagramLibraryVersions.nwdiag = version } + const wirevizVersionFound = line.match(/^ARG WIREVIZ_VERSION="(?.+)"$/) + if (wirevizVersionFound) { + const { version } = wirevizVersionFound.groups + diagramLibraryVersions.wireviz = version + } } const svgbobCargoContent = await fs.readFile(ospath.join(rootDir, 'server', 'ops', 'docker', 'Cargo.toml'), 'utf8') diff --git a/ci/tests/docker-compose.yaml b/ci/tests/docker-compose.yaml index 7f357260c..d09d35458 100644 --- a/ci/tests/docker-compose.yaml +++ b/ci/tests/docker-compose.yaml @@ -12,7 +12,6 @@ services: - KROKI_BPMN_HOST=bpmn - KROKI_EXCALIDRAW_HOST=excalidraw - KROKI_DIAGRAMSNET_HOST=diagramsnet - - KROKI_WIREVIZ_HOST=wireviz ports: - "8000:8000" @@ -35,8 +34,3 @@ services: image: yuzutech/kroki-diagramsnet:smoketests expose: - "8005" - - wireviz: - image: yuzutech/kroki-wireviz:smoketests - ports: - - "8006:8006" diff --git a/docker-bake-release.hcl b/docker-bake-release.hcl index c6640074d..4acdf26b8 100644 --- a/docker-bake-release.hcl +++ b/docker-bake-release.hcl @@ -20,7 +20,3 @@ target "kroki-excalidraw" { target "kroki-diagramsnet" { tags = ["yuzutech/kroki-diagramsnet:${RELEASE_VERSION}", "yuzutech/kroki-diagramsnet:latest"] } - -target "kroki-wireviz" { - tags = ["yuzutech/kroki-wireviz:${RELEASE_VERSION}", "yuzutech/kroki-wireviz:latest"] -} diff --git a/docker-bake.hcl b/docker-bake.hcl index 19f397baa..24e28d800 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -3,7 +3,7 @@ variable "TAG" { } group "companion-images" { - targets = ["kroki-mermaid", "kroki-bpmn", "kroki-excalidraw", "kroki-diagramsnet", "kroki-wireviz"] + targets = ["kroki-mermaid", "kroki-bpmn", "kroki-excalidraw", "kroki-diagramsnet"] } target "kroki" { @@ -39,8 +39,3 @@ target "kroki-diagramsnet" { context = "diagrams.net" tags = ["yuzutech/kroki-diagramsnet:${TAG}"] } - -target "kroki-wireviz" { - context = "wireviz" - tags = ["yuzutech/kroki-wireviz:${TAG}"] -} diff --git a/docs/modules/setup/examples/k8s-multi-pod/wireviz-deployment.yaml b/docs/modules/setup/examples/k8s-multi-pod/wireviz-deployment.yaml deleted file mode 100644 index b76966aa1..000000000 --- a/docs/modules/setup/examples/k8s-multi-pod/wireviz-deployment.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - labels: - app: wireviz - name: wireviz -spec: - replicas: 1 - selector: - matchLabels: - app: wireviz - template: - metadata: - labels: - app: wireviz - spec: - containers: - - image: yuzutech/kroki-wireviz - name: wireviz - ports: - - containerPort: 8006 - restartPolicy: Always diff --git a/docs/modules/setup/examples/k8s-multi-pod/wireviz-service.yaml b/docs/modules/setup/examples/k8s-multi-pod/wireviz-service.yaml deleted file mode 100644 index df6180393..000000000 --- a/docs/modules/setup/examples/k8s-multi-pod/wireviz-service.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -apiVersion: v1 -kind: Service -metadata: - annotations: - labels: - app: wireviz - name: wireviz -spec: - ports: - - name: "8006" - port: 8006 - targetPort: 8006 - selector: - app: wireviz diff --git a/server/ops/docker/jdk11-jammy/Dockerfile b/server/ops/docker/jdk11-jammy/Dockerfile index 30a7138b3..02f832993 100644 --- a/server/ops/docker/jdk11-jammy/Dockerfile +++ b/server/ops/docker/jdk11-jammy/Dockerfile @@ -240,6 +240,7 @@ ARG UMLET_VERSION="2023-03-20_UMLet_v15.1" ARG GRAPHVIZ_VERSION="8.0.5" ARG DITAA_VERSION="1.0.3" ARG BLOCKDIAG_VERSION="3.1.0" +ARG WIREVIZ_VERSION="0.3.3" ARG TARGETARCH LABEL \ @@ -298,6 +299,9 @@ RUN wget "https://github.com/yuzutech/umlet/releases/download/${UMLET_VERSION}/u RUN wget "https://github.com/yuzutech/blockdiag/releases/download/v${BLOCKDIAG_VERSION}/blockdiag-bundle-linux-${TARGETARCH}.bin" -O /usr/bin/blockdiag && \ chmod +x /usr/bin/blockdiag +RUN wget "https://github.com/yuzutech/WireViz/releases/download/v${WIREVIZ_VERSION}/wireviz-linux-${TARGETARCH}.bin" -O /usr/bin/wireviz && \ + chmod +x /usr/bin/wireviz + COPY --from=kroki-builder-static-svgbob /usr/local/cargo/bin/svgbob_cli /usr/bin/svgbob COPY --from=kroki-builder-static-erd /root/.local/bin/erd /usr/bin/erd COPY --from=kroki-builder-static-pikchr /build/pikchr /usr/bin/pikchr @@ -329,7 +333,7 @@ ENV KROKI_PLANTUML_BIN_PATH=/usr/bin/plantuml ENV KROKI_TIKZ2SVG_BIN_PATH=/usr/bin/tikz2svg ENV KROKI_DITAA_BIN_PATH=/usr/bin/ditaa ENV KROKI_SYMBOLATOR_BIN_PATH=/usr/bin/symbolator -ENV KROKI_BLOCKDIAG_BIN_PATH=/usr/bin/blockdiag +ENV KROKI_WIREVIZ_BIN_PATH=/usr/bin/wireviz ENV JAVA_OPTS="-Dlogback.configurationFile=/etc/kroki/logback.xml -Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory" COPY --chown=kroki:kroki target/kroki-server.jar /usr/local/kroki/kroki-server.jar diff --git a/server/src/main/java/io/kroki/server/Server.java b/server/src/main/java/io/kroki/server/Server.java index f22ee4010..e9e763488 100644 --- a/server/src/main/java/io/kroki/server/Server.java +++ b/server/src/main/java/io/kroki/server/Server.java @@ -143,7 +143,7 @@ static void start(Vertx vertx, JsonObject config, Handler> handler) { vertx.executeBlocking(future -> { try { - byte[] result = vega(sourceDecoded.getBytes()); + byte[] result = commander.execute(sourceDecoded.getBytes(), binPath); future.complete(result); } catch (IOException | InterruptedException | IllegalStateException e) { future.fail(e); } }, res -> handler.handle(res.map(o -> Buffer.buffer((byte[]) o)))); } - - private byte[] vega(byte[] source) throws IOException, InterruptedException, IllegalStateException { - return commander.execute(source, binPath); - } } diff --git a/server/src/main/java/io/kroki/server/service/Wireviz.java b/server/src/main/java/io/kroki/server/service/Wireviz.java index 4c7889317..28aba72c5 100644 --- a/server/src/main/java/io/kroki/server/service/Wireviz.java +++ b/server/src/main/java/io/kroki/server/service/Wireviz.java @@ -1,5 +1,6 @@ package io.kroki.server.service; +import io.kroki.server.action.Commander; import io.kroki.server.action.Delegator; import io.kroki.server.decode.DiagramSource; import io.kroki.server.decode.SourceDecoder; @@ -13,28 +14,29 @@ import io.vertx.ext.web.client.HttpResponse; import io.vertx.ext.web.client.WebClient; +import java.io.IOException; import java.util.Arrays; +import java.util.Collections; import java.util.List; public class Wireviz implements DiagramService { private static final List SUPPORTED_FORMATS = Arrays.asList(FileFormat.PNG, FileFormat.SVG); - - private final WebClient client; + private final Vertx vertx; + private final String binPath; private final SourceDecoder sourceDecoder; - private final String host; - private final int port; + private final Commander commander; - public Wireviz(Vertx vertx, JsonObject config) { - this.client = WebClient.create(vertx); + public Wireviz(Vertx vertx, JsonObject config, Commander commander) { + this.vertx = vertx; + this.binPath = config.getString("KROKI_WIREVIZ_BIN_PATH", "wireviz"); this.sourceDecoder = new SourceDecoder() { @Override public String decode(String encoded) throws DecodeException { return DiagramSource.decode(encoded); } }; - this.host = config.getString("KROKI_WIREVIZ_HOST", "127.0.0.1"); - this.port = config.getInteger("KROKI_WIREVIZ_PORT", 8006); + this.commander = commander; } @Override @@ -49,13 +51,20 @@ public SourceDecoder getSourceDecoder() { @Override public String getVersion() { - return "0.3.2"; + return "0.3.3"; } @Override public void convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, Handler> handler) { - String requestURI = "/" + serviceName + "/" + fileFormat.getName(); - Handler>> responseHandler = Delegator.createHandler(host, port, requestURI, handler); - Delegator.delegate(client, host, port, requestURI, sourceDecoded, options, responseHandler); + vertx.executeBlocking(future -> { + try { + byte[] result = commander.execute(sourceDecoded.getBytes(), binPath, + "--format=" + fileFormat.getName(), + "-"); + future.complete(result); + } catch (IOException | InterruptedException | IllegalStateException e) { + future.fail(e); + } + }, res -> handler.handle(res.map(o -> Buffer.buffer((byte[]) o)))); } } diff --git a/wireviz/.dockerignore b/wireviz/.dockerignore deleted file mode 100644 index 9379563cb..000000000 --- a/wireviz/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -venv-py*/ -test/ -.idea/ diff --git a/wireviz/.editorconfig b/wireviz/.editorconfig deleted file mode 100644 index 25ac5ff12..000000000 --- a/wireviz/.editorconfig +++ /dev/null @@ -1,14 +0,0 @@ -root = true - -[*] -end_of_line = lf -insert_final_newline = true -charset = utf-8 -indent_style = space - -[*.py] -indent_size = 4 - - -[*.svg] -indent_size = 2 \ No newline at end of file diff --git a/wireviz/.gitignore b/wireviz/.gitignore deleted file mode 100644 index dfeb86fe5..000000000 --- a/wireviz/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -venv-*/ -*.pyc diff --git a/wireviz/Dockerfile b/wireviz/Dockerfile deleted file mode 100644 index 9d60c07d1..000000000 --- a/wireviz/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -FROM python:3.11.4-alpine3.18 - -RUN addgroup -g 1000 kroki && adduser -D -G kroki -u 1000 kroki - -# add runtime dependency -RUN apk --update --no-cache add graphviz ttf-liberation && fc-cache -f - -# ENV LIBRARY_PATH=/lib:/usr/lib - -WORKDIR /usr/local/kroki - -COPY --chown=kroki:kroki requirements.txt . - -# build -RUN apk --update --no-cache add --virtual build-dependencies build-base python3-dev \ - && pip install --no-cache-dir -r requirements.txt \ - && apk del build-dependencies - -COPY --chown=kroki:kroki src . - -EXPOSE 8006 - -USER kroki - -CMD ["gunicorn", "--preload", "--bind", "0.0.0.0:8006", "wsgi"] diff --git a/wireviz/Makefile b/wireviz/Makefile deleted file mode 100644 index 62bcccd67..000000000 --- a/wireviz/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -.PHONY: test showExamples - -default: test - -install: requirements.txt - python -m pip install -r requirements.txt - -test: - python -m unittest test/test_wireviz.py - -showExamples: - $(PYTHON) wireviz/examples.py diff --git a/wireviz/README.adoc b/wireviz/README.adoc deleted file mode 100644 index 5a24a3c83..000000000 --- a/wireviz/README.adoc +++ /dev/null @@ -1,35 +0,0 @@ -= WireViz -:uri-py-venv: https://docs.python.org/3/library/venv.html -:uri-py-releases: https://www.python.org/downloads/releases - -Kroki companion server for WireViz diagrams. - -[NOTE] -==== -The server accepts `POST` requests with the diagram sent as plain text. -It should only be used behind the Kroki gateway. -==== - -== Package - -To get you started quickly, you can build a Docker image: - - $ sudo make package - -Then you can run the server using the following command: - - $ sudo docker run --publish=8006:8006 yuzutech/kroki-wireviz:latest - -NOTE: We are using the `--publish` option to expose the container's port 8006 on the host's port 8006. - -The server should be running and available at: http://localhost:8006/ - -== Local development - -You will need to install {uri-py-releases}[Python 3.8+] on your machine. -We recommend {uri-py-venv}[creating a virtual environment] to install all the dependencies: - - $ python3.8 -m venv venv-py38 - - $ venv-py38/bin/pip install -r requirements.txt - $ venv-py38/bin/python src/server.py diff --git a/wireviz/examples.py b/wireviz/examples.py deleted file mode 100644 index cde55764b..000000000 --- a/wireviz/examples.py +++ /dev/null @@ -1,52 +0,0 @@ -# coding: utf-8 -import base64 -import zlib - - -def encode(source): - return base64.urlsafe_b64encode(zlib.compress(source.encode('utf-8'), 9)).decode('utf-8') - - -def section(title): - print('') - print('') - print('== ' + title) - - -def sample(service, source): - print('\n```' + source + '```') - print('/' + service + '/svg/' + encode(source)) - - -print('= Examples') - -section('WireViz') -cable = """ -connectors: - X1: - type: D-Sub - subtype: female - pinlabels: [DCD, RX, TX, DTR, GND, DSR, RTS, CTS, RI] - X2: - type: Molex KK 254 - subtype: female - pinlabels: [GND, RX, TX] - -cables: - W1: - gauge: 0.25 mm2 - length: 0.2 - color_code: DIN - wirecount: 3 - shield: true - -connections: - - - - X1: [5,2,3] - - W1: [1,2,3] - - X2: [1,3,2] - - - - X1: 5 - - W1: s -""" -sample('wireviz', cable) diff --git a/wireviz/requirements.txt b/wireviz/requirements.txt deleted file mode 100644 index bf1a7b4dc..000000000 --- a/wireviz/requirements.txt +++ /dev/null @@ -1,11 +0,0 @@ -click==8.1.7 -Flask==2.3.2 -gunicorn==20.1.0 -itsdangerous==2.1.2 -Werkzeug==2.3.7 -wireviz==0.3.2 -graphviz==0.20.1 -Jinja2==3.1.2 -MarkupSafe==2.1.3 -Pillow==9.5.0 -PyYAML==6.0.1 diff --git a/wireviz/src/backend/__init__.py b/wireviz/src/backend/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/wireviz/src/backend/error.py b/wireviz/src/backend/error.py deleted file mode 100644 index 28ad7c78e..000000000 --- a/wireviz/src/backend/error.py +++ /dev/null @@ -1,14 +0,0 @@ -class GenerateError(Exception): - status_code = 400 - - def __init__(self, message, status_code=None, payload=None): - Exception.__init__(self) - self.message = message - if status_code is not None: - self.status_code = status_code - self.payload = payload - - def to_dict(self): - rv = dict(self.payload or ()) - rv['message'] = self.message - return rv diff --git a/wireviz/src/server.py b/wireviz/src/server.py deleted file mode 100644 index aec8fc9ed..000000000 --- a/wireviz/src/server.py +++ /dev/null @@ -1,108 +0,0 @@ -import io -from flask import Flask, send_file, make_response, jsonify -from wireviz.wireviz import parse -from backend.error import GenerateError -from flask import request -from wireviz import __version__ as wireviz_version -from werkzeug.exceptions import default_exceptions -from werkzeug.exceptions import HTTPException - - -def make_json_app(import_name, **kwargs): - """ - Creates a JSON-oriented Flask app. - All error responses that you don't specifically - manage yourself will have application/json content - type, and will contain JSON like this (just an example): - { "message": "405: Method Not Allowed" } - """ - def make_json_error(ex): - response = jsonify({"error": str(ex.description)}) - response.status_code = (ex.code - if isinstance(ex, HTTPException) - else 500) - return response - - app = Flask(import_name, **kwargs) - - for code in iter(default_exceptions.keys()): - app.errorhandler(code)(make_json_error) - - return app - - -application = make_json_app(__name__) - - -class InvalidUsage(Exception): - status_code = 400 - - def __init__(self, error, status_code=None, payload=None): - Exception.__init__(self) - self.error = error - if status_code is not None: - self.status_code = status_code - self.payload = payload - - def to_dict(self): - rv = dict(self.payload or ()) - rv['error'] = self.error - return rv - - -@application.route('/_status', methods=['GET']) -def status(): - return jsonify( - name='wireviz', - version={ - 'wireviz': wireviz_version - } - ) - -@application.route('/wireviz/', methods=['POST']) -def wireviz(output_format, source=None): - types = {"svg": "image/svg+xml", "png": "image/png"} - if output_format in types: - config = source or request.get_data(cache=False, as_text=True, parse_form_data=False) - try: - graph = parse(yaml_input=config, return_types=output_format) - return make_response(graph) - except Exception as err: - raise GenerateError('Unable to generate the wireviz diagram from source', - status_code=400, - payload={ - 'source': source, - 'output_format': output_format, - 'diagram_type': 'wireviz', - 'error': str(err) - }) - else: - raise InvalidUsage('Unsupported output format: %s. Must be one of: png or svg.' % output_format, - status_code=400) - -@application.route('/', methods=['POST']) -def diag(output_format): - source = request.get_data(as_text=True) - if source.startswith('wireviz'): - return wireviz(output_format, source) - else: - raise InvalidUsage('Diagram source must begin with the following: wireviz', - status_code=400) - - -@application.errorhandler(GenerateError) -def handle_generate_error(error): - response = jsonify(error.to_dict()) - response.status_code = error.status_code - return response - - -@application.errorhandler(InvalidUsage) -def handle_invalid_usage(error): - response = jsonify(error.to_dict()) - response.status_code = error.status_code - return response - - -if __name__ == '__main__': - application.run(debug=True, host='0.0.0.0', port=8006) diff --git a/wireviz/src/wsgi.py b/wireviz/src/wsgi.py deleted file mode 100644 index b5d6763bc..000000000 --- a/wireviz/src/wsgi.py +++ /dev/null @@ -1,5 +0,0 @@ -from server import application - -if __name__ == "__main__": - application.run() - diff --git a/wireviz/test/__init__.py b/wireviz/test/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/wireviz/test/fixtures/wireviz_expected.svg b/wireviz/test/fixtures/wireviz_expected.svg deleted file mode 100644 index 2319619b6..000000000 --- a/wireviz/test/fixtures/wireviz_expected.svg +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - - - - -X1 - - -X1 - -D-Sub - -female - -9-pin - -DCD - -1 - -RX - -2 - -TX - -3 - -DTR - -4 - -GND - -5 - -DSR - -6 - -RTS - -7 - -CTS - -8 - -RI - -9 - - - -W1 - - -W1 - -3x - -0.25 mm² - -+ S - -0.2 m -  -X1:5:GND -     1:WH     -X2:1:GND - - - -X1:2:RX -     2:BN     -X2:3:TX - - - -X1:3:TX -     3:GN     -X2:2:RX - - - -  -X1:5:GND -Shield - -  - - - -X1:e--W1:w - - - - - - -X1:e--W1:w - - - - - - -X1:e--W1:w - - - - - - -X1:e--W1:w - - - - -X2 - - -X2 - -Molex KK 254 - -female - -3-pin - -1 - -GND - -2 - -RX - -3 - -TX - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - diff --git a/wireviz/test/fixtures/wireviz_source.txt b/wireviz/test/fixtures/wireviz_source.txt deleted file mode 100644 index 56c77c11b..000000000 --- a/wireviz/test/fixtures/wireviz_source.txt +++ /dev/null @@ -1,26 +0,0 @@ -connectors: - X1: - type: D-Sub - subtype: female - pinlabels: [DCD, RX, TX, DTR, GND, DSR, RTS, CTS, RI] - X2: - type: Molex KK 254 - subtype: female - pinlabels: [GND, RX, TX] - -cables: - W1: - gauge: 0.25 mm2 - length: 0.2 - color_code: DIN - wirecount: 3 - shield: true - -connections: - - - - X1: [5,2,3] - - W1: [1,2,3] - - X2: [1,3,2] - - - - X1: 5 - - W1: s diff --git a/wireviz/test/test_wireviz.py b/wireviz/test/test_wireviz.py deleted file mode 100644 index 0d1983b7d..000000000 --- a/wireviz/test/test_wireviz.py +++ /dev/null @@ -1,31 +0,0 @@ -import unittest -import sys - -from werkzeug.datastructures import MultiDict - -sys.path.append('src') -from server import InvalidUsage -from server import - -class TestDiag(unittest.TestCase): - - def _generate(self, filename, options=None): - if options is None: - options = MultiDict() - with open('test/fixtures/' + filename + '_source.txt', 'r') as file: - source = file.read() - with open('test/fixtures/' + filename + '_expected.svg', 'r') as file: - lines = file.readlines() - expected = '\n'.join([item.strip() for item in lines]) - - result = parse(yaml_input=source, return_types='svg') - actual = '\n'.join([item.strip() for item in result.split('\n')]) - return actual, expected - - def test_wireviz(self): - actual, expected = self._generate('wireviz') - self.maxDiff = None - self.assertEqual(actual, expected) - -if __name__ == '__main__': - unittest.main()