Exemplo n.º 1
0
 def test_connection_id_setter(self, model_new):
     model = copy.deepcopy(model_new)
     connection = make_connection(model)
     cid = str(uuid.uuid4())
     connection.connection_id = cid
     assert connection.connection_id == cid
     assert connection.model['connection_id'] == cid
Exemplo n.º 2
0
    def add(self, request, connection_id=None):
        if 'connection_id' in request:
            raise ValueError(
                f'Invalid argument: connection_id. Expected empty but actual {request["connection_id"]}'
            )
        connection = make_connection(self.enhanced_request(request))
        now = datetime.datetime.utcnow()
        connection.metadata.created = now
        connection.metadata.updated = now

        self.repo.save(connection)
        sqs.publish(str(to_json(vars(ConnectionCreated(connection.model)))))
        return {'connection_id': connection.connection_id}
Exemplo n.º 3
0
    def run(self, logger=None):
        while True:
            try:
                for message in sqs.receive():
                    if 'Body' in message:
                        print(message['Body'])
                        connection = make_connection(
                            from_json(message['Body'])['body'])
                        print(connection)
                        ConnectionService().connection_created(connection)
                    sqs.delete(message)

            except Exception as e:
                logger.exception(e)
                sleep(1)
Exemplo n.º 4
0
    def tally_main(self, cr, uid, ids, context=None):

        form_obj = self.pool.get('tally.connection')
        obj = form_obj.browse(cr, uid, ids[0], context=context)
        conn = connection.make_connection(obj.url)
        company = obj.company
        daybook = obj.daybook

        def _processData(s):
            f = self.createTempFile(s)
            configdict = etree_parser.ConvertXmlToDict(f.name)
            if not configdict:
                return {}
            tallyData = dict(configdict)
            obj_migrator = migrator.migrator()
            obj_migrator.insertData(cr, uid, company, tallyData)
            self.deleteTempFile()

        if obj.ledgers:
            s = self.getData("Ledgers", conn)
            _processData(s)
        elif obj.groups:
            s = self.getData("Groups", conn)
            _processData(s)

        if obj.vouchers:
            s = self.getData("Ledgers", conn)
            _processData(s)
            try:
                configdict = etree_parser.ConvertXmlToDict(daybook)
            except Exception, e:
                raise osv.except_osv(('No such file or directory'), str(e))
            if not configdict:
                return {}
            tallyData = dict(configdict)
            obj_voucher = voucher.voucher(cr)
            obj_voucher.insertVoucherData(cr, uid, company, tallyData)
Exemplo n.º 5
0
 def test_connection_serialization(self, model_valid):
     dumps = json.dumps(make_connection(model_valid).model).encode()
     print(dumps)
     assert dumps
Exemplo n.º 6
0
 def test_name_required(self, model_valid):
     model = copy.deepcopy(model_valid)
     del model['name']
     with pytest.raises(KeyError) as err:
         make_connection(model)
Exemplo n.º 7
0
 def test_connection_id_is_uuid(self, model_valid):
     model_valid['connection_id'] = '5ee7dcd0-54'
     with pytest.raises(ValueError) as err:
         make_connection(model_valid)
Exemplo n.º 8
0
 def test_resource_created_when_valid_request(self, model_valid):
     connection = make_connection(model_valid)
     assert connection.name == model_valid['name']
     assert connection.connector_type == model_valid['connector_type']
Exemplo n.º 9
0
 def list(self):
     return [make_connection(item) for item in self.table.scan()['Items']]
Exemplo n.º 10
0
 def get(self, connection_id):
     response = self.table.get_item(Key={'connection_id': connection_id})
     if 'Item' not in response:
         return None
     return make_connection(response['Item'])
Exemplo n.º 11
0
 def test_resource_created_when_valid_request(self, model_valid):
     connection = make_connection(model_valid)
     assert connection
Exemplo n.º 12
0
 def test_profile_id_required(self, model_valid):
     del model_valid['parameters']['profile_id']
     with pytest.raises(KeyError) as err:
         make_connection(model_valid)