def test_service_name_and_story_line(patch, story): patch.object(hashlib, 'sha1') story.name = 'story_name' ret = Containers.hash_service_name_and_story_line(story, {'ln': '1'}, 'alpine') hashlib.sha1.assert_called_with(f'alpine-{story.name}-1'.encode('utf-8')) assert ret == hashlib.sha1().hexdigest()
def test_get_container_name(patch, story, line, reusable): patch.object(Containers, 'is_service_reusable', return_value=reusable) story.app.app_id = 'my_app' ret = Containers.get_container_name(story, line, 'alpine') if reusable: assert ret == f'alpine-{Containers.hash_service_name("alpine")}' else: h = Containers.hash_service_name_and_story_line(story, line, 'alpine') assert ret == f'alpine-{h}'