-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated DATE/DATETIME to also handle datetime inputs and strip away t…
…z info, added mission tests
- Loading branch information
Showing
6 changed files
with
82 additions
and
3 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,65 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Tests for OData relational module | ||
TODO: tests heavily access protected members of the library -> improve? how? | ||
authors: Julian Minder | ||
""" | ||
|
||
import pytest | ||
|
||
from rel2graph.common_modules import util | ||
from rel2graph import Attribute | ||
from datetime import datetime | ||
|
||
@pytest.fixture | ||
def default_format(): | ||
return Attribute("key", "2015-05-17T21:18:19") | ||
|
||
@pytest.fixture | ||
def other_format(): | ||
return Attribute("key", "2015/05/17 21h 18min 19s") | ||
|
||
@pytest.fixture | ||
def as_datetime(): | ||
return Attribute("key", datetime.strptime("2015-05-17T21:18:19", "%Y-%m-%dT%H:%M:%S")) | ||
|
||
def test_date(default_format, other_format, as_datetime): | ||
result = util.DATE(default_format).value | ||
assert(result.year == 2015) | ||
assert(result.month == 5) | ||
assert(result.day == 17) | ||
result = util.DATE(other_format, "%Y/%m/%d %Hh %Mmin %Ss").value | ||
assert(result.year == 2015) | ||
assert(result.month == 5) | ||
assert(result.day == 17) | ||
result = util.DATE(as_datetime).value | ||
assert(result.year == 2015) | ||
assert(result.month == 5) | ||
assert(result.day == 17) | ||
|
||
def test_datetime(default_format, other_format, as_datetime): | ||
result = util.DATETIME(default_format).value | ||
assert(result.year == 2015) | ||
assert(result.month == 5) | ||
assert(result.day == 17) | ||
assert(result.hour == 21) | ||
assert(result.minute == 18) | ||
assert(result.second == 19) | ||
result = util.DATETIME(other_format, "%Y/%m/%d %Hh %Mmin %Ss").value | ||
assert(result.year == 2015) | ||
assert(result.month == 5) | ||
assert(result.day == 17) | ||
assert(result.hour == 21) | ||
assert(result.minute == 18) | ||
assert(result.second == 19) | ||
result = util.DATETIME(as_datetime).value | ||
assert(result.year == 2015) | ||
assert(result.month == 5) | ||
assert(result.day == 17) | ||
assert(result.hour == 21) | ||
assert(result.minute == 18) | ||
assert(result.second == 19) |
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,8 @@ | ||
ENTITY("entity"): | ||
NODE("node") test: | ||
- mystr = "1" #str | ||
- myfloat = 1.1 #float | ||
- myint = 1 #int | ||
- myTrue = True # bool | ||
- myFalse = False # bool | ||
RELATION(test, "to", MATCH("node", mystr = "1", myint = 1, myfloat = 1.1, myTrue = True, myFalse = False)): |
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 @@ | ||
ENTITY("TEST") |
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 @@ | ||
ENTITY("TEST") |