def mutate_and_get_payload(cls, root, info, owner, labbook_name, client_mutation_id=None): username = get_logged_in_username() lb = InventoryManager().load_labbook(username, owner, labbook_name, author=get_logged_in_author()) # TODO - Should we cehck if a custom docker component already exists? with lb.lock(): cm = ComponentManager(lb) cm.remove_docker_snippet(cm.DEFAULT_CUSTOM_DOCKER_NAME) return RemoveCustomDocker( updated_environment=Environment(owner=owner, name=labbook_name))
def test_add_then_remove_custom_docker_snipper_with_valid_docker( self, mock_config_with_repo): lb = create_tmp_labbook(mock_config_with_repo[0]) snippet = [ "RUN true", "RUN touch /tmp/testfile", "RUN rm /tmp/testfile", "RUN echo 'done'" ] c1 = lb.git.commit_hash cm = ComponentManager(lb) cm.add_docker_snippet( "unittest-docker", docker_content=snippet, description= "yada yada's, \n\n **I'm putting in lots of apostrophę's**.") #print(open(os.path.join(lb.root_dir, '.gigantum', 'env', 'docker', 'unittest-docker.yaml')).read(10000)) c2 = lb.git.commit_hash assert c1 != c2 import yaml d = yaml.safe_load( open( os.path.join(lb.root_dir, '.gigantum', 'env', 'docker', 'unittest-docker.yaml'))) print(d) assert d[ 'description'] == "yada yada's, \n\n **I'm putting in lots of apostrophę's**." assert d['name'] == 'unittest-docker' assert all( [d['content'][i] == snippet[i] for i in range(len(snippet))]) with pytest.raises(ValueError): cm.remove_docker_snippet('nothing') c1 = lb.git.commit_hash cm.remove_docker_snippet('unittest-docker') c2 = lb.git.commit_hash assert not os.path.exists( os.path.join(lb.root_dir, '.gigantum', 'env', 'docker', 'unittest-docker.yaml')) assert c1 != c2