Example #1
0
 def test_fd_update_rule(self):
     intent = TestAccount.get_intent()
     intentid = intent["ID"]
     candidates = [
         c.attribute_values
         for c in Item.query("rule", Item.parent.__eq__(intentid))
     ]
     rule = candidates[0]
     ruleid = rule["ID"]
     print ">>", ruleid
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "updateRule",
         "path": "Mutation/updateRule",
         "arguments": {
             "ruleid": ruleid,
             "input": {
                 "description": "updated"
             }
         }
     }
     r = App.handler(event, {})
     print r
     self.assertEqual(r["description"], "updated")
Example #2
0
 def test_ed_update_variable(self):
     entity = TestAccount.get_entity()
     entityid = entity["ID"]
     candidates = [
         c.attribute_values
         for c in Item.query("variable", Item.parent.__eq__(entityid))
     ]
     variable = candidates[0]
     variableid = variable["ID"]
     print ">>", variableid
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "updateVariable",
         "path": "Mutation/updateVariable",
         "arguments": {
             "variableid": variableid,
             "input": {
                 "description": "updated"
             }
         }
     }
     r = App.handler(event, {})
     print r
     self.assertEqual(r["description"], "updated")
Example #3
0
 def test_ac_list_myaccount(self):
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "listMyAccounts",
         "path": "Query/listMyAccounts",
         "arguments": {}
     }
     x = App.handler(event, {})
     for user in x:
         print user
Example #4
0
    def test_aa_clean(self):
        event = {
            "identity": {
                "claims": TestAccount.get_claim()
            },
            "field": "listMyAccounts",
            "path": "Query/listMyAccounts",
            "arguments": {}
        }
        accounts = App.handler(event, {})

        if type(accounts) == type(["a", "list"]):
            print "Found", len(accounts), "accounts"
            print accounts
            for accountdoc in accounts:
                a = Item.get('account', accountdoc["ID"])
                a.delete()

            x = App.handler(event, {})
            self.assertTrue(len(x) == 0)
        else:
            self.assertTrue(True, "no accounts")
Example #5
0
 def test_bc_get_bot(self):
     accountid = TestAccount.get_accountid()
     bots = TestAccount.get_bots()
     bot = bots[0]
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "getBot",
         "path": "Query/getBot",
         "arguments": {
             "botid": bot["ID"]
         }
     }
     r = App.handler(event, {})
     self.assertEqual(r["name"], bot["name"])
Example #6
0
 def test_ad_invite(self):
     accountid = TestAccount.get_accountid()
     print "accountid = ,", accountid
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "inviteUser",
         "path": "Mutation/inviteUser",
         "arguments": {
             "accountid": accountid,
             "email": "*****@*****.**",
         }
     }
     x = App.handler(event, {})
     print x
Example #7
0
    def test_bb_list_bots(self):
        accountid = TestAccount.get_accountid()
        event = {
            "identity": {
                "claims": TestAccount.get_claim()
            },
            "field": "listBots",
            "path": "Account/listBots",
            "arguments": {},
            "source": {
                "ID": accountid
            }
        }

        r = App.handler(event, {})
        print r
        print pprint.pformat(r)
        self.assertTrue(len(r) == 1)
Example #8
0
    def test_eb_list_variables(self):
        entity = TestAccount.get_entity()
        entityid = entity["ID"]
        event = {
            "identity": {
                "claims": TestAccount.get_claim()
            },
            "field": "listVariables",
            "path": "Entity/listVariables",
            "arguments": {},
            "source": {
                "ID": entityid
            }
        }

        r = App.handler(event, {})
        print r
        print pprint.pformat(r)
        self.assertTrue(len(r) == 1)
Example #9
0
    def test_fb_list_rules(self):
        intent = TestAccount.get_intent()
        intentid = intent["ID"]
        event = {
            "identity": {
                "claims": TestAccount.get_claim()
            },
            "field": "listRules",
            "path": "Intent/listRules",
            "arguments": {},
            "source": {
                "ID": intentid
            }
        }

        r = App.handler(event, {})
        print r
        print pprint.pformat(r)
        self.assertTrue(len(r) == 1)
Example #10
0
 def test_ab_create_account(self):
     print "+-+" * 30
     print "CREATION"
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "createAccount",
         "path": "Mutation/createAccount",
         "arguments": {
             "input": {
                 "name": "testaccount"
             }
         }
     }
     self.assertTrue(True)
     w = App.handler(event, {})
     print "Creation "
     print pprint.pformat(w)
