Beispiel #1
0
    def test_multi_register(self):
        basic = Util.parse_schema_from_string(data_gen.BASIC_SCHEMA)
        adv = Util.parse_schema_from_string(data_gen.ADVANCED_SCHEMA)
        subject = 'test'
        client = self.client

        id1 = client.register(subject, basic)
        latest1 = client.get_latest_schema(subject)
        v1 = client.get_version(subject, basic)
        self.assertLatest(latest1, id1, basic, v1)

        id2 = client.register(subject, adv)
        latest2 = client.get_latest_schema(subject)
        v2 = client.get_version(subject, adv)
        self.assertLatest(latest2, id2, adv, v2)

        self.assertNotEqual(id1, id2)
        self.assertNotEqual(latest1, latest2)
        # ensure version is higher
        self.assertTrue(latest1[2] < latest2[2])

        client.register(subject, basic)
        latest3 = client.get_latest_schema(subject)
        # latest should not change with a re-reg
        self.assertEqual(latest2, latest3)
Beispiel #2
0
    def test_multi_subject_register(self):
        parsed = Util.parse_schema_from_string(data_gen.BASIC_SCHEMA)
        client = self.client
        schema_id = client.register('test', parsed)
        self.assertTrue(schema_id > 0)

        # register again under different subject
        dupe_id = client.register('other', parsed)
        self.assertEqual(schema_id, dupe_id)
        self.assertEqual(len(client.id_to_schema), 1)
 def _get_schema_from_body(self, req):
     length = int(req.headers['content-length'])
     data = req.rfile.read(length)
     data = json.loads(data)
     schema = data.get("schema", None)
     if not schema:
         return None
     try:
         avro_schema = Util.parse_schema_from_string(schema)
         return self._get_identity_schema(avro_schema)
     except:
         return None
Beispiel #4
0
    def test_dupe_register(self):
        parsed = Util.parse_schema_from_string(data_gen.BASIC_SCHEMA)
        subject = 'test'
        client = self.client
        schema_id = client.register(subject, parsed)
        self.assertTrue(schema_id > 0)
        latest = client.get_latest_schema(subject)

        # register again under same subject
        dupe_id = client.register(subject, parsed)
        self.assertEqual(schema_id, dupe_id)
        dupe_latest = client.get_latest_schema(subject)
        self.assertEqual(latest, dupe_latest)
Beispiel #5
0
    def test_getters(self):
        parsed = Util.parse_schema_from_string(data_gen.BASIC_SCHEMA)
        client = self.client
        subject = 'test'
        version = client.get_version(subject, parsed)
        self.assertEqual(version, -1)
        schema = client.get_by_id(1)
        self.assertEqual(schema, None)
        latest = client.get_latest_schema(subject)
        self.assertEqual(latest, (None, None, None))

        # register
        schema_id = client.register(subject, parsed)
        latest = client.get_latest_schema(subject)
        version = client.get_version(subject, parsed)
        self.assertLatest(latest, schema_id, parsed, version)

        fetched = client.get_by_id(schema_id)
        self.assertEqual(fetched, parsed)
Beispiel #6
0
 def test_register(self):
     parsed = Util.parse_schema_from_string(data_gen.BASIC_SCHEMA)
     client = self.client
     schema_id = client.register('test', parsed)
     self.assertTrue(schema_id > 0)
     self.assertEqual(len(client.id_to_schema), 1)
 def test_schema_from_string(self):
     parsed = Util.parse_schema_from_string(data_gen.BASIC_SCHEMA)
     self.assertTrue(isinstance(parsed, schema.Schema))
 def test_schema_from_file(self):
     parsed = Util.parse_schema_from_file(
         data_gen.get_schema_path('adv_schema.avsc'))
     self.assertTrue(isinstance(parsed, schema.Schema))