Esempio n. 1
0
    def testChangeNarrativePlace(self):
        logoutCurrentUser()
        setCurrentUser("*****@*****.**", "User1")
        register_new_user('User1')
        
        place1 = create_place("Place 1")
        place2 = create_place("Place 2")
        role1 = create_role("Role 1")
        role2 = create_role("Role 2")

        create_presence(role1, place1)
        create_presence(role2, place2)
        set_playing(role1)
        create_narrative(place1, "Narrative 1 from Role 1 at Place 1")
    
        rset = get_first_narrative()
        self.assertEqual(len(rset["narrative"]), 1)
        narrative = rset["narrative"][0]
        
        set_playing(role2)
        rset = get_first_narrative()
        self.assertEqual(len(rset["narrative"]), 0)

        set_playing(role1)
        create_presence(role1, place2)
        save_narrative(narrative["id"], place_id=place2)

        rset = get_first_narrative()
        self.assertEqual(len(rset["narrative"]), 1)
        
        set_playing(role2)
        rset = get_first_narrative()
        self.assertEqual(len(rset["narrative"]), 1)
Esempio n. 2
0
def setupLotsOfRoles():
    setCurrentUser("*****@*****.**", "User1")
    register_new_user('User1')
    place1 = create_place("Test Place 1")
    role1 = create_role("Test Role 1")
    create_presence(role1, place1)
    role2 = create_role("Test Role 2")
    create_presence(role2, place1)
    create_role("Test Role 3")
    create_role("Test Role 4")
    create_role("Test Role 5")
    create_role("Test Role 6")
    create_role("Test Role 7")
    create_role("Test Role 8")
    create_role("Test Role 9")
    create_role("Test Role 10")
    create_role("Test Role 11")
    create_role("Test Role 12")
    create_role("Test Role 13")
    create_role("Test Role 14")
    setCurrentUser("*****@*****.**", "User2")
    register_new_user('User2')
    create_place("Test Place 2")
    create_role("Test Role 15")
    create_role("Test Role 16")
    return place1
Esempio n. 3
0
 def testDeleteUnoccupiedPlace(self):
     setCurrentUser("*****@*****.**", "User1")
     register_new_user('User1')
     place1 = create_place("Test Place 1")
     place2 = create_place("Test Place 2")
     role1 = create_role("Test Role 1")
     create_presence(role1, place2)
     delete_place(place1)
Esempio n. 4
0
 def testIsPresent(self):
     setCurrentUser("*****@*****.**", "User1")
     register_new_user('User1')
     place1 = create_place("Test Place 1")
     place2 = create_place("Test Place 2")
     role1 = create_role("Test Role 1")
     role2 = create_role("Test Role 2")
     create_presence(role1, place1)
     create_presence(role2, place2)
     self.assertTrue(is_present(role1, place1))
     self.assertFalse(is_present(role1, place2))
     self.assertTrue(is_present(role2, place2))
     self.assertFalse(is_present(role2, place1))
Esempio n. 5
0
 def testCreatePresence(self):
     setCurrentUser("*****@*****.**", "User1")
     register_new_user('User1')
     place1 = create_place("Test Place 1")
     place2 = create_place("Test Place 2")
     role1 = create_role("Test Role 1")
     self.assertEqual(len(get_roles_in_place(place1)), 0)
     self.assertEqual(len(get_roles_in_place(place2)), 0)
     create_presence(role1, place1)
     self.assertEqual(len(get_roles_in_place(place1)), 1)
     self.assertEqual(len(get_roles_in_place(place2)), 0)
     create_presence(role1, place2)
     self.assertEqual(len(get_roles_in_place(place1)), 1)
     self.assertEqual(len(get_roles_in_place(place2)), 1)
Esempio n. 6
0
 def testDeleteOccupiedPlace(self):
     setCurrentUser("*****@*****.**", "User1")
     register_new_user('User1')
     place1 = create_place("Test Place 1")
     role1 = create_role("Test Role 1")
     create_presence(role1, place1)
     self.assertRaises(ActionException, delete_place, place1)
