-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Digant C Kasundra
committed
May 14, 2015
1 parent
0f2aa65
commit 223423e
Showing
4 changed files
with
135 additions
and
12 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,54 @@ | ||
import pytest | ||
from sqlalchemy.exc import IntegrityError | ||
|
||
from hermes import exc | ||
from hermes import models | ||
|
||
from .fixtures import db_engine, session, sample_data1 | ||
|
||
|
||
def test_creation(sample_data1): | ||
event_types = sample_data1.query(models.EventType).all() | ||
assert len(event_types) == 6 | ||
event_type1 = event_types[0] | ||
|
||
hosts = sample_data1.query(models.Host).all() | ||
assert len(hosts) == 3 | ||
host = hosts[0] | ||
|
||
models.Event.create( | ||
sample_data1, host, "testman", event_type1, note="This is a test event" | ||
) | ||
sample_data1.commit() | ||
|
||
events = sample_data1.query(models.Event).all() | ||
|
||
# the total number of events should be 3 now. We care about the new one | ||
assert len(events) == 3 | ||
event = events[2] | ||
assert event.id == 3 | ||
assert event.host == host | ||
assert event.user == "testman" | ||
assert event.event_type == event_type1 | ||
assert event.note == "This is a test event" | ||
|
||
|
||
def test_duplicate(sample_data1): | ||
event_types = sample_data1.query(models.EventType).all() | ||
assert len(event_types) == 6 | ||
event_type1 = event_types[0] | ||
|
||
hosts = sample_data1.query(models.Host).all() | ||
assert len(hosts) == 3 | ||
host = hosts[0] | ||
|
||
models.Event.create( | ||
sample_data1, host, "testman", event_type1, note="This is a test event" | ||
) | ||
sample_data1.commit() | ||
|
||
models.Event.create( | ||
sample_data1, host, "testman", event_type1, note="This is another test event" | ||
) | ||
sample_data1.commit() | ||
|
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