Exemple #1
0
class TestDbPolygons(unittest.TestCase):
    def setUp(self):
        self.db = RiakDb()
        self.db.create_user(U_EMAIL, U_NAME, U_PASS, U_ADDR)
        p = self.db.create_polygon("Nevada", "Area 51", U_EMAIL, date.today(),
                                   None, ['type1', 'typeB'])
        self.poly_id = p['id']

    def tearDown(self):
        self.db.delete_polygon(self.poly_id)
        self.db.delete_user(U_EMAIL)

    def test_get_own_polygon(self):
        poly = self.db.get_polygon(self.poly_id, U_EMAIL)
        self.assertEqual(poly['name'], "Area 51")
        self.assertEqual(poly['type'], ['type1', 'typeB'])

    def test_polygon_start_date_as_datetime(self):
        dt = self.db.get_polygon(self.poly_id, U_EMAIL)['start_date']
        self.assertEqual(dt, date.today())

    def test_get_other_polygon(self):
        self.assertIsNone(self.db.get_polygon(self.poly_id, "wrong_user"))

    def test_delete_polygon(self):
        self.db.delete_polygon(self.poly_id)
        self.assertIsNone(self.db.get_polygon(self.poly_id, U_EMAIL))
Exemple #2
0
        if parent in ptypes:
            ptypes[parent]["children"] += [name]
        else:
            print("Unseen parent:", parent)
        ptypes[name] = ptype

for ptype in ptypes.values():
    db.create_poly_type(ptype["name"], ptype["is_container"], ptype["harvest"],
                        ptype["children"])

user2 = db.create_user("*****@*****.**", "Test 2", "test2",
                       "2418 S 7th St West Missoula, MT")

poly21 = db.create_polygon(
    "{\"shape\":\"rectangle\",\"neBounds\":{\"lat\":46.8650112119313,\"lng\":-114.03847303235585},\"swBounds\":{\"lat\":46.864189627987635,\"lng\":-114.03875466430242}}",
    "Peas", user2["email"], "2018-04-01", "2018-07-01", [
        "Plant", "Garden Patch/Area (NOT raised beds)",
        "Vegetable & Fruit Garden", "Peas", "Field Peas"
    ])
poly22 = db.create_polygon(
    "{\"shape\":\"polygon\",\"path\":[{\"lat\":46.865022489339296,\"lng\":-114.03836775320389},{\"lat\":46.86419540384883,\"lng\":-114.03841871517517},{\"lat\":46.864193569942216,\"lng\":-114.03825510042526},{\"lat\":46.8650261570958,\"lng\":-114.03820413845398}]}",
    "Squash", user2["email"], "2018-04-01", "2018-07-01", [
        "Plant", "Garden Patch/Area (NOT raised beds)",
        "Vegetable & Fruit Garden", "Squash", "Acorn"
    ])
poly23 = db.create_polygon(
    "{\"shape\":\"polygon\",\"path\":[{\"lat\":46.865014158935594,\"lng\":-114.03903280001782},{\"lat\":46.864117384811145,\"lng\":-114.03902743559979},{\"lat\":46.86417423596727,\"lng\":-114.03895233374737},{\"lat\":46.86417973768884,\"lng\":-114.03878871899747},{\"lat\":46.865014158935594,\"lng\":-114.0387940834155}]}",
    "Carrots", user2["email"], "2018-04-01", "2018-07-01", [
        "Plant", "Garden Patch/Area (NOT raised beds)",
        "Vegetable & Fruit Garden", "Carrot", "Nantes"
    ])