def setUpClass(cls):
        '''
            Initiate the test data to use throughout all Tests
        '''
        cls.snapshot_data = [large_snapshot, small_snapshot, single_message_test,
                             no_messages_test, internal_messages_test]

        # Create a new snaphot object for all test data
        for snapshot in cls.snapshot_data:
            s = NetworkTrafficSnapshot()

            # Use upload method to extract data from the test log files
            content = TestNetworkTrafficSnapshot._get_snapshot_content(snapshot['path'])
            s.upload(snapshot['title'], snapshot['desc'], snapshot['path'], content)

            # Store the snapshot for use within the tests
            cls.snapshots.append(s)
Ejemplo n.º 2
0
    def POST(self):
        try:
            data = web.input()
            for field, schema in self.schema.iteritems():
                if field not in data:
                    if 'default' in self.schema[field]:
                        data[field] = self.schema[field]['default']
                    else:
                        web.badrequest()
                        return

        except AttributeError:
            pass
        else:
            # Process the logfile
            snapshot = NetworkTrafficSnapshot()
            snapshot.upload(data['title'], data['description'], data['logfile_name'], data['logfile_content'])
            snapshot_id = snapshot.save()

            # Process the statistics
            snapshot.generate_statistics()

            # Process the transactions
            transactions = SipTransactions()
            transactions.extract(snapshot_id)
            transactions.save()

            # Process the dialogs
            dialogs = SIPDialogs()
            dialogs.extract(snapshot_id)
            dialogs.save()

            return snapshot_id