Skip to content

Commit

Permalink
tests fixed a lil bit
Browse files Browse the repository at this point in the history
  • Loading branch information
JaeAeich committed May 12, 2024
1 parent 743f073 commit 988009b
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 21 deletions.
File renamed without changes.
13 changes: 9 additions & 4 deletions tesk/service/filer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@
from glob import glob

import requests
from service.exception import FileProtocolDisabled, ServiceStatusCodes, UnknownProtocol
from service.filer_s3 import S3Transput
from service.path import containerPath, fileEnabled, getPath
from service.transput import Transput, Type, urlparse

from tesk.service.exceptions import (
FileProtocolDisabled,
ServiceStatusCodes,
UnknownProtocol,
)
from tesk.service.filer_s3 import S3Transput
from tesk.service.path import containerPath, fileEnabled, getPath
from tesk.service.transput import Transput, Type, urlparse


class HTTPTransput(Transput):
Expand Down
4 changes: 2 additions & 2 deletions tesk/service/filer_class.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json

from service import path
from service.path import fileEnabled
from tesk.service import path
from tesk.service.path import fileEnabled


class Filer:
Expand Down
3 changes: 2 additions & 1 deletion tesk/service/filer_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

import boto3
import botocore
from service.transput import Transput, Type

from tesk.service.transput import Transput, Type


class S3Transput(Transput):
Expand Down
7 changes: 4 additions & 3 deletions tesk/service/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

from kubernetes import client
from kubernetes.client.rest import ApiException
from service.exceptions import STATUS_CODE
from service.Util import pprint

from tesk.service.exceptions import ServiceStatusCodes
from tesk.service.Util import pprint

logging.basicConfig(format='%(message)s', level=logging.INFO)

Expand All @@ -28,7 +29,7 @@ def run_to_completion(self, poll_interval, check_cancelled, pod_timeout):
try:
self.bv1.create_namespaced_job(self.namespace, self.body)
except ApiException as ex:
if ex.status == STATUS_CODE['conflict']:
if ex.status == ServiceStatusCodes.CONFLICT:
logging.debug(f'Reading existing job: {self.name} ')
self.bv1.read_namespaced_job(self.name, self.namespace)
else:
Expand Down
2 changes: 1 addition & 1 deletion tesk/service/path.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from os.path import relpath

from service.exception import InvalidHostPath
from tesk.service.exceptions import InvalidHostPath

try:
from urllib.parse import urlparse
Expand Down
7 changes: 4 additions & 3 deletions tesk/service/pvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

from kubernetes import client
from kubernetes.client.rest import ApiException
from service.exceptions import STATUS_CODE
from service.Util import pprint

from tesk.service.exceptions import ServiceStatusCodes
from tesk.service.Util import pprint


class PVC:
Expand Down Expand Up @@ -47,7 +48,7 @@ def create(self):
self.namespace, self.spec
)
except ApiException as ex:
if ex.status == STATUS_CODE['Conflict']:
if ex.status == ServiceStatusCodes.CONFLICT:
logging.debug(f'Reading existing PVC: {self.name}')
return self.cv1.read_namespaced_persistent_volume_claim(
self.name, self.namespace
Expand Down
7 changes: 4 additions & 3 deletions tesk/service/taskmaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
import sys

from kubernetes import config
from service.filer_class import Filer
from service.job import Job
from service.pvc import PVC

from tesk.service.filer_class import Filer
from tesk.service.job import Job
from tesk.service.pvc import PVC

created_jobs = []
poll_interval = 5
Expand Down
4 changes: 2 additions & 2 deletions tests/test_unit/service/test_filer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
from io import StringIO
from unittest.mock import patch

from assertThrows import AssertThrowsMixin
from fs.opener import open_fs

from tesk.service.exception import (
from tesk.service.exceptions import (
FileProtocolDisabled,
InvalidHostPath,
UnknownProtocol,
Expand All @@ -26,6 +25,7 @@
)
from tesk.service.filer_s3 import S3Transput
from tesk.service.path import containerPath
from tests.test_unit.service.assertThrows import AssertThrowsMixin


def getTree(rootDir):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_unit/service/test_s3_filer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import pytest

# from service.extract_endpoint import extract_endpoint
from moto import mock_s3
from moto import mock_aws

from tesk.service.filer_s3 import S3Transput


@pytest.fixture()
def moto_boto():
with mock_s3():
with mock_aws():
boto3.client('s3', endpoint_url='http://s3.amazonaws.com')

client = boto3.resource('s3', endpoint_url='http://s3.amazonaws.com')
Expand Down

0 comments on commit 988009b

Please sign in to comment.