Esempio n. 7
0
 def testBlankPlaceName(self):
     setCurrentUser("*****@*****.**", "User1")
     register_new_user('User1')
     place1url = create_place("Test Place 1")
     self.assertRaises(ActionException, create_place, None)
     self.assertRaises(DataModelException, create_place, "")
     self.assertRaises(DataModelException, save_place, place1url, name="")
Esempio n. 8
0
    def testChangeNarrativeBody(self):
        logoutCurrentUser()
        setCurrentUser("*****@*****.**", "User1")
        register_new_user('User1')
        
        place1 = create_place("Place 1")
        role1 = create_role("Role 1")

        create_presence(role1, place1)
        set_playing(role1)
        create_narrative(place1, "Narrative 1 from Role 1 at Place 1")
    
        rset = get_first_narrative()
        self.assertEqual(rset["more"], False)
        self.assertEqual(len(rset["narrative"]), 1)
        narrative = rset["narrative"][0]
        self.assertEqual(narrative["role"], "Role 1")
        self.assertEqual(narrative["place"], "Place 1")
        self.assertEqual(narrative["body"], "Narrative 1 from Role 1 at Place 1")
        self.assertIsNotNone(narrative["created"])
        self.assertIsNone(narrative["updated"])
        
        save_narrative(narrative["id"], "Narrative 1 from Role 1 at Place 1 - updated")

        rset = get_first_narrative()
        self.assertEqual(rset["more"], False)
        self.assertEqual(len(rset["narrative"]), 1)
        narrative = rset["narrative"][0]
        self.assertEqual(narrative["role"], "Role 1")
        self.assertEqual(narrative["place"], "Place 1")
        self.assertEqual(narrative["body"], "Narrative 1 from Role 1 at Place 1 - updated")
        self.assertIsNotNone(narrative["created"])
        self.assertIsNotNone(narrative["updated"])
Esempio n. 9
0
 def testSavePresence(self):
     setCurrentUser("*****@*****.**", "User1")
     register_new_user('User1')
     place1 = create_place("Test Place 1")
     role1 = create_role("Test Role 1")
     create_presence(role1, place1)
     save_presence(role1, place1, ["broken nose", "busted leg"])
     self.assertEqual(2, len(get_roles_in_place(place1)[0].get("damage")))
Esempio n. 10
0
 def testDeleteAnotherUsersPlace(self):
     setCurrentUser("*****@*****.**", "User1")
     register_new_user('User1')
     place1url = create_place("Test Place 1")
     setCurrentUser("*****@*****.**", "User2")
     register_new_user('User2')
     self.assertEquals(len(get_my_places()), 0)
     self.assertRaises(DataModelException, delete_place, place1url)
Esempio n. 11
0
 def testDeletePlace(self):
     setCurrentUser("*****@*****.**", "User1")
     register_new_user('User1')
     self.assertEquals(len(get_my_places()), 0)
     place1url = create_place("Test Place 1")
     self.assertEquals(len(get_my_places()), 1)
     delete_place(place1url)
     self.assertEquals(len(get_my_places()), 0)
Esempio n. 12
0
 def testWritableProperty(self):
     setCurrentUser("*****@*****.**", "User1")
     register_new_user('User1')
     place1url = create_place("Test Place 1")
     self.assertTrue(get_place_properties(place1url)["writable"])
     logoutCurrentUser()
     setCurrentUser("*****@*****.**", "User2")
     register_new_user('User2')
     self.assertFalse(get_place_properties(place1url)["writable"])
Esempio n. 13
0
 def testCreatePresenceInSomeoneElsesPlace(self):
     setCurrentUser("*****@*****.**", "User1")
     register_new_user('User1')
     place1 = create_place("Test Place 1")
     logoutCurrentUser()
     setCurrentUser("*****@*****.**", "User2")
     register_new_user('User2')
     role1 = create_role("Test Role 1")
     self.assertRaises(DataModelException, create_presence, role1, place1)
