forked from tern-tools/tern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_fixtures.py
81 lines (65 loc) · 2.32 KB
/
test_fixtures.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# -*- coding: utf-8 -*-
#
# Copyright (c) 2019 VMware, Inc. All Rights Reserved.
# SPDX-License-Identifier: BSD-2-Clause
"""
Objects to use for testing
"""
from tern.classes.package import Package
from tern.classes.image_layer import ImageLayer
from tern.classes.image import Image
from tern.classes.template import Template
class TestImage(Image):
def __init__(self, id):
super().__init__(id)
def load_image(self):
l1 = ImageLayer('123abc', 'path/to/tar')
self.name = 'testimage'
self.tag = 'testtag'
l1.add_package(Package('p1'))
l1.add_package(Package('p2'))
self._layers.append(l1)
class TestTemplate1(Template):
'''Template with no origins mapping'''
def package(self):
return {'name': 'package.name',
'version': 'package.version',
'pkg_license': 'package.license'}
def image_layer(self):
return {'diff_id': 'layer.diff',
'tar_file': 'layer.tarfile',
'packages': 'layer.packages'}
def image(self):
return {'image_id': 'image.id',
'layers': 'image.layers'}
class TestTemplate2(Template):
'''Template with origins mapping'''
def package(self):
mapping = {'name': 'package.name',
'version': 'package.version',
'pkg_license': 'package.license',
'proj_url': 'package.url'}
# we update the mapping with another defined mapping
mapping.update(self.origins())
return mapping
def image_layer(self):
mapping = {'diff_id': 'layer.diff',
'tar_file': 'layer.tarfile',
'packages': 'layer.packages'}
# we update the mapping with another defined mapping
mapping.update(self.origins())
return mapping
def image(self):
mapping = {'image_id': 'image.id',
'layers': 'image.layers'}
# we update the mapping with another defined mapping
mapping.update(self.origins())
return mapping
def notice(self):
return {'level': 'note.level',
'message': 'note.message'}
def notice_origin(self):
return {'origin_str': 'note.source',
'notices': 'note.messages'}
def origins(self):
return {'origins': 'notes'}