Update test_labels.py

pull/500/head
James Bourbeau 2018-12-13 12:43:45 -06:00
rodzic 624ad94073
commit 99b1e7548a
2 zmienionych plików z 11 dodań i 17 usunięć

Wyświetl plik

@ -744,6 +744,8 @@ class Repo2Docker(Application):
else:
picked_buildpack = self.default_buildpack()
self._picked_buildpack = picked_buildpack
picked_buildpack.appendix = self.appendix
picked_buildpack.labels['repo2docker.version'] = self.version
picked_buildpack.labels['repo2docker.repo'] = self.repo

Wyświetl plik

@ -10,28 +10,20 @@ import pytest
@pytest.mark.parametrize('ref', ['some-branch', None])
def test_labels(ref, tmpdir):
app = Repo2Docker()
repo = str(tmpdir)
if ref is not None:
argv = ['--ref', ref, str(tmpdir)]
argv = ['--ref', ref, repo]
else:
argv = [str(tmpdir)]
argv = [repo]
app.initialize(argv)
app.debug = True
app.build = False
app.run = False
app.start() # This just build the image and does not run it.
container = app.start_container()
app.start()
labels = app._picked_buildpack.labels
expected_labels = {
'repo2docker.ref': str(ref),
'repo2docker.repo': str(tmpdir),
'repo2docker.ref': ref,
'repo2docker.repo': repo,
'repo2docker.version': __version__,
}
# wait a bit for the container to be ready
# give the container a chance to start
time.sleep(1)
try:
assert container.labels == expected_labels
finally:
# stop the container
container.stop()
app.wait_for_container(container)
assert labels == expected_labels