Ejemplo n.º 1
0
    def updateCorpSignaturesInSystem(self, corpId, systemId, signatures):
        #: :type: pyeve.schema.CorpSignature
        sig = self._session.query(CorpSignature).filter(and_(
            corpSignatures.c.id == corpId,
            corpSignatures.c.systemId == systemId
        )).first()

        if sig is None:
            sig = CorpSignature(corpId, systemId, signatures)
            self._session.add(sig)
        else:
            oldSig = sig.getSignatures()
            newSig = combineSignatures(oldSig, signatures)
            sig.setSignatures(newSig)

        return sig.getSignatures()
Ejemplo n.º 2
0
    def test_simpleUpdate(self):
        oldSignatures = [
            Signature('JVY-655', '', '', ''),
            Signature('ZXC-123', 'abc', 'def', ''),
        ]

        newSignatures = [
            Signature('JVY-655', 'Cosmic Signature', 'Combat Site', 'ala'),
            Signature('ZXC-123', '', 'def', 'ghi'),
        ]

        result = combineSignatures(oldSignatures, newSignatures)

        self.assertEqual(len(result), 2)

        sigByKey = dict([(x.key, x) for x in result])

        self.assertIn('JVY-655', sigByKey)
        self.assertIn('ZXC-123', sigByKey)

        self.assertEqual(sigByKey['JVY-655'], Signature('JVY-655', 'Cosmic Signature', 'Combat Site', 'ala'))

        self.assertEqual(sigByKey['ZXC-123'], Signature('ZXC-123', 'abc', 'def', 'ghi'))
Ejemplo n.º 3
0
    def test_addNew(self):
        oldSignatures = [
            Signature('ABC-123', '', '', ''),
            Signature('ZXC-123', 'abc', 'def', ''),
        ]

        newSignatures = [
            Signature('ABC-123', '', '', ''),
            Signature('ABC-456', '', '', ''),
            Signature('DEF-789', '', '', ''),
            Signature('ZXC-123', 'abc', 'def', ''),
        ]

        result = combineSignatures(oldSignatures, newSignatures)

        self.assertEqual(len(result), 4)

        sigByKey = dict([(x.key, x) for x in result])

        self.assertIn('ABC-123', sigByKey)
        self.assertIn('ABC-456', sigByKey)
        self.assertIn('DEF-789', sigByKey)
        self.assertIn('ZXC-123', sigByKey)