Example #11
0
 def test_ea_create_variable(self):
     entity = TestAccount.get_entity()
     entityid = entity["ID"]
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "createVariable",
         "path": "Mutation/createVariable",
         "arguments": {
             "entityid": entityid,
             "input": {
                 "name": "mytestvariable",
                 "description": "test"
             }
         }
     }
     self.assertTrue(True)
     w = App.handler(event, {})
     print pprint.pformat(w)
Example #12
0
 def test_dc_get_intent(self):
     accountid = TestAccount.get_accountid()
     bots = TestAccount.get_bots()
     bot = bots[0]
     botid = bot["ID"]
     intents = TestAccount.get_intents(botid)
     intent = intents[0]
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "getIntent",
         "path": "Query/getIntent",
         "arguments": {
             "intentid": intent["ID"]
         }
     }
     r = App.handler(event, {})
     print r
     self.assertEqual(r["name"], intent["name"])
Example #13
0
 def test_fa_create_rule(self):
     intent = TestAccount.get_intent()
     intentid = intent["ID"]
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "createRule",
         "path": "Mutation/createRule",
         "arguments": {
             "intentid": intentid,
             "input": {
                 "name": "mytestrule",
                 "description": "test"
             }
         }
     }
     self.assertTrue(True)
     w = App.handler(event, {})
     print pprint.pformat(w)
Example #14
0
 def test_cc_get_entity(self):
     accountid = TestAccount.get_accountid()
     bots = TestAccount.get_bots()
     bot = bots[0]
     botid = bot["ID"]
     entities = TestAccount.get_entities(botid)
     entity = entities[0]
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "getEntity",
         "path": "Query/getEntity",
         "arguments": {
             "entityid": entity["ID"]
         }
     }
     r = App.handler(event, {})
     print r
     self.assertEqual(r["name"], entity["name"])
Example #15
0
 def test_ba_create_bot(self):
     accountid = TestAccount.get_accountid()
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "createBot",
         "path": "Mutation/createBot",
         "arguments": {
             "accountid": accountid,
             "input": {
                 "name": "mytestbot",
                 "description": "test"
             }
         }
     }
     self.assertTrue(True)
     w = App.handler(event, {})
     print "Creation "
     print pprint.pformat(w)
Example #16
0
 def test_be_list_bots_with_search(self):
     accountid = TestAccount.get_accountid()
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "listBots",
         "path": "Account/listBots",
         "arguments": {
             "options": {
                 "search": "updated"
             }
         },
         "source": {
             "ID": accountid
         }
     }
     r = App.handler(event, {})
     print r
     self.assertEqual(len(r), 1)
Example #17
0
 def test_bd_update_bot(self):
     accountid = TestAccount.get_accountid()
     bots = TestAccount.get_bots()
     bot = bots[0]
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "updateBot",
         "path": "Mutation/updateBot",
         "arguments": {
             "botid": bot["ID"],
             "input": {
                 "description": "updated"
             }
         }
     }
     r = App.handler(event, {})
     print r
     self.assertEqual(r["description"], "updated")
Example #18
0
 def test_fe_list_rules_with_search(self):
     intent = TestAccount.get_intent()
     intentid = intent["ID"]
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "listRules",
         "path": "Entity/listRules",
         "arguments": {
             "options": {
                 "search": "updated"
             }
         },
         "source": {
             "ID": intentid
         }
     }
     r = App.handler(event, {})
     print r
     self.assertEqual(len(r), 1)
Example #19
0
    def test_cb_list_entities(self):
        accountid = TestAccount.get_accountid()
        bots = TestAccount.get_bots()
        bot = bots[0]
        botid = bot["ID"]
        event = {
            "identity": {
                "claims": TestAccount.get_claim()
            },
            "field": "listEntities",
            "path": "Bot/listEntities",
            "arguments": {},
            "source": {
                "ID": botid
            }
        }

        r = App.handler(event, {})
        print r
        print pprint.pformat(r)
        self.assertTrue(len(r) == 1)
Example #20
0
 def test_ee_list_variables_with_search(self):
     entity = TestAccount.get_entity()
     entityid = entity["ID"]
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "listVariables",
         "path": "Entity/listVariables",
         "arguments": {
             "options": {
                 "search": "updated"
             }
         },
         "source": {
             "ID": entityid
         }
     }
     r = App.handler(event, {})
     print r
     self.assertEqual(len(r), 1)
