Skip to content

Commit

Permalink
test: add test to tutor install version command
Browse files Browse the repository at this point in the history
  • Loading branch information
Alec4r committed Aug 10, 2022
1 parent e6c09d9 commit db1d198
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
Empty file.
Empty file.
31 changes: 31 additions & 0 deletions tests/version_manager/application/test_tutor_version_installer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import pytest

from tests.version_manager.infrastructure.version_manager_in_memory_repository import VersionManagerInMemoryRepository
from tvm.version_manager.application.tutor_version_installer import TutorVersionInstaller
from tvm.version_manager.domain.tutor_version_format_error import TutorVersionFormatError


def test_should_fail_if_version_format_is_not_valid():
# Given
version = "v123"
repository = VersionManagerInMemoryRepository()

# When
installer = TutorVersionInstaller(repository=repository)

# Then
with pytest.raises(TutorVersionFormatError) as format_err:
installer(version=version)


def test_should_install_the_tutor_version():
# Given
version = "v1.2.3"
repository = VersionManagerInMemoryRepository()

# When
installer = TutorVersionInstaller(repository=repository)
installer(version=version)

# Then
assert version in repository.VERSIONS_INSTALLED
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from typing import List, Optional

from tvm.version_manager.domain.tutor_version import TutorVersion
from tvm.version_manager.domain.version_manager_repository import VersionManagerRepository


class VersionManagerInMemoryRepository(VersionManagerRepository):
VERSIONS_INSTALLED = []

def list_versions(self, limit: int) -> List[TutorVersion]:
pass

@staticmethod
def local_versions(tvm_path: str) -> List[TutorVersion]:
pass

@staticmethod
def current_version(tvm_path: str) -> List[TutorVersion]:
pass

def install_version(self, version: TutorVersion) -> None:
self.VERSIONS_INSTALLED.append(version)

def find_version(self, version: TutorVersion) -> Optional[TutorVersion]:
return version if version in self.VERSIONS_INSTALLED else None

def uninstall_version(self, version: TutorVersion) -> None:
pass

def use_version(self, version: TutorVersion) -> None:
pass

@staticmethod
def version_is_installed(version: str) -> None:
pass

def install_plugin(self, options: List) -> None:
pass

def uninstall_plugin(self, options: List) -> None:
pass

0 comments on commit db1d198

Please sign in to comment.