-
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 8, 2015
1 parent
050256a
commit 2b71f1c
Showing
8 changed files
with
113 additions
and
11 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
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,39 @@ | ||
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(session, sample_data1): | ||
event_types = session.query(models.EventType).all() | ||
assert len(event_types) == 4 | ||
|
||
event_type1 = event_types[2] | ||
event_type2 = event_types[3] | ||
|
||
models.Fate.create(session, event_type1, event_type2, "New fate") | ||
session.commit() | ||
|
||
fates = session.query(models.Fate).all() | ||
|
||
# the total number of fates should be 2 now. We care about the new one | ||
assert len(fates) == 2 | ||
fate = fates[1] | ||
assert fate.id == 2 | ||
assert fate.creation_event_type == event_type1 | ||
assert fate.completion_event_type == event_type2 | ||
assert fate.description == "New fate" | ||
|
||
|
||
def test_duplicate(session, sample_data1): | ||
event_types = session.query(models.EventType).all() | ||
assert len(event_types) == 4 | ||
|
||
event_type1 = event_types[0] | ||
event_type2 = event_types[1] | ||
|
||
with pytest.raises(IntegrityError): | ||
models.Fate.create(session, event_type1, event_type2, "Dup fate") |
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,10 @@ | ||
INSERT INTO `event_types` (`id`, `category`, `state`, `description`) | ||
VALUES | ||
(1,'system-reboot','required','This system requires a reboot.'), | ||
(2,'system-reboot','completed','This system rebooted.'), | ||
(3,'system-maintenance','required','This system requires maintenance.'), | ||
(4,'system-maintenance','completed','System maintenance completed.'); | ||
|
||
INSERT INTO `fates` (`id`, `creation_type_id`, `completion_type_id`, `description`) | ||
VALUES | ||
(1,1,2,'A system that needs a reboot can be cleared by rebooting the machine.'); |