-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from workenvoy/0.0.7
0.0.7
- Loading branch information
Showing
11 changed files
with
171 additions
and
33 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,4 @@ | ||
from firestore.db.connection import Connection | ||
|
||
|
||
__all__ = ["Connection"] |
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 |
---|---|---|
@@ -1,30 +1,71 @@ | ||
from unittest import TestCase | ||
from pytest import mark | ||
|
||
from firestore import Document, Integer, Map, String | ||
from firestore.datatypes.map import MapSchema | ||
|
||
from firestore.errors import ValidationError | ||
|
||
|
||
class Mapping(MapSchema): | ||
name = String(required=True) | ||
name = String(required=True, default="Tiza") | ||
age = Integer(minimum=4) | ||
|
||
class AltMapping(MapSchema): | ||
name = String(required=True) | ||
|
||
class MapDocument(Document): | ||
map = Map(required=True) | ||
map = Map() | ||
|
||
class MapDocumentMapping(Document): | ||
map = Map(Mapping) | ||
|
||
|
||
class MapTest(TestCase): | ||
def setUp(self): | ||
self.md = MapDocument() | ||
self.mdm = MapDocumentMapping() | ||
|
||
def tearDown(self): | ||
pass | ||
|
||
def test_map_schema(self): | ||
def test_map_schema_validation(self): | ||
"""Tests that the map schema object correctly transforms | ||
to a python dict in the document instance and vis a vis""" | ||
pass | ||
with self.assertRaises(ValidationError): | ||
self.mdm.map = {"name": "Peter", "age": 2} | ||
|
||
def test_map_schema_value_error(self): | ||
with self.assertRaises(ValueError): | ||
self.mdm.map = {"name": "Peter", "age": "two"} | ||
|
||
def test_document_presave_with_map(self): | ||
mapping = Mapping() | ||
self.mdm.map = mapping | ||
self.assertEqual(self.mdm.map.name, "Tiza") | ||
|
||
def test_mapschema_assignment_validation(self): | ||
""" | ||
Test that validations in mapschema are invoked if | ||
a MapSchema object is used for assignment as opposed | ||
to a dict loaded into a mapschema | ||
""" | ||
mapping = AltMapping() | ||
with self.assertRaises(ValidationError): | ||
self.mdm.map = mapping | ||
|
||
def test_map_schema_assignment(self): | ||
mapping = Mapping() | ||
mapping.name = "Tiza" | ||
self.mdm.map = mapping | ||
self.assertEqual(self.mdm.map.name, "Tiza") | ||
|
||
def test_map_in_document_instance(self): | ||
"""Test when we create a map it get's loaded into the parent doc instance""" | ||
self.md.map = {} | ||
_map = {"name": "peter", "age": 5} | ||
self.md.map = _map | ||
|
||
# this is not testing self.md_data but testing that the map | ||
# descriptor field has pushed it's value to the | ||
# documents _data cache | ||
self.assertEqual(self.md._data.get('map'), _map) |
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
Empty file.
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,15 @@ | ||
from unittest import TestCase | ||
|
||
from firestore import Connection | ||
|
||
|
||
class TestConnection(TestCase): | ||
|
||
def setUp(self): | ||
pass | ||
|
||
def tearDown(self): | ||
pass | ||
|
||
def test_firebase_connection(self): | ||
pass |