-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set end timestamp if not set before record (#179)
* send end timestamp if not set before record * tests * token cost print fix * test fix
- Loading branch information
1 parent
139488a
commit 2a0ee73
Showing
2 changed files
with
35 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import time | ||
import requests_mock | ||
import pytest | ||
import agentops | ||
from agentops import ActionEvent | ||
|
||
|
||
@pytest.fixture | ||
def mock_req(): | ||
with requests_mock.Mocker() as m: | ||
url = 'https://api.agentops.ai' | ||
m.post(url + '/events', text='ok') | ||
m.post(url + '/sessions', json={'status': 'success', 'token_cost': 5}) | ||
yield m | ||
|
||
class TestEvents: | ||
def setup_method(self): | ||
self.api_key = "random_api_key" | ||
self.event_type = 'test_event_type' | ||
self.config = agentops.Configuration(api_key=self.api_key, max_wait_time=50, max_queue_size=1) | ||
|
||
def test_record_timestamp(self, mock_req): | ||
agentops.init(api_key=self.api_key) | ||
|
||
event = ActionEvent() | ||
time.sleep(0.15) | ||
agentops.record(event) | ||
|
||
assert event.init_timestamp != event.end_timestamp |