-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set agent name in constructor (#322)
* allow naming in agent constructor * allow naming in agent constructor * formatting * moved to decorators * doc kwarg update * remove empty file
- Loading branch information
1 parent
6dd5a01
commit 60ae045
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from unittest import TestCase | ||
from unittest.mock import patch, MagicMock | ||
from uuid import uuid4 | ||
|
||
from agentops import track_agent | ||
import agentops | ||
|
||
|
||
class TrackAgentTests(TestCase): | ||
def test_track_agent_with_class(self): | ||
agentops.init() | ||
|
||
@track_agent(name="agent_name") | ||
class TestAgentClass: | ||
t = "a" | ||
pass | ||
|
||
obj = TestAgentClass() | ||
self.assertTrue(isinstance(obj, TestAgentClass)) | ||
self.assertEqual(getattr(obj, "agent_ops_agent_name"), "agent_name") | ||
self.assertIsNotNone(getattr(obj, "agent_ops_agent_id")) | ||
|
||
def test_track_agent_with_class_name(self): | ||
agentops.init() | ||
|
||
@track_agent(name="agent_name") | ||
class TestAgentClass: | ||
t = "a" | ||
pass | ||
|
||
obj = TestAgentClass(agentops_name="agent1") | ||
self.assertTrue(isinstance(obj, TestAgentClass)) | ||
self.assertEqual(getattr(obj, "agent_ops_agent_name"), "agent1") | ||
self.assertIsNotNone(getattr(obj, "agent_ops_agent_id")) |