def test_override_project(): file_config = FileConfiguration("project-name", "/project/remote/dir", None, []) argv = ["--project", "other-project"] server_id = uuid.uuid4() project = Project(uuid.uuid4(), "other-project", uuid.uuid4()) with _patched_config(file_config): with _patched_server(server_id): with _patched_project(project) as resolve_project_mock: cli.parse_command_line(argv=argv) resolve_project_mock.assert_called_once_with("other-project")
def test_specify_server_command_line(): file_config = FileConfiguration("project-name", "/project/remote/dir", None, []) argv = ["--server", "server-name"] server_id = uuid.uuid4() project = Project(uuid.uuid4(), "project-name", uuid.uuid4()) with _patched_config(file_config): with _patched_server(server_id) as resolve_server_mock: with _patched_project(project): cli.parse_command_line(argv=argv) resolve_server_mock.assert_called_once_with( project.id, "server-name")
def test_add_ignore(): file_config = FileConfiguration("project-name", "/project/remote/dir", None, ["ig1"]) argv = ["--ignore", "ig2", "ig3"] server_id = uuid.uuid4() project = Project(uuid.uuid4(), "project-name", uuid.uuid4()) with _patched_config(file_config): with _patched_server(server_id): with _patched_project(project): configuration = cli.parse_command_line(argv=argv) expected_ignore_patterns = cli.DEFAULT_IGNORE_PATTERNS + [ "ig1", "ig2", "ig3", ] assert configuration.ignore == expected_ignore_patterns
def test_no_configuration(): file_config = FileConfiguration(None, None, None, []) argv = ["--project", "project-name"] server_id = uuid.uuid4() project = Project(uuid.uuid4(), "project-name", uuid.uuid4()) with _patched_config(file_config): with _patched_server(server_id): with _patched_project(project) as resolve_project_mock: configuration = cli.parse_command_line(argv=argv) assert configuration == models.Configuration( project=project, server_id=server_id, local_dir="./", remote_dir=None, debug=False, ignore=cli.DEFAULT_IGNORE_PATTERNS, ) resolve_project_mock.assert_called_once_with("project-name")
import uuid import datetime from faculty.clients.project import Project from faculty.clients.server import ( DedicatedServerResources, ServerStatus, SharedServerResources, Server, Service, ) from faculty.config import Profile USER_ID = uuid.uuid4() PROJECT = Project(id=uuid.uuid4(), name="test-project", owner_id=USER_ID) PROFILE = Profile( domain="services.subdomain.my.faculty.ai", protocol="https", client_id=uuid.uuid4(), client_secret="29o9P0q3BZiUDMx4R38haZCOPbuy3p7fGARUBD0a", ) SERVER_CREATION_DATE = datetime.datetime(year=2020, month=1, day=1) SERVICE = Service( name="test-service", host="test-host", port=8000, scheme="test-scheme", uri="test-uri",
from datetime import datetime import pytest from marshmallow import ValidationError from pytz import UTC from faculty.clients.project import Project, ProjectClient, _ProjectSchema USER_ID = uuid.uuid4() ARCHIVED_AT = datetime(2018, 3, 10, 11, 32, 6, 247000, tzinfo=UTC) ARCHIVED_AT_STRING = "2018-03-10T11:32:06.247Z" PROJECT = Project( id=uuid.uuid4(), name="test-project", owner_id=uuid.uuid4(), archived_at=None, ) PROJECT_BODY = { "projectId": str(PROJECT.id), "name": PROJECT.name, "ownerId": str(PROJECT.owner_id), "archivedAt": None, } ARCHIVED_PROJECT = Project( id=uuid.uuid4(), name="archived-project", owner_id=uuid.uuid4(), archived_at=ARCHIVED_AT, )