1 # ============LICENSE_START====================================================
3 # =============================================================================
4 # Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
5 # Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
6 # =============================================================================
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 # ============LICENSE_END======================================================
20 from testing_helpers import get_json_fixture, get_fixture_path
21 from aoconversion import docker_gen, scanner
24 TEST_META = get_json_fixture("models/example-model/metadata.json")
27 def test_generate_dockerfile():
29 docker_gen._generate_dockerfile(TEST_META, "example-model", '', '', '')
33 ENV MODELNAME example-model
37 ADD ./example-model /app/example-model
38 ADD ./requirements.txt /app
45 RUN pip install -r /app/requirements.txt && \
46 pip install acumos_dcae_model_runner && \
52 ENTRYPOINT ["acumos_dcae_model_runner"]
53 CMD ["/app/example-model"]
58 def test_build_and_push_docker(monkeypatch):
59 model_repo_path = get_fixture_path('models')
60 config = scanner.Config(dcaeurl='http://dcaeurl', dcaeuser='dcaeuser', onboardingurl='https://onboarding', onboardinguser='obuser', onboardingpass='obpass', acumosurl='https://acumos', certfile=None, dockerregistry='dockerregistry', dockeruser='registryuser', dockerpass='registrypassword', http_proxy='', https_proxy='', no_proxy='', tmpdir=model_repo_path)
61 monkeypatch.setattr(docker_gen, 'APIClient', test_fed._mockdocker.APIClient)
62 assert(docker_gen.build_and_push_docker(config, 'example-model', model_version="latest") == 'dockerregistry/example-model:latest')