Skip to content

Commit

Permalink
Adapt tests for new structure
Browse files Browse the repository at this point in the history
- patch path for avoiding import errors (I hate this)
- fix imports to new structure
- update logging test
  • Loading branch information
eyalzek committed Sep 30, 2022
1 parent d7e41cc commit 3a64e0e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
7 changes: 7 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os
import sys
PROJECT_PATH = os.getcwd()
SOURCE_PATH = os.path.join(
PROJECT_PATH, 'src'
)
sys.path.append(SOURCE_PATH)
4 changes: 3 additions & 1 deletion tests/test_gkeworkload.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import unittest
from unittest.mock import MagicMock, patch
from analyzer.analyzer import GkeWorkload, Reporter, parse_args, init_logger
from gke import GkeWorkload
from analyzer import parse_args, init_logger
from reporter import Reporter


class GkeWorkloadTestCase(unittest.TestCase):
Expand Down
8 changes: 5 additions & 3 deletions tests/test_gsaproject.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import unittest
from unittest.mock import MagicMock, patch
from analyzer.analyzer import GsaProject, Reporter, parse_args, init_logger
from gsa import GsaProject
from analyzer import parse_args, init_logger
from reporter import Reporter


@patch('googleapiclient.discovery.build')
Expand Down Expand Up @@ -106,10 +108,10 @@ def test_list_gsa_project_roles(self, mock_build):
'members': ['serviceAccount:testMember']}
]
}
with self.assertLogs('analyzer') as cm:
with self.assertLogs() as cm:
gsaProject.list_gsa_project_roles()
self.assertEqual(cm.output, [
'INFO:analyzer:GSA: "testMember" has the following '
'INFO:root:GSA: "testMember" has the following '
'roles in project "test-project":'
'\nroles/viewer\nroles/editor'])

Expand Down

0 comments on commit 3a64e0e

Please sign in to comment.