Beispiel #1
0
    def test_single_aggregation_trees(self):
        aggregation_tree = {"org_chart": ["CEO", "Architect", "Developer"]}
        entity = Entity(geocode="1234", geoname="Accra", unique_name="Kajelo CHPS", aggregation_tree=aggregation_tree)
        entity.save()

        loaded_entity = query.get(uuid=entity.uuid)
        self.assertEqual(loaded_entity.aggregation_tree["org_chart"], ["CEO", "Architect", "Developer"])
Beispiel #2
0
    def test_if_reported_at_attribute_is_created(self):
        entity = Entity(geocode="1234", geoname="Accra", unique_name="Kajelo CHPS")
        entity.save()

        data_record = entity.submit_datarecord(
            record_dict={"name": "arv", "value": "40", "type": "int"}, reported_at=datetime.datetime.now()
        )
        data_record.save()
        self.assertEqual(data_record.reported_at.date(), datetime.datetime.now().date())
Beispiel #3
0
    def test_add_data_record_to_entity(self):
        entity = Entity(geocode="1234", geoname="Accra", unique_name="Kajelo CHPS")
        entity.save()

        data_record = entity.submit_datarecord(
            record_dict={"name": "arv", "value": "40", "type": "int"}, reported_at=datetime.datetime.now()
        )
        data_record.save()
        self.assertEqual(data_record.for_entity_uuid, entity.uuid)
Beispiel #4
0
    def test_entity_state(self):
        entity = Entity(geocode="9876", geoname="Gulu", unique_name="Ashianti")
        entity.save()

        data_record = entity.submit_datarecord(
            record_dict={"name": "arv", "value": "12", "type": "int"}, reported_at=datetime.date(2011, 03, 01)
        )
        data_record.save()
        data_record = entity.submit_datarecord(
            record_dict={"name": "arv", "value": "1", "type": "int"}, reported_at=datetime.date(2011, 03, 13)
        )
Beispiel #5
0
    def test_discover_data_types_of_the_datarecords(self):
        entity = Entity(geocode="1234", geoname="Gulu", unique_name="Ashianti CHPS")
        entity.save()

        data_record = entity.submit_datarecord(
            record_dict={"name": "arv", "value": "12", "type": "int"}, reported_at=datetime.date(2011, 03, 01)
        )
        data_record.save()
        data_record = entity.submit_datarecord(
            record_dict={"name": "patients", "value": "1", "type": "int"}, reported_at=datetime.date(2011, 03, 03)
        )
        data_record.save()

        data_types = entity.get_data_records_types()
        self.assertEqual(data_types, {"patients": "int", "arv": "int"})
from datastore.entity import Entity, EntityError
from datastore.index import Index

db = tornado.database.Connection(
    '127.0.0.1',
    'gitlytics',
    'root',
    ''
)
tornado.options.enable_pretty_logging()
tornado.options.parse_command_line()

#   Create a test entity
test_entity = Entity('test_entity', 'test_id', {
    'test':'1',
    'b':'2'
}, db)

#   Create an index on test_entity for property 'test' and 'b'
test_entity.add_index(Index(test_entity, 'test', db))
test_entity.add_index(Index(test_entity, 'b', db))

#   Create Entity and Associated Index Tables
test_entity.create_table()

#   Lets create an entity without providing any data.
try:
    test = test_entity.create({})
except EntityError, e:
    print e
else:
Beispiel #7
0
 def test_create_entity(self):
     entity = Entity(geocode="1234", geoname="Ghana", unique_name="Navio CHPS")
     entity.save()
     self.assertEqual(entity.geoname, "Ghana")
Beispiel #8
0
 def test_enity_has_created_at(self):
     entity = Entity(geocode="1234", geoname="Accra", unique_name="Kajelo CHPS")
     entity.save()
Beispiel #9
0
    def test_load_entity(self):
        entity = Entity(geocode="123466", geoname="Ghana", unique_name="Navio CHPS")
        entity.save()

        loaded_entity = query.get(uuid=entity.uuid)
        self.assertEqual(loaded_entity.uuid, entity.uuid)