Add a test for resolve_profiles.

This commit is contained in:
Ralph Bean
2016-11-21 13:50:55 -05:00
parent 439721da99
commit 2357691c03
4 changed files with 9076 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
# Copyright (c) 2016 Red Hat, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Written by Ralph Bean <rbean@redhat.com>
import os
import modulemd
from datetime import datetime
from module_build_service import app, db
from module_build_service.config import from_app_config
from module_build_service.models import ModuleBuild, BUILD_STATES
app.config.from_object('config.TestConfiguration')
conf = from_app_config()
datadir = os.path.dirname(__file__) + '/data/'
def module_build_from_modulemd(yaml):
mmd = modulemd.ModuleMetadata()
mmd.loads(yaml)
build = ModuleBuild()
build.name = mmd.name
build.stream = mmd.stream
build.version = mmd.version
build.state = BUILD_STATES['ready']
build.modulemd = yaml
build.koji_tag = None
build.batch = 0
build.owner = 'some_other_user'
build.time_submitted = datetime(2016, 9, 3, 12, 28, 33)
build.time_modified = datetime(2016, 9, 3, 12, 28, 40)
build.time_completed = None
return build
def init_data():
db.session.remove()
db.drop_all()
db.create_all()
for filename in os.listdir(datadir):
with open(datadir + filename, 'r') as f:
yaml = f.read()
build = module_build_from_modulemd(yaml)
db.session.add(build)
db.session.commit()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,39 @@
document: modulemd
version: 1
data:
name: testmodule
stream: master
version: 1
summary: A test module in all its beautiful beauty
description: This module demonstrates how to write simple modulemd files And can be used for testing the build and release pipeline.
license:
module: [ MIT ]
dependencies:
buildrequires:
base-runtime: master
requires:
base-runtime: master
references:
community: https://fedoraproject.org/wiki/Modularity
documentation: https://fedoraproject.org/wiki/Fedora_Packaging_Guidelines_for_Modules
tracker: https://taiga.fedorainfracloud.org/project/modularity
profiles:
default:
rpms:
- tangerine
api:
rpms:
- perl-Tangerine
- tangerine
components:
rpms:
perl-List-Compare:
rationale: A dependency of tangerine.
ref: f25
perl-Tangerine:
rationale: Provides API for this module and is a dependency of tangerine.
ref: f25
tangerine:
rationale: Provides API for this module.
buildorder: 10
ref: f25

View File

@@ -0,0 +1,49 @@
# Copyright (c) 2016 Red Hat, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Written by Ralph Bean <rbean@redhat.com>
from nose.tools import eq_
import unittest
from tests.test_models import init_data, db
from module_build_service import models
class TestModels(unittest.TestCase):
def setUp(self):
init_data()
def test_resolve_refs(self):
expected = set([
'shadow-utils',
'fedora-release',
'redhat-rpm-config',
'rpm-build',
'fedpkg-minimal',
'gnupg2',
'bash',
])
build = db.session.query(models.ModuleBuild).filter_by(name='testmodule').one()
result = build.resolve_profiles(db.session, 'srpm-buildroot')
eq_(result, expected)