Esempio n. 14
0
 def testDeleteRoleWithPresence(self):
     setCurrentUser("*****@*****.**", "User1")
     register_new_user('User1')
     place1 = create_place("Test Place 1")
     self.assertEqual(len(get_roles_in_place(place1)), 0)
     role1 = create_role("Test Role 1")
     create_presence(role1, place1)
     self.assertEqual(len(get_roles_in_place(place1)), 1)
     self.assertRaises(ActionException, delete_role, role1)
Esempio n. 15
0
 def testSaveAnotherUsersPlace(self):
     setCurrentUser("*****@*****.**", "User1")
     register_new_user('User1')
     place1url = create_place("Test Place 1")
     save_place(place1url, name="This is a new place name")
     logoutCurrentUser()
     setCurrentUser("*****@*****.**", "User2")
     self.assertRaises(DataModelException, save_place, place1url, "Should Fail")
     register_new_user('User2')
     self.assertRaises(DataModelException, save_place, place1url, "Should Fail")
Esempio n. 16
0
 def testDeletePresenceFromSomeoneElsesPlace(self):
     setCurrentUser("*****@*****.**", "User1")
     register_new_user('User1')
     place1 = create_place("Test Place 1")
     role1 = create_role("Test Role 1")
     pres1 = create_presence(role1, place1)
     logoutCurrentUser()
     setCurrentUser("*****@*****.**", "User2")
     register_new_user('User2')
     self.assertRaises(ActionException, delete_presence, role1, place1)
Esempio n. 17
0
 def testWritableProperty(self):
     setCurrentUser("*****@*****.**", "User1")
     register_new_user('User1')
     create_role("Role 1")
     myroles1 = get_my_roles()
     self.assertTrue(myroles1[0].get("writable"))
     self.assertTrue(myroles1[1].get("writable"))
     place1 = create_place("Place 1")
     create_presence(myroles1[1]["id"], place1)
     logoutCurrentUser()
     setCurrentUser("*****@*****.**", "User2")
     register_new_user('User2')
     create_role("Role 2")
     myroles2 = get_my_roles()
     self.assertTrue(myroles2[0].get("writable"))
     self.assertTrue(myroles2[1].get("writable"))
     myroles3 = get_roles_in_place(place1)
     self.assertFalse(myroles3[0].get("writable"))
Esempio n. 18
0
 def testSavePlaceName(self):
     setCurrentUser("*****@*****.**", "User1")
     register_new_user('User1')
     place1url = create_place("Test Place 1")
     save_place(place1url, name="This is a new place name")
     self.assertEqual(get_place_properties(place1url)["name"], "This is a new place name")
Esempio n. 19
0
    def testCreateNarrative(self):
        logoutCurrentUser()
        setCurrentUser("*****@*****.**", "User1")
        user1 = register_new_user('User1')
        
        place1 = create_place("Place 1")
        role1 = create_role("Role 1")
        place2 = create_place("Place 2")
        role2 = create_role("Role 2")
    
        create_presence(role1, place1)
        set_playing(role1)
        create_narrative(place1, "Narrative 1 from Role 1 at Place 1")
        create_presence(role2, place2)
        set_playing(role2)
        create_narrative(place2, "Narrative 1 from Role 2 at Place 2")
    
        create_presence(role2, place1)
        set_playing(role1)
        create_narrative(place1, "Narrative 2 from Role 1 at Place 1")
        create_presence(role1, place2)
        set_playing(role2)
        create_narrative(place2, "Narrative 2 from Role 2 at Place 2")
    
        delete_presence(role2, place1)
        set_playing(role1)
        create_narrative(place1, "Narrative 3 from Role 1 at Place 1")
        delete_presence(role1, place2)
        set_playing(role2)
        create_narrative(place2, "Narrative 3 from Role 2 at Place 2")
    
        set_playing(role1)
        rset = get_first_narrative()
        self.assertEqual(rset["more"], False)
        self.assertEqual(len(rset["narrative"]), 4)

        set_playing(role2)
        rset = get_first_narrative()
        self.assertEqual(rset["more"], False)
        self.assertEqual(len(rset["narrative"]), 4)

        set_playing(user1)
        rset = get_first_narrative()
        self.assertEqual(rset["more"], False)
        self.assertEqual(len(rset["narrative"]), 6)

        setCurrentUser("*****@*****.**", "Administrator")
        rset = get_first_narrative()
        self.assertEqual(rset["more"], False)
        self.assertEqual(len(rset["narrative"]), 0)

        setCurrentUser("*****@*****.**", "User1")
        create_presence(role1, place2)
        create_presence(role2, place1)

        set_playing(role1)
        create_narrative(place1, "Narrative 4 from Role 1 at Place 1")
        create_narrative(place1, "Narrative 5 from Role 1 at Place 1")
        create_narrative(place1, "Narrative 6 from Role 1 at Place 1")
        create_narrative(place1, "Narrative 7 from Role 1 at Place 1")
        create_narrative(place1, "Narrative 8 from Role 1 at Place 1")
        create_narrative(place1, "Narrative 9 from Role 1 at Place 1")

        set_playing(role2)
        create_narrative(place2, "Narrative 4 from Role 2 at Place 2")
        create_narrative(place2, "Narrative 5 from Role 2 at Place 2")
        create_narrative(place2, "Narrative 6 from Role 2 at Place 2")
        create_narrative(place2, "Narrative 7 from Role 2 at Place 2")
        create_narrative(place2, "Narrative 8 from Role 2 at Place 2")
        create_narrative(place2, "Narrative 9 from Role 2 at Place 2")

        set_playing(role1)
        rset = get_first_narrative()
        self.assertEqual(rset["more"], True)
        self.assertEqual(len(rset["narrative"]), 10)
        rset = get_more_narrative(rset["next"])
        self.assertEqual(rset["more"], False)
        self.assertEqual(len(rset["narrative"]), 6)

        set_playing(role2)
        rset = get_first_narrative()
        self.assertEqual(rset["more"], True)
        self.assertEqual(len(rset["narrative"]), 10)
        rset = get_more_narrative(rset["next"])
        self.assertEqual(rset["more"], False)
        self.assertEqual(len(rset["narrative"]), 6)

        set_playing(user1)
        rset = get_first_narrative()
        self.assertEqual(rset["more"], True)
        self.assertEqual(len(rset["narrative"]), 10)
        rset = get_more_narrative(rset["next"])
        self.assertEqual(rset["more"], False)
        self.assertEqual(len(rset["narrative"]), 8)

        setCurrentUser("*****@*****.**", "Administrator")
        rset = get_first_narrative()
        self.assertEqual(rset["more"], False)
        self.assertEqual(len(rset["narrative"]), 0)
Esempio n. 20
0
 def testAdminAndNonAdminCreatePlaces(self):
     self.assertIsInstance(create_place("Test Place 1"), str)
     logoutCurrentUser()
     setCurrentUser("*****@*****.**", "User1")
     register_new_user('User1')
     self.assertIsInstance(create_place("Test Place 2"), str)
Esempio n. 21
0
 def testAdminCreatePlace(self):
     create_place("Test Place 1")
     self.assertEquals(len(get_my_places()), 1)
Esempio n. 22
0
def setupLotsOfPlaces():
    setCurrentUser("*****@*****.**", "User1")
    register_new_user('User1')
    create_place("Test Place 1")
    create_place("Test Place 2")
    create_place("Test Place 3")
    create_place("Test Place 4")
    create_place("Test Place 5")
    create_place("Test Place 6")
    create_place("Test Place 7")
    create_place("Test Place 8")
    create_place("Test Place 9")
    create_place("Test Place 10")
    create_place("Test Place 11")
    create_place("Test Place 12")
    create_place("Test Place 13")
    create_place("Test Place 14")
    setCurrentUser("*****@*****.**", "User2")
    register_new_user('User2')
    create_place("Test Place 15")
    create_place("Test Place 16")