Skip to content

Commit

Permalink
first unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jupe committed May 19, 2020
1 parent 11dd49f commit d0f94e5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pytest_opentmi/OpenTmiReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def _get_tcid(report):
return report.head_line.rstrip("[]")

def _parse_test(self, report):
tcid = self._get_tcid(report)
tcid = OpenTmiReport._get_tcid(report)
key = OpenTmiReport._get_test_key(report)
item = self._items[key]
doc = inspect.getdoc(item.obj)
Expand Down
37 changes: 37 additions & 0 deletions test/test_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from dataclasses import dataclass
import unittest
from pytest_opentmi.OpenTmiReport import OpenTmiReport


class MockPluginManager:
def hasplugin(self, plugin):
return False


@dataclass
class MockConfig:
pluginmanager: MockPluginManager = MockPluginManager()

def getoption(self, opt):
if opt == 'opentmi':
return 'https://localhost'
if opt == 'opentmi_store_logs':
return False
raise AssertionError('invalid opt')


class TestPlugin(unittest.TestCase):

def test_constructor(self):
report = OpenTmiReport(config=MockConfig())
self.assertIsInstance(report, OpenTmiReport)

def test_get_test_key(self):
report = OpenTmiReport(config=MockConfig())

class Item:
@property
def location(self):
return ['a', 2, 'b']
key = report._get_test_key(Item())
self.assertEqual(key, 'a_2_b')

0 comments on commit d0f94e5

Please sign in to comment.