Ejemplo n.º 1
0
class SessionValidatorTest(unittest.TestCase):

    def setUp(self):
        self.config = TestConfig()
        self.loader = SessionLoader(self.config)
        self.validator = SessionValidator()

    def test_validate(self):
        session = self.loader.load("testsession")
        self.assertTrue(session)
        self.assertTrue(self.validator.validate(session))

        session = self.loader.load("invalidsession")
        self.assertTrue(session)
        self.assertFalse(self.validator.validate(session))

        session = self.loader.load("sessionwithoutname")
        self.assertTrue(session)
        self.assertFalse(self.validator.validate(session))
Ejemplo n.º 2
0
    def test_load_derived(self):
        config = TestConfig()
        loader = SessionLoader(config)

        module = loader.module("derivedsession")
        self.assertTrue(module)
        self.assertEquals("derivedsession", module.__name__)

        classes = loader.classes("derivedsession")
        self.assertEquals(1, len(classes))

        sessions = loader.sessions("derivedsession")
        self.assertEquals(1, len(sessions))

        session = loader.load("derivedsession")
        self.assertTrue(session)
        self.assertEquals("1.0.abc", session.version)
        instance = session(config, "session",
                           "session", "session")
        self.assertTrue(instance)
Ejemplo n.º 3
0
    def test_load_sub(self):

        config = TestConfig()
        loader = SessionLoader(config)

        module = loader.module("subtest.subsession")
        self.assertTrue(module)
        self.assertEquals("subtest.subsession", module.__name__)

        classes = loader.classes("subtest.subsession")
        self.assertEquals(1, len(classes))

        sessions = loader.sessions("subtest.subsession")
        self.assertEquals(1, len(sessions))

        session = loader.load("subtest.subsession")
        self.assertTrue(session)
        self.assertEquals("x.y.z", session.version)
        instance = session(config, "session",
                           "session", "session")
        self.assertTrue(instance)

        module = loader.module("subtest.derivedsession")
        self.assertTrue(module)
        self.assertEquals("subtest.derivedsession", module.__name__)

        classes = loader.classes("subtest.derivedsession")
        self.assertEquals(1, len(classes))

        sessions = loader.sessions("subtest.derivedsession")
        self.assertEquals(1, len(sessions))

        session = loader.load("subtest.derivedsession")
        self.assertTrue(session)
        self.assertEquals("olla", session.version)
        instance = session(config, "session",
                           "session", "session")
        self.assertTrue(instance)
Ejemplo n.º 4
0
    def test_load(self):
        config = TestConfig()
        loader = SessionLoader(config)

        module = loader.module("testsession")
        self.assertTrue(module)
        self.assertEquals("testsession", module.__name__)

        classes = loader.classes("testsession")
        self.assertEquals(2, len(classes))

        sessions = loader.sessions("testsession")
        self.assertEquals(1, len(sessions))

        session = loader.load("testsession")
        self.assertTrue(session)
        instance = session(config, "session",
                           "session", "session")
        self.assertTrue(instance)
        self.assertTrue(instance.build())
        self.assertEquals(1, instance.my_method())

        session = loader.load("notestsession")
        self.assertFalse(session)
Ejemplo n.º 5
0
 def setUp(self):
     self.config = TestConfig()
     self.loader = SessionLoader(self.config)
     self.validator = SessionValidator()