Example #21
0
 def test_da_create_intent(self):
     bots = TestAccount.get_bots()
     bot = bots[0]
     print "??", bot
     botid = bot["ID"]
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "createIntent",
         "path": "Mutation/createIntent",
         "arguments": {
             "botid": botid,
             "input": {
                 "name": "mytestintent",
                 "description": "test"
             }
         }
     }
     self.assertTrue(True)
     w = App.handler(event, {})
     print pprint.pformat(w)
Example #22
0
 def test_fc_get_rule(self):
     intent = TestAccount.get_intent()
     intentid = intent["ID"]
     candidates = [
         c.attribute_values
         for c in Item.query("rule", Item.parent.__eq__(intentid))
     ]
     rule = candidates[0]
     ruleid = rule["ID"]
     print ">>", ruleid
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "getRule",
         "path": "Query/getRule",
         "arguments": {
             "ruleid": ruleid
         }
     }
     r = App.handler(event, {})
     print r
     self.assertEqual(r["name"], rule["name"])
Example #23
0
 def test_ec_get_variable(self):
     entity = TestAccount.get_entity()
     entityid = entity["ID"]
     candidates = [
         c.attribute_values
         for c in Item.query("variable", Item.parent.__eq__(entityid))
     ]
     variable = candidates[0]
     variableid = variable["ID"]
     print ">>", variableid
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "getVariable",
         "path": "Query/getVariable",
         "arguments": {
             "variableid": variableid
         }
     }
     r = App.handler(event, {})
     print r
     self.assertEqual(r["name"], variable["name"])
Example #24
0
 def test_cd_update_entity(self):
     accountid = TestAccount.get_accountid()
     bots = TestAccount.get_bots()
     bot = bots[0]
     botid = bots[0]["ID"]
     entities = TestAccount.get_entities(botid)
     entity = entities[0]
     entityid = entity["ID"]
     event = {
         "identity": {
             "claims": TestAccount.get_claim()
         },
         "field": "updateEntity",
         "path": "Mutation/updateEntity",
         "arguments": {
             "entityid": entityid,
             "input": {
                 "description": "updated"
             }
         }
     }
     r = App.handler(event, {})
     print r
     self.assertEqual(r["description"], "updated")
Example #25
0
def handler(event, context):
    x = App.handler(event, context)
    print x
    return x
Example #26
0
    def test_entity_api(self):
        event = {
            "identity": {
                "claims": TestEndToEnd.get_claim()
            },
            "field": "createBot",
            "path": "Mutation/createBot",
            "arguments": {
                "accountid": "testaccount",
                "input": {
                    "name": "mytestbot",
                    "description": "test"
                }
            }
        }
        self.assertTrue(True)
        b = App.handler(event, {})
        print b

        event = {
            "identity": {
                "claims": TestEndToEnd.get_claim()
            },
            "field": "createEntity",
            "path": "Mutation/createEntity",
            "arguments": {
                "botid": b["ID"],
                "input": {
                    "name": "mytestbot",
                    "description": "test"
                }
            }
        }

        e = App.handler(event, {})
        print e

        event = {
            "identity": {
                "claims": TestEndToEnd.get_claim()
            },
            "field": "createEntity",
            "path": "Mutation/createEntity",
            "arguments": {
                "botid": b["ID"],
                "input": {
                    "name": "mytestbot",
                    "description": "test"
                }
            }
        }

        w = App.handler(event, {})
        print w

        event = {
            "identity": {
                "claims": TestEndToEnd.get_claim()
            },
            "field": "getEntity",
            "path": "Query/getEntity",
            "arguments": {
                "entityid": w["ID"],
            }
        }

        event = {
            "identity": {
                "claims": TestEndToEnd.get_claim()
            },
            "field": "updateEntity",
            "path": "Mutation/updateEntity",
            "arguments": {
                "entityid": w["ID"],
                "input": {
                    "tags": "x,y,z"
                }
            }
        }
        u = App.handler(event, {})
        print "U = ", u

        event = {
            "identity": {
                "claims": TestEndToEnd.get_claim()
            },
            "field": "listEntities",
            "path": "Query/listentities",
            "arguments": {
                "botid": b["ID"]
            }
        }
        l = App.handler(event, {})
        print "entities = ", l

        event = {
            "identity": {
                "claims": TestEndToEnd.get_claim()
            },
            "field": "deleteEntity",
            "path": "Mutation/deleteEntity",
            "arguments": {
                "entityid": w["ID"]
            }
        }
        d = App.handler(event, {})
        print "D = ", d