Exemplo n.º 1
0
    def test_run_init_hooks(self):
        from evennia.utils import create

        obj1 = create.object(key="HookTestObj1")
        obj2 = create.object(key="HookTestObj2")
        acct1 = create.account("HookAcct1", "*****@*****.**", "testpasswd")
        acct2 = create.account("HookAcct2", "*****@*****.**", "testpasswd")

        with patch("evennia.objects.models.ObjectDB") as mockobj:
            with patch("evennia.server.server.AccountDB") as mockacct:

                mockacct.get_all_cached_instances = MagicMock(
                    return_value=[acct1, acct2])
                mockobj.get_all_cached_instances = MagicMock(
                    return_value=[obj1, obj2])
                mockobj.objects.clear_all_sessids = MagicMock()

                evennia = self.server.Evennia(MagicMock())
                evennia.run_init_hooks("reload")
                evennia.run_init_hooks("reset")
                evennia.run_init_hooks("shutdown")

                mockacct.get_all_cached_instances.assert_called()
                mockobj.get_all_cached_instances.assert_called()
                mockobj.objects.clear_all_sessids.assert_called_with()
        obj1.delete()
        obj2.delete()
        acct1.delete()
        acct2.delete()
Exemplo n.º 2
0
 def test_create_account(self):
     acct = create.account(
         "TestAccount3", "*****@*****.**", "testpassword123",
         locks="test:all()",
         tags=[("tag1", "category1"), ("tag2", "category2", "data1"), ("tag3", None)],
         attributes=[("key1", "value1", "category1",
                      "edit:false()", True),
                     ("key2", "value2")])
     acct.save()
     self.assertTrue(acct.pk)