This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from docker.models.volumes import Volume | |
from docker_manager import DockerManager | |
if __name__ == "__main__": | |
VOLUME_NAME = "TestVolume" | |
docker_manager = DockerManager() | |
print("Creating volume...") | |
docker_manager.create_volume(VOLUME_NAME) | |
print("List all volumes...") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_volume(self, name, driver="local", driver_opts=None, labels=None): | |
""" | |
Create a volume | |
:param name: The name of the volume | |
:param driver: The type of driver to use | |
:param driver_opts: Additional options | |
:param labels: Labels for the volume | |
:return: The created Volume | |
""" | |
if driver_opts is None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.overliambitious.vaadin.frontend; | |
import com.vaadin.flow.component.button.Button; | |
import com.vaadin.flow.component.html.Label; | |
import com.vaadin.flow.component.notification.Notification; | |
import com.vaadin.flow.component.orderedlayout.VerticalLayout; | |
import com.vaadin.flow.router.Route; | |
import javax.annotation.PostConstruct; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from typing import List | |
import docker | |
from docker.errors import NotFound | |
from docker.models.containers import Container | |
class DockerManager: | |
def __init__(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import docker | |
def run_container(): | |
client = docker.client.from_env() | |
client.containers.run("busybox:latest", "echo Hello World!", name="tutorial1") | |
if __name__ == "__main__": | |
run_container() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def function_one(): | |
print "One" | |
def function_two(): | |
print "Two" | |
def function_three(): | |
print "Three" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.liamdjolly; | |
public class MyException extends Exception { | |
public MyException() { | |
} | |
public MyException(String message) { | |
super(message); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import exception_example | |
import unittest | |
import mock | |
class ExceptionExampleTest(unittest.TestCase): | |
def test_does_user_exist(self): | |
self.assertTrue(exception_example.does_user_exist("user1")) | |
def test_does_user_exist_no_user(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_user(username): | |
if username == "user1": | |
return dict(name="user1", id_no="12345") | |
else: | |
raise Exception | |
def does_user_exist(username): | |
try: | |
find_user(username) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
import mock | |
import file_utils | |
class FileUtilsTest(unittest.TestCase): | |
def test_read_file(self): | |
with mock.patch("__builtin__.open", mock.mock_open(read_data="MOCKED"), create=True) as mock_file: | |
result = file_utils.read_file("path") |
NewerOlder