Пример #1
0
    def doPost(self, request):
        """
        :type request: werkzeug.wrappers.Request
        """

        operation = request.args.get('call', None)
        helper = IGBRequest(request)

        if operation == 'saveSignatures':
            newSignatures = request.data.decode('utf8')

            parsed = parseSignatures(newSignatures)
            currentSignatures = self._updateSignatures(self.getDA().getSignaturesDA(), helper, parsed)

            html = flatten(self.getKnownSignaturesTable(currentSignatures))

            return JsonResponse(dict(status='save sig', html=html))

        elif operation == 'getSystem':
            return JsonResponse(dict(systemName=helper.systemName))

        elif operation == 'getLoot':
            return self.handleGetLootRequest(request)

        elif operation == 'addContainer':
            return self.handleAddContainerRequest(request)

        else:
            return JsonResponse(dict(error='invalid operation'))
Пример #2
0
    def test_unparseParseEqual(self):
        signatures = [
            Signature('JVY-655', 'Cosmic Signature', 'Combat Site', 'ala'),
            Signature('ZXC-123', '', 'def', 'ghi'),
            Signature('ABC-456', 'Lorem ipsum', 'Dolor sit', 'Amet est'),
        ]

        signaturesStr = unparseSignatures(signatures)

        parsed = parseSignatures(signaturesStr)

        self.assertEqual(len(parsed), len(signatures))

        self.assertIn(signatures[0], parsed)
        self.assertIn(signatures[1], parsed)
        self.assertIn(signatures[2], parsed)
Пример #3
0
    def test_simpleParse(self):
        sigData = """SNL-720	Cosmic Signature	Relic Site	Ruined Serpentis Temple Site	100,00%	50,99 AU
KKP-634	Cosmic Signature	Data Site		0,00%	62,23 AU
JVY-655	Cosmic Signature	Combat Site		0,00%	50,02 AU"""

        result = parseSignatures(sigData)

        self.assertEqual(len(result), 3)

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

        self.assertIn('SNL-720', sigByKey)
        self.assertIn('KKP-634', sigByKey)
        self.assertIn('JVY-655', sigByKey)

        self.assertEqual(sigByKey['SNL-720'], Signature('SNL-720', 'Cosmic Signature', 'Relic Site',
                                                        'Ruined Serpentis Temple Site'))

        self.assertEqual(sigByKey['KKP-634'], Signature('KKP-634', 'Cosmic Signature', 'Data Site', ''))

        self.assertEqual(sigByKey['JVY-655'], Signature('JVY-655', 'Cosmic Signature', 'Combat Site', ''))
Пример #4
0
    def getSignatures(self):
        if self.data is None:
            return None

        return parseSignatures(self.data)
Пример #5
0
    def test_parseEmptyNewline(self):
        result = parseSignatures("\n")

        self.assertEqual(len(result), 0)
Пример #6
0
    def test_parseEmpty(self):
        result = parseSignatures("")

        self.assertEqual(len(result), 0)