示例#1
0
    def test_copy(self):
        """
        """
        session = GASession(garuda_uuid='xxx-xxx-xxx-xxx')
        request = GARequest(action=GARequest.ACTION_READ)
        context = GAContext(session=session, request=request)

        context.add_error(GAError(type=GAError.TYPE_INVALID, title='title1', description='description2', suggestion='nope', property_name='prop1'))
        context.add_error(GAError(type=GAError.TYPE_CONFLICT, title='title2', description='description3', suggestion='nope', property_name='prop2'))
        context.add_error(GAError(type=GAError.TYPE_NOTFOUND, title='title3', description='description4', suggestion='nope', property_name='prop3'))
        context.add_event(GAPushEvent(action=GARequest.ACTION_UPDATE, entity=tstdk.GAEnterprise()))
        context.add_event(GAPushEvent(action=GARequest.ACTION_CREATE, entity=tstdk.GAEnterprise()))
        context.add_event(GAPushEvent(action=GARequest.ACTION_DELETE, entity=tstdk.GAEnterprise()))

        context.object = tstdk.GAEnterprise(name='enterprise1')
        context.objects = [tstdk.GAEnterprise(name='enterprise2'), tstdk.GAEnterprise(name='enterprise3')]

        context_copy = context.copy()

        self.assertEquals(context_copy.session.uuid, session.uuid)
        self.assertEquals(context_copy.request.action, GARequest.ACTION_READ)
        self.assertEquals([obj.name for obj in context_copy.objects], [obj.name for obj in context.objects])
        self.assertEquals(context_copy.object.name, context.object.name)

        self.assertEquals(context_copy.has_errors, True)
        self.assertEquals(len(context_copy.errors), 3)

        self.assertEquals(context_copy.has_events, True)
        self.assertEquals(len(context_copy.events), 3)
示例#2
0
    def test_add_events(self):
        """
        """
        session = GASession(garuda_uuid='xxx-xxx-xxx-xxx')
        request = GARequest(action=GARequest.ACTION_READ)
        context = GAContext(session=session, request=request)
        event1 = GAPushEvent(action=GARequest.ACTION_UPDATE, entity=tstdk.GAEnterprise())
        event2 = GAPushEvent(action=GARequest.ACTION_CREATE, entity=tstdk.GAEnterprise())
        event3 = GAPushEvent(action=GARequest.ACTION_DELETE, entity=tstdk.GAEnterprise())

        context.add_event(event1)
        self.assertEquals(len(context.events), 1)
        self.assertEquals(context.has_events, True)

        context.add_events([event2, event3])
        self.assertEquals(len(context.events), 3)
        self.assertEquals(context.has_events, True)
示例#3
0
    def test_add_events(self):
        """
        """
        session = GASession(garuda_uuid='xxx-xxx-xxx-xxx')
        request = GARequest(action=GARequest.ACTION_READ)
        context = GAContext(session=session, request=request)
        event1 = GAPushEvent(action=GARequest.ACTION_UPDATE,
                             entity=tstdk.GAEnterprise())
        event2 = GAPushEvent(action=GARequest.ACTION_CREATE,
                             entity=tstdk.GAEnterprise())
        event3 = GAPushEvent(action=GARequest.ACTION_DELETE,
                             entity=tstdk.GAEnterprise())

        context.add_event(event1)
        self.assertEquals(len(context.events), 1)
        self.assertEquals(context.has_events, True)

        context.add_events([event2, event3])
        self.assertEquals(len(context.events), 3)
        self.assertEquals(context.has_events, True)
示例#4
0
    def test_copy(self):
        """
        """
        session = GASession(garuda_uuid='xxx-xxx-xxx-xxx')
        request = GARequest(action=GARequest.ACTION_READ)
        context = GAContext(session=session, request=request)

        context.add_error(
            GAError(type=GAError.TYPE_INVALID,
                    title='title1',
                    description='description2',
                    suggestion='nope',
                    property_name='prop1'))
        context.add_error(
            GAError(type=GAError.TYPE_CONFLICT,
                    title='title2',
                    description='description3',
                    suggestion='nope',
                    property_name='prop2'))
        context.add_error(
            GAError(type=GAError.TYPE_NOTFOUND,
                    title='title3',
                    description='description4',
                    suggestion='nope',
                    property_name='prop3'))
        context.add_event(
            GAPushEvent(action=GARequest.ACTION_UPDATE,
                        entity=tstdk.GAEnterprise()))
        context.add_event(
            GAPushEvent(action=GARequest.ACTION_CREATE,
                        entity=tstdk.GAEnterprise()))
        context.add_event(
            GAPushEvent(action=GARequest.ACTION_DELETE,
                        entity=tstdk.GAEnterprise()))

        context.object = tstdk.GAEnterprise(name='enterprise1')
        context.objects = [
            tstdk.GAEnterprise(name='enterprise2'),
            tstdk.GAEnterprise(name='enterprise3')
        ]

        context_copy = context.copy()

        self.assertEquals(context_copy.session.uuid, session.uuid)
        self.assertEquals(context_copy.request.action, GARequest.ACTION_READ)
        self.assertEquals([obj.name for obj in context_copy.objects],
                          [obj.name for obj in context.objects])
        self.assertEquals(context_copy.object.name, context.object.name)

        self.assertEquals(context_copy.has_errors, True)
        self.assertEquals(len(context_copy.errors), 3)

        self.assertEquals(context_copy.has_events, True)
        self.assertEquals(len(context_copy.events), 3)