def test_clone_repo(self): builder = Builder(Manifest('info.yaml')) builder.clone_repo( 'https://github.com/antonkurenkov/systembuilder.git') # waiting while cloning sleep(5) assert os.path.isfile('./repo/README.md')
def test_create_dockerfile(self): builder = Builder(Manifest('info.yaml')) builder.create_dockerfile() assert os.path.isfile('Dockerfile') with open('Dockerfile', 'r') as dockerfile: fst_line = dockerfile.readline() assert fst_line == 'FROM python:latest\n' os.remove('info.yaml') os.remove('Dockerfile')
def test_generate_status_file_without_error(): builder = Builder(Manifest()) builder.generate_status_file(True) assert os.path.isfile('status.json') with open('status.json') as status_file: status = json.load(status_file) assert status['status'] assert status['message'] == "" os.remove('status.json')
def test_generate_status_file_with_error(self): builder = Builder(Manifest('info.yaml')) project_status = builder.generate_status(False, "error") builder.generate_status_file(1.0, {"project": project_status}) assert os.path.isfile('status.json') with open('status.json') as status_file: status = json.load(status_file) assert not status['status']['project']['status'] assert status['status']['project']['message'] == 'error' os.remove('status.json')
def test_generate_status_file_without_error(self): builder = Builder(Manifest('info.yaml')) project_status = builder.generate_status(True) builder.generate_status_file(1.0, {"project": project_status}) assert os.path.isfile('status.json') with open('status.json') as status_file: status = json.load(status_file) assert status['status']['project']['status'] assert status['status']['project']['message'] == "" assert status['version'] == 1.0 os.remove('status.json')
def test_create_dockerfile(): builder = Builder(Manifest()) data = {'docker': {'dockerfile': 'FROM python:latest\nENTRYPOINT ["python"]', 'parameters': ['some parameter']}} with open('info.yaml', 'w') as file: yaml.dump(data, file) builder.create_dockerfile('info.yaml') assert os.path.isfile('DOCKERFILE') with open('DOCKERFILE', 'r') as dockerfile: fst_line = dockerfile.readline() assert fst_line == 'FROM python:latest\n' os.remove('info.yaml') os.remove('DOCKERFILE')
from src.main.builder import Builder from src.main.manifest import Manifest builder = Builder(Manifest()) try: builder.get_build() message = "" status = True except Exception as e: message = str(e) status = False builder.generate_status_file(status, message)