Example #1
0
    def get_enrichment(self):
        try:
            logger = self._logger

            heartbeat_enrichment_set = PanoptesEnrichmentSet(u'heartbeat')
            heartbeat_enrichment_set.add(u'timestamp', time())

            self._heartbeat_enrichment_group.add_enrichment_set(
                heartbeat_enrichment_set)

            self._heartbeat_enrichment_group_set.add_enrichment_group(
                self._heartbeat_enrichment_group)

            logger.debug(
                u'Heartbeat enrichment for host {} PanoptesEnrichmentGroupSet {}'
                .format(self._device_fqdn,
                        self._heartbeat_enrichment_group_set))

            self._heartbeat_enrichment_multi_group_set.add_enrichment_group_set(
                self._heartbeat_enrichment_group_set)

            return self._heartbeat_enrichment_multi_group_set
        except Exception as e:
            raise PanoptesEnrichmentPluginError(
                u'Failed to get heartbeat timestamp enrichment for the host "%s": %s'
                % (self._device_fqdn, repr(e)))
    def test_panoptes_enrichment_group(self):
        interface_validation_object = PanoptesEnrichmentInterfaceSchemaValidator(
        )
        enrichment_group1 = PanoptesEnrichmentGroup(
            'interface', interface_validation_object, 300, 60)
        self.assertEquals(enrichment_group1.enrichment_schema,
                          PanoptesEnrichmentInterfaceSchemaValidator.schema)
        self.assertEquals(
            repr(enrichment_group1),
            "PanoptesEnrichmentGroup({{'data': set([]), "
            "'namespace': 'interface', "
            "'metadata': {{"
            "'_enrichment_group_creation_timestamp': {:.5f}, "
            "'_enrichment_ttl': 300, "
            "'_execute_frequency': 60}}}})".format(mock_time.return_value))

        enrichment_set1 = PanoptesEnrichmentSet('int_001')
        enrichment_set1.add('speed', 1000)
        enrichment_set1.add('index', 001)
        enrichment_set1.add('status', 'up')

        self.assertFalse(enrichment_group1 == enrichment_set1)

        enrichment_group2 = PanoptesEnrichmentGroup(
            'interface', interface_validation_object, 300, 60)
        enrichment_group3 = PanoptesEnrichmentGroup(
            'other_namespace', interface_validation_object, 300, 60)
        self.assertTrue(enrichment_group1 == enrichment_group2)
        self.assertFalse(enrichment_group1 == enrichment_group3)
    def test_enrichment_set(self):
        enrichment_set = PanoptesEnrichmentSet('int_001')
        enrichment_set.add('speed', 1000)
        enrichment_set.add('index', 001)
        enrichment_set.add('status', 'up')
        self.assertEquals(enrichment_set.key, 'int_001')
        self.assertDictEqual(enrichment_set.value, {
            'status': 'up',
            'index': 1,
            'speed': 1000
        })
        self.assertEquals(len(enrichment_set), 3)

        enrichment_set1 = PanoptesEnrichmentSet('int_002', {
            'status': 'down',
            'index': 2,
            'speed': 1000
        })
        self.assertEquals(enrichment_set1.key, 'int_002')
        self.assertDictEqual(enrichment_set1.value, {
            'status': 'down',
            'index': 2,
            'speed': 1000
        })

        with self.assertRaises(AssertionError):
            PanoptesEnrichmentSet('int_001', 'string')

        with self.assertRaises(AssertionError):
            PanoptesEnrichmentSet('int_001', 100)
    def test_enrichment_schema_validator(self):
        validator = PanoptesEnrichmentInterfaceSchemaValidator()
        enrichment_set = PanoptesEnrichmentSet('int_001')
        enrichment_set.add('speed', 1000)
        enrichment_set.add('index', 001)
        enrichment_set.add('status', 'up')
        self.assertTrue(validator.validate(enrichment_set))

        enrichment_set.add('status', 01)
        self.assertFalse(validator.validate(enrichment_set))
    def test_panoptes_enrichment_set(self):
        enrichment_set1 = PanoptesEnrichmentSet('int_001')
        enrichment_set1.add('speed', 1000)
        enrichment_set1.add('index', 001)
        enrichment_set1.add('status', 'up')
        self.assertEquals(
            enrichment_set1.json(),
            '{"int_001": {"index": 1, "speed": 1000, "status": "up"}}')
        self.assertEquals(
            repr(enrichment_set1),
            "PanoptesEnrichmentSet({'int_001': {'status': 'up', 'index': 1, 'speed': 1000}})"
        )

        enrichment_set2 = PanoptesEnrichmentSet('int_002')
        enrichment_set2.add('speed', 1000)
        enrichment_set2.add('index', 002)
        enrichment_set2.add('status', 'down')

        interface_validation_object = PanoptesEnrichmentInterfaceSchemaValidator(
        )
        enrichment_group1 = PanoptesEnrichmentGroup(
            'interface', interface_validation_object, 300, 60)

        self.assertFalse(enrichment_set1 == enrichment_group1)
        self.assertFalse(enrichment_set1 == enrichment_set2)
Example #6
0
    def _construct_flat_schema_entry(self, enrichment_group):

        if enrichment_group.enrichment_schema[u'enrichment_label'][
                u'type'] != u'dict':
            return None

        enrichment = PanoptesEnrichmentSet(key=u'enrichment_label')

        for key, value in list(
                enrichment_group.enrichment_schema[u'enrichment_label']
            [u'schema'].items()):
            validator_type = value[u'type']

            if type(validator_type) is list:
                enrichment.add(key, types[value[u'type'][0]](key))

            elif type(validator_type) is str:
                enrichment.add(key, types[value[u'type']](key))

        return enrichment
Example #7
0
    def test_panoptes_enrichment_group(self):
        interface_validation_object = PanoptesEnrichmentInterfaceSchemaValidator()
        enrichment_group1 = PanoptesEnrichmentGroup(u'interface', interface_validation_object, 300, 60)
        self.assertEquals(enrichment_group1.enrichment_schema, PanoptesEnrichmentInterfaceSchemaValidator.schema)

        self.assertEquals(repr(enrichment_group1), u"PanoptesEnrichmentGroup[namespace:interface,"
                                                   u"enrichment_ttl:300,execute_frequency:60,"
                                                   u"enrichment_group_creation_timestamp:{}]".format(
                                                    mock_time.return_value))

        enrichment_set1 = PanoptesEnrichmentSet(u'int_001')
        enrichment_set1.add(u'speed', 1000)
        enrichment_set1.add(u'index', 0o01)
        enrichment_set1.add(u'status', u'up')

        self.assertFalse(enrichment_group1 == enrichment_set1)

        enrichment_group2 = PanoptesEnrichmentGroup(u'interface', interface_validation_object, 300, 60)
        enrichment_group3 = PanoptesEnrichmentGroup(u'other_namespace', interface_validation_object, 300, 60)
        self.assertTrue(enrichment_group1 == enrichment_group2)
        self.assertFalse(enrichment_group1 == enrichment_group3)
Example #8
0
    def test_panoptes_enrichment_set(self):
        enrichment_set1 = PanoptesEnrichmentSet(u'int_001')
        enrichment_set1.add(u'speed', 1000)
        enrichment_set1.add(u'index', 0o01)
        enrichment_set1.add(u'status', u'up')
        self.assertEquals(enrichment_set1.json(),
                          u'{"int_001": {"index": 1, "speed": 1000, "status": "up"}}')
        self.assertEquals(repr(enrichment_set1),
                          u"PanoptesEnrichmentSet[int_001[index:1,speed:1000,status:up]]")

        enrichment_set2 = PanoptesEnrichmentSet(u'int_002')
        enrichment_set2.add(u'speed', 1000)
        enrichment_set2.add(u'index', 0o02)
        enrichment_set2.add(u'status', u'down')

        interface_validation_object = PanoptesEnrichmentInterfaceSchemaValidator()
        enrichment_group1 = PanoptesEnrichmentGroup(u'interface', interface_validation_object, 300, 60)

        self.assertFalse(enrichment_set1 == enrichment_group1)
        self.assertFalse(enrichment_set1 == enrichment_set2)
Example #9
0
    def setUp(self):
        self.my_dir, self.panoptes_test_conf_file = _get_test_conf_file()
        self._panoptes_context = PanoptesContext(self.panoptes_test_conf_file,
                                                 key_value_store_class_list=[PanoptesEnrichmentCacheKeyValueStore,
                                                                             PanoptesResourcesKeyValueStore])

        self._enrichment_kv = self._panoptes_context.get_kv_store(PanoptesEnrichmentCacheKeyValueStore)

        self._panoptes_resource = PanoptesResource(resource_site=u'test_site',
                                                   resource_class=u'test_class',
                                                   resource_subclass=u'test_subclass',
                                                   resource_type=u'test_type',
                                                   resource_id=u'test_resource_id',
                                                   resource_endpoint=u'test_endpoint',
                                                   resource_plugin=u'test_plugin')

        interface_validation_object = PanoptesEnrichmentInterfaceSchemaValidator()
        neighbor_validation_object = PanoptesEnrichmentNeighborSchemaValidator()

        enrichment_set1 = PanoptesEnrichmentSet(u'int_001')
        enrichment_set1.add(u'speed', 1000)
        enrichment_set1.add(u'index', 0o01)
        enrichment_set1.add(u'status', u'up')

        enrichment_set2 = PanoptesEnrichmentSet(u'int_002')
        enrichment_set2.add(u'speed', 1000)
        enrichment_set2.add(u'index', 0o02)
        enrichment_set2.add(u'status', u'down')

        enrichment_group1 = PanoptesEnrichmentGroup(u'interface', interface_validation_object, 300, 60)
        enrichment_group1.add_enrichment_set(enrichment_set1)
        enrichment_group1.add_enrichment_set(enrichment_set2)

        enrichment_set3 = PanoptesEnrichmentSet(u'host_name')
        enrichment_set3.add(u'vlan_id', 501)
        enrichment_set3.add(u'property', u'Test Property')
        enrichment_set3.add(u'mac', u'aa:bb:cc:dd:ee:ff')

        enrichment_group2 = PanoptesEnrichmentGroup(u'neighbor', neighbor_validation_object, 600, 120)
        enrichment_group2.add_enrichment_set(enrichment_set3)

        self.enrichment_group_set1 = PanoptesEnrichmentGroupSet(self._panoptes_resource)
        self.enrichment_group_set1.add_enrichment_group(enrichment_group1)
        self.enrichment_group_set1.add_enrichment_group(enrichment_group2)

        self._panoptes_resource01 = PanoptesResource(resource_site=u'test_site',
                                                     resource_class=u'test_class',
                                                     resource_subclass=u'test_subclass',
                                                     resource_type=u'test_type',
                                                     resource_id=u'test_resource_id01',
                                                     resource_endpoint=u'test_endpoint01',
                                                     resource_plugin=u'test_plugin')

        enrichment_set4 = PanoptesEnrichmentSet(u'host_name01')
        enrichment_set4.add(u'vlan_id', 502)
        enrichment_set4.add(u'property', u'Test Property')
        enrichment_set4.add(u'mac', u'aa:bb:cc:dd:ee:ff')

        enrichment_group3 = PanoptesEnrichmentGroup(u'neighbor', neighbor_validation_object, 600, 120)
        enrichment_group3.add_enrichment_set(enrichment_set3)
        enrichment_group3.add_enrichment_set(enrichment_set4)

        self.enrichment_group_set2 = PanoptesEnrichmentGroupSet(self._panoptes_resource01)
        self.enrichment_group_set2.add_enrichment_group(enrichment_group1)
        self.enrichment_group_set2.add_enrichment_group(enrichment_group3)

        self._multi_enrichment_group_set = PanoptesEnrichmentMultiGroupSet()
        self._multi_enrichment_group_set.add_enrichment_group_set(self.enrichment_group_set1)
        self._multi_enrichment_group_set.add_enrichment_group_set(self.enrichment_group_set2)
Example #10
0
    def test_multi_enrichment_group_set(self):
        interface_validation_object = PanoptesEnrichmentInterfaceSchemaValidator()
        neighbor_validation_object = PanoptesEnrichmentNeighborSchemaValidator()

        panoptes_resource = self.__panoptes_resource

        multi_enrichment_results_data = \
            {
                "group_sets": [
                    {
                        "enrichment": [
                            {
                                "data": [
                                    {
                                        "host_name": {
                                            "mac": "aa:bb:cc:dd:ee:ff",
                                            "property": "Test Property",
                                            "vlan_id": 501
                                        }
                                    },
                                    {
                                        "host_name01": {
                                            "mac": "aa:bb:cc:dd:ee:ff",
                                            "property": "Test Property",
                                            "vlan_id": 502
                                        }
                                    }
                                ],
                                "metadata": {
                                    "_enrichment_group_creation_timestamp": mock_time.return_value,
                                    "_enrichment_ttl": 600,
                                    "_execute_frequency": 120
                                },
                                "namespace": "neighbor"
                            },
                            {
                                "data": [
                                    {
                                        "int_001": {
                                            "index": 1,
                                            "speed": 1000,
                                            "status": "up"
                                        }
                                    }
                                ],
                                "metadata": {
                                    "_enrichment_group_creation_timestamp": mock_time.return_value,
                                    "_enrichment_ttl": 300,
                                    "_execute_frequency": 60
                                },
                                "namespace": "interface"
                            }
                        ],
                        "enrichment_group_set_creation_timestamp": mock_time.return_value,
                        "resource": {
                            "resource_class": "test_class",
                            "resource_creation_timestamp": mock_time.return_value,
                            "resource_endpoint": "test_endpoint01",
                            "resource_id": "test_resource_id01",
                            "resource_metadata": {
                                "_resource_ttl": "604800"
                            },
                            "resource_plugin": "test_plugin",
                            "resource_site": "test_site",
                            "resource_subclass": "test_subclass",
                            "resource_type": "test_type"
                        }
                    },
                    {
                        "enrichment": [
                            {
                                "data": [
                                    {
                                        "int_001": {
                                            "index": 1,
                                            "speed": 1000,
                                            "status": "up"
                                        }
                                    }
                                ],
                                "metadata": {
                                    "_enrichment_group_creation_timestamp": mock_time.return_value,
                                    "_enrichment_ttl": 300,
                                    "_execute_frequency": 60
                                },
                                "namespace": "interface"
                            },
                            {
                                "data": [
                                    {
                                        "host_name": {
                                            "mac": "aa:bb:cc:dd:ee:ff",
                                            "property": "Test Property",
                                            "vlan_id": 501
                                        }
                                    }
                                ],
                                "metadata": {
                                    "_enrichment_group_creation_timestamp": mock_time.return_value,
                                    "_enrichment_ttl": 600,
                                    "_execute_frequency": 120
                                },
                                "namespace": "neighbor"
                            }
                        ],
                        "enrichment_group_set_creation_timestamp": mock_time.return_value,
                        "resource": {
                            "resource_class": "test",
                            "resource_creation_timestamp": mock_time.return_value,
                            "resource_endpoint": "test",
                            "resource_id": "test",
                            "resource_metadata": {
                                "_resource_ttl": "604800",
                                "test": "test"
                            },
                            "resource_plugin": "test",
                            "resource_site": "test",
                            "resource_subclass": "test",
                            "resource_type": "test"
                        }
                    }
                ]
            }

        enrichment_set1 = PanoptesEnrichmentSet(u'int_001')
        enrichment_set1.add(u'speed', 1000)
        enrichment_set1.add(u'index', 0o01)
        enrichment_set1.add(u'status', u'up')

        enrichment_group1 = PanoptesEnrichmentGroup(u'interface', interface_validation_object, 300, 60)
        enrichment_group1.add_enrichment_set(enrichment_set1)

        enrichment_set3 = PanoptesEnrichmentSet(u'host_name')
        enrichment_set3.add(u'vlan_id', 501)
        enrichment_set3.add(u'property', u'Test Property')
        enrichment_set3.add(u'mac', u'aa:bb:cc:dd:ee:ff')

        enrichment_group2 = PanoptesEnrichmentGroup(u'neighbor', neighbor_validation_object, 600, 120)
        enrichment_group2.add_enrichment_set(enrichment_set3)

        enrichment_group_set1 = PanoptesEnrichmentGroupSet(panoptes_resource)
        enrichment_group_set1.add_enrichment_group(enrichment_group1)
        enrichment_group_set1.add_enrichment_group(enrichment_group2)

        panoptes_resource01 = PanoptesResource(resource_site=u'test_site',
                                               resource_class=u'test_class',
                                               resource_subclass=u'test_subclass',
                                               resource_type=u'test_type',
                                               resource_id=u'test_resource_id01',
                                               resource_endpoint=u'test_endpoint01',
                                               resource_plugin=u'test_plugin')

        panoptes_resource02 = PanoptesResource(resource_site=u'test_site',
                                               resource_class=u'test_class',
                                               resource_subclass=u'test_subclass',
                                               resource_type=u'test_type',
                                               resource_id=u'test_resource_id02',
                                               resource_endpoint=u'test_endpoint02',
                                               resource_plugin=u'test_plugin')

        enrichment_set4 = PanoptesEnrichmentSet(u'host_name01')
        enrichment_set4.add(u'vlan_id', 502)
        enrichment_set4.add(u'property', u'Test Property')
        enrichment_set4.add(u'mac', u'aa:bb:cc:dd:ee:ff')

        enrichment_group3 = PanoptesEnrichmentGroup(u'neighbor', neighbor_validation_object, 600, 120)
        enrichment_group3.add_enrichment_set(enrichment_set3)
        enrichment_group3.add_enrichment_set(enrichment_set4)

        enrichment_group_set2 = PanoptesEnrichmentGroupSet(panoptes_resource01)
        enrichment_group_set2.add_enrichment_group(enrichment_group1)
        enrichment_group_set2.add_enrichment_group(enrichment_group3)

        multi_enrichment_group_set = PanoptesEnrichmentMultiGroupSet()
        multi_enrichment_group_set.add_enrichment_group_set(enrichment_group_set1)
        multi_enrichment_group_set.add_enrichment_group_set(enrichment_group_set2)

        multi_enrichment_group_set_repr = u"PanoptesEnrichmentMultiGroupSet[PanoptesEnrichmentGroupSet[resource:" \
                                          u"plugin|test|site|test|class|test|subclass|test|type|test|id|test|endpoint" \
                                          u"|test,enrichment_group_set_creation_timestamp:{},PanoptesEnrichmentGroup" \
                                          u"[namespace:interface,enrichment_ttl:300,execute_frequency:60," \
                                          u"enrichment_group_creation_timestamp:{},PanoptesEnrichmentSet[" \
                                          u"int_001[index:1,speed:1000,status:up]]],PanoptesEnrichmentGroup[" \
                                          u"namespace:neighbor,enrichment_ttl:600,execute_frequency:120," \
                                          u"enrichment_group_creation_timestamp:{},PanoptesEnrichmentSet" \
                                          u"[host_name[mac:aa:bb:cc:dd:ee:ff,property:Test Property,vlan_id:501]" \
                                          u"]]],PanoptesEnrichmentGroupSet[resource:plugin|test_plugin|site|" \
                                          u"test_site|class|test_class|subclass|test_subclass|type|test_type|id" \
                                          u"|test_resource_id01|endpoint|test_endpoint01," \
                                          u"enrichment_group_set_creation_timestamp:{},PanoptesEnrichmentGroup" \
                                          u"[namespace:interface,enrichment_ttl:300,execute_frequency:60," \
                                          u"enrichment_group_creation_timestamp:{},PanoptesEnrichmentSet" \
                                          u"[int_001[index:1,speed:1000,status:up]]],PanoptesEnrichmentGroup" \
                                          u"[namespace:neighbor,enrichment_ttl:600,execute_frequency:120," \
                                          u"enrichment_group_creation_timestamp:{},PanoptesEnrichmentSet" \
                                          u"[host_name[mac:aa:bb:cc:dd:ee:ff,property:Test Property,vlan_id:501]]," \
                                          u"PanoptesEnrichmentSet[host_name01[mac:aa:bb:cc:dd:ee:ff," \
                                          u"property:Test Property,vlan_id:502]]]]]".format(mock_time.return_value,
                                                                                            mock_time.return_value,
                                                                                            mock_time.return_value,
                                                                                            mock_time.return_value,
                                                                                            mock_time.return_value,
                                                                                            mock_time.return_value)

        self.assertEquals(repr(multi_enrichment_group_set), multi_enrichment_group_set_repr)

        self.assertEquals(len(multi_enrichment_group_set.enrichment_group_sets), 2)

        self.assertEquals(ordered(json.loads(multi_enrichment_group_set.json())),
                          ordered(multi_enrichment_results_data))

        self.assertEquals(len(multi_enrichment_group_set), 2)

        multi_enrichment_group_set.add_enrichment_group_set(enrichment_group_set2)
        self.assertEquals(len(multi_enrichment_group_set), 2)

        enrichment_group_set3 = PanoptesEnrichmentGroupSet(panoptes_resource02)
        enrichment_group_set3.add_enrichment_group(enrichment_group1)
        multi_enrichment_group_set.add_enrichment_group_set(enrichment_group_set3)
        self.assertEquals(len(multi_enrichment_group_set), 3)

        with self.assertRaises(AssertionError):
            multi_enrichment_group_set.add_enrichment_group_set(u'non_enrichment_group')

        enrichment_group_set3 = PanoptesEnrichmentGroupSet(panoptes_resource01)
        with self.assertRaises(AssertionError):
            multi_enrichment_group_set.add_enrichment_group_set(enrichment_group_set3)
Example #11
0
    def test_enrichment_group_set(self):
        interface_validation_object = PanoptesEnrichmentInterfaceSchemaValidator()
        neighbor_validation_object = PanoptesEnrichmentNeighborSchemaValidator()

        panoptes_resource = self.__panoptes_resource

        enrichment_data = \
            u'''{{"enrichment": [{{"metadata": {{"_enrichment_group_creation_timestamp": {:.5f}, "_enrichment_ttl": 600,
            "_execute_frequency": 120}}, "data": [{{"host_name":
            {{"mac": "aa:bb:cc:dd:ee:ff", "property": "Test Property", "vlan_id": 501}}}}],
            "namespace": "neighbor"}}, {{"metadata": {{"_enrichment_group_creation_timestamp": {:.5f},
            "_enrichment_ttl": 300,
            "_execute_frequency": 60}}, "data": [
            {{"int_001": {{"index": 1, "speed": 1000, "status": "up"}}}}, {{"int_002": {{"index": 2, "speed": 1000,
            "status": "down"}}}}], "namespace": "interface"}}],
            "enrichment_group_set_creation_timestamp": {:.5f}, "resource": {{"resource_class": "test",
            "resource_creation_timestamp": {:.5f}, "resource_endpoint": "test", "resource_id": "test",
            "resource_metadata": {{"_resource_ttl": "604800", "test": "test"}}, "resource_plugin": "test",
            "resource_site": "test",
            "resource_subclass": "test", "resource_type": "test"}}}}'''.format(mock_time.return_value,
                                                                               mock_time.return_value,
                                                                               mock_time.return_value,
                                                                               mock_time.return_value)

        enrichment_set1 = PanoptesEnrichmentSet(u'int_001')
        enrichment_set1.add(u'speed', 1000)
        enrichment_set1.add(u'index', 0o01)
        enrichment_set1.add(u'status', u'up')

        enrichment_set2 = PanoptesEnrichmentSet(u'int_002')
        enrichment_set2.add(u'speed', 1000)
        enrichment_set2.add(u'index', 0o02)
        enrichment_set2.add(u'status', u'down')

        enrichment_group1 = PanoptesEnrichmentGroup(u'interface', interface_validation_object, 300, 60)
        enrichment_group1.add_enrichment_set(enrichment_set1)
        enrichment_group1.add_enrichment_set(enrichment_set2)

        enrichment_set3 = PanoptesEnrichmentSet(u'host_name')
        enrichment_set3.add(u'vlan_id', 501)
        enrichment_set3.add(u'property', u'Test Property')
        enrichment_set3.add(u'mac', u'aa:bb:cc:dd:ee:ff')

        enrichment_group2 = PanoptesEnrichmentGroup(u'neighbor', neighbor_validation_object, 600, 120)
        enrichment_group2.add_enrichment_set(enrichment_set3)

        enrichment_group_set1 = PanoptesEnrichmentGroupSet(panoptes_resource)
        enrichment_group_set1.add_enrichment_group(enrichment_group1)
        enrichment_group_set1.add_enrichment_group(enrichment_group2)
        self.assertEquals(len(enrichment_group_set1), 2)

        group_set_repr = u"PanoptesEnrichmentGroupSet[resource:" \
                         u"plugin|test|site|test|class|test|subclass|test|type|test|id|test|endpoint|test," \
                         u"enrichment_group_set_creation_timestamp:{},PanoptesEnrichmentGroup[namespace:" \
                         u"interface,enrichment_ttl:300,execute_frequency:60,enrichment_group_creation_timestamp:{}," \
                         u"PanoptesEnrichmentSet[int_001[index:1,speed:1000,status:up]],PanoptesEnrichmentSet[" \
                         u"int_002[index:2,speed:1000,status:down]]],PanoptesEnrichmentGroup[namespace:neighbor," \
                         u"enrichment_ttl:600,execute_frequency:120,enrichment_group_creation_timestamp:{}," \
                         u"PanoptesEnrichmentSet[host_name[mac:aa:bb:cc:dd:ee:ff,property:" \
                         u"Test Property,vlan_id:501]]]]".format(mock_time.return_value,
                                                                 mock_time.return_value,
                                                                 mock_time.return_value)

        self.assertEquals(repr(enrichment_group_set1), group_set_repr)

        self.assertIsInstance(enrichment_group_set1.resource, PanoptesResource)
        self.assertEqual(enrichment_group_set1.enrichment_group_set_creation_timestamp, mock_time.return_value)

        self.assertEqual(
            ordered(json.loads(json.dumps(enrichment_group_set1.enrichment, cls=PanoptesEnrichmentEncoder))),
            ordered(json.loads(enrichment_data)[u'enrichment']))

        self.assertEqual(ordered(json.loads(enrichment_group_set1.json())[u'enrichment']),
                         ordered(json.loads(enrichment_data)[u'enrichment']))

        with self.assertRaises(AssertionError):
            PanoptesEnrichmentGroupSet(u'bad_resource')

        with self.assertRaises(AssertionError):
            PanoptesEnrichmentGroupSet(panoptes_resource).add_enrichment_group(u'non_PanoptesEnrichmentGroup_obj')

        enrichment_group_set2 = PanoptesEnrichmentGroupSet(panoptes_resource)
        enrichment_group3 = PanoptesEnrichmentGroup(u'interface', interface_validation_object, 300, 60)

        with self.assertRaises(AssertionError):
            enrichment_group_set2.add_enrichment_group(enrichment_group3)

        self.assertFalse(enrichment_group_set1 == enrichment_group1)
        self.assertFalse(enrichment_group_set1 == enrichment_group_set2)
Example #12
0
    def test_enrichment_group(self):
        interface_validation_object = PanoptesEnrichmentInterfaceSchemaValidator()
        neighbor_validation_object = PanoptesEnrichmentNeighborSchemaValidator()

        interface_data = \
            u'''{"data": [
            {"int_001": {"index": 1, "speed": 1000, "status": "up"}},
            {"int_002": {"index": 2, "speed": 1000, "status": "down"}}],
            "metadata": {"_enrichment_group_creation_timestamp": %f, "_enrichment_ttl": 300, "_execute_frequency": 60},
            "namespace": "interface"}''' % mock_time.return_value

        neighbor_data = \
            u'''{"data": [{"host_name": {"mac": "aa:bb:cc:dd:ee:ff", "property": "Test Property", "vlan_id": 501}}],
            "metadata": {"_enrichment_group_creation_timestamp": %f, "_enrichment_ttl": 600, "_execute_frequency": 120},
            "namespace": "neighbor"}''' % mock_time.return_value

        with self.assertRaises(AssertionError):
            PanoptesEnrichmentGroup(1, interface_validation_object, 300, 60)

        with self.assertRaises(AssertionError):
            PanoptesEnrichmentGroup(u'interface', u'non_validation_object', 300, 60)

        with self.assertRaises(AssertionError):
            PanoptesEnrichmentGroup(u'interface', interface_validation_object, u'300', 60)

        with self.assertRaises(AssertionError):
            PanoptesEnrichmentGroup(u'interface', interface_validation_object, 300, u'60')

        with self.assertRaises(AssertionError):
            PanoptesEnrichmentGroup(u'interface', interface_validation_object, 0, 60)

        with self.assertRaises(AssertionError):
            PanoptesEnrichmentGroup(u'interface', interface_validation_object, 300, 0)

        with self.assertRaises(AssertionError):
            PanoptesEnrichmentGroup(u'interface', interface_validation_object, 300, 60).\
                add_enrichment_set(u'not_PanoptesEnrichmentSet_obj')

        enrichment_set1 = PanoptesEnrichmentSet(u'int_001')
        enrichment_set1.add(u'speed', 1000)
        enrichment_set1.add(u'index', 0o01)
        enrichment_set1.add(u'status', u'up')

        enrichment_set2 = PanoptesEnrichmentSet(u'int_002')
        enrichment_set2.add(u'speed', 1000)
        enrichment_set2.add(u'index', 0o02)
        enrichment_set2.add(u'status', u'down')

        enrichment_group1 = PanoptesEnrichmentGroup(u'interface', interface_validation_object, 300, 60)
        enrichment_group1.add_enrichment_set(enrichment_set1)
        enrichment_group1.add_enrichment_set(enrichment_set2)

        self.assertEqual(enrichment_group1.namespace, u'interface')
        self.assertEqual(enrichment_group1.enrichment_ttl, 300)
        self.assertEqual(enrichment_group1.execute_frequency, 60)
        self.assertEqual(enrichment_group1.enrichment_group_creation_timestamp, mock_time.return_value)
        self.assertEqual(ordered(json.loads(json.dumps(enrichment_group1.data, cls=PanoptesEnrichmentEncoder))),
                         ordered(json.loads(interface_data)[u'data']))
        self.assertEqual(ordered(json.loads(enrichment_group1.json())), ordered(json.loads(interface_data)))
        self.assertEquals(len(enrichment_group1), 2)

        enrichment_set3 = PanoptesEnrichmentSet(u'int_002')
        enrichment_set3.add(u'speed', 1000)
        enrichment_set3.add(u'index', 0o02)
        enrichment_set3.add(u'status', u'down')

        self.assertEqual(ordered(json.loads(enrichment_group1.json())), ordered(json.loads(interface_data)))
        self.assertEqual(ordered(enrichment_group1.metadata), ordered(json.loads(interface_data)[u'metadata']))
        self.assertEquals(len(enrichment_group1), 2)

        test_metadata = json.loads(interface_data)[u'metadata']
        test_metadata[u'metadata_key'] = u'metadata_value'

        enrichment_group1.upsert_metadata(u'metadata_key', u'metadata_value')
        self.assertEqual(ordered(enrichment_group1.metadata), ordered(test_metadata))
        enrichment_group1.upsert_metadata(u'ttl', 300)
        with self.assertRaises(ValueError):
            enrichment_group1.upsert_metadata(u'_enrichment_ttl', 300)
        with self.assertRaises(AssertionError):
            enrichment_group1.upsert_metadata(u'metadata', {})
        with self.assertRaises(AssertionError):
            enrichment_group1.upsert_metadata(u'metadata', [])

        enrichment_set4 = PanoptesEnrichmentSet(u'host_name')
        enrichment_set4.add(u'vlan_id', 501)
        enrichment_set4.add(u'property', u'Test Property')
        enrichment_set4.add(u'mac', u'aa:bb:cc:dd:ee:ff')

        enrichment_group2 = PanoptesEnrichmentGroup(u'neighbor', neighbor_validation_object, 600, 120)
        enrichment_group2.add_enrichment_set(enrichment_set4)

        self.assertEqual(ordered(json.loads(enrichment_group2.json())), ordered(json.loads(neighbor_data)))
        self.assertEquals(len(enrichment_group2), 1)

        enrichment_set5 = PanoptesEnrichmentSet(u'host_name01')
        enrichment_set5.add(u'vlan_id', 502)
        enrichment_set5.add(u'property', u'Netops01.US')

        enrichment_set6 = PanoptesEnrichmentSet(u'host_name02')
        enrichment_set6.add(u'vlan_id', 503)
        enrichment_set6.add(u'mac', u'aa:bb:cc:dd:ee:ff')

        enrichment_group3 = PanoptesEnrichmentGroup(u'neighbor', neighbor_validation_object, 600, 120)
        enrichment_group3.add_enrichment_set(enrichment_set5)
        with self.assertRaises(AssertionError):
            enrichment_group3.add_enrichment_set(enrichment_set6)

        interface_store_data = u'{"int_001": {"index": 1, "speed": 1000, "status": "up"}, ' \
                               u'"int_002": {"index": 2, "speed": 1000, "status": "down"}}'

        neighbor_store_data = u'{"host_name": {"mac": "aa:bb:cc:dd:ee:ff", ' \
                              u'"property": "Test Property", "vlan_id": 501}}'

        self.assertEquals(ordered(json.loads(enrichment_group1.serialize_data())),
                          ordered(json.loads(interface_store_data)))
        self.assertEquals(ordered(json.loads(enrichment_group2.serialize_data())),
                          ordered(json.loads(neighbor_store_data)))

        enrichment_group1.upsert_metadata(u'ttl', 300)
        with self.assertRaises(ValueError):
            enrichment_group1.upsert_metadata(u'_enrichment_ttl', 300)

        interface_data_serialized = u'''{{"data": {{"int_001": {{"index": 1, "speed": 1000, "status": "up"}},
        "int_002": {{"index": 2, "speed": 1000, "status": "down"}}}}, "metadata":
        {{"_enrichment_group_creation_timestamp": {:.5f}, "_enrichment_ttl": 300, "_execute_frequency": 60,
        "metadata_key": "metadata_value", "ttl": 300}}}}'''.format(mock_time.return_value)

        neighbor_data_serialized = u'''{{"data": {{"host_name": {{"mac": "aa:bb:cc:dd:ee:ff", "property":
        "Test Property","vlan_id": 501}}}}, "metadata": {{"_enrichment_group_creation_timestamp": {:.5f},
        "_enrichment_ttl": 600, "_execute_frequency": 120}}}}'''.format(mock_time.return_value)

        self.assertEquals(ordered(json.loads(enrichment_group1.serialize())),
                          ordered(json.loads(interface_data_serialized)))

        self.assertEquals(ordered(json.loads(enrichment_group2.serialize())),
                          ordered(json.loads(neighbor_data_serialized)))
    def test_multi_enrichment_group_set(self):
        interface_validation_object = PanoptesEnrichmentInterfaceSchemaValidator(
        )
        neighbor_validation_object = PanoptesEnrichmentNeighborSchemaValidator(
        )

        panoptes_resource = self.__panoptes_resource

        multi_enrichment_results_data = \
            {
                "group_sets": [
                    {
                        "enrichment": [
                            {
                                "data": [
                                    {
                                        "host_name": {
                                            "mac": "aa:bb:cc:dd:ee:ff",
                                            "property": "Test Property",
                                            "vlan_id": 501
                                        }
                                    },
                                    {
                                        "host_name01": {
                                            "mac": "aa:bb:cc:dd:ee:ff",
                                            "property": "Test Property",
                                            "vlan_id": 502
                                        }
                                    }
                                ],
                                "metadata": {
                                    "_enrichment_group_creation_timestamp": mock_time.return_value,
                                    "_enrichment_ttl": 600,
                                    "_execute_frequency": 120
                                },
                                "namespace": "neighbor"
                            },
                            {
                                "data": [
                                    {
                                        "int_001": {
                                            "index": 1,
                                            "speed": 1000,
                                            "status": "up"
                                        }
                                    }
                                ],
                                "metadata": {
                                    "_enrichment_group_creation_timestamp": mock_time.return_value,
                                    "_enrichment_ttl": 300,
                                    "_execute_frequency": 60
                                },
                                "namespace": "interface"
                            }
                        ],
                        "enrichment_group_set_creation_timestamp": mock_time.return_value,
                        "resource": {
                            "resource_class": "test_class",
                            "resource_creation_timestamp": mock_time.return_value,
                            "resource_endpoint": "test_endpoint01",
                            "resource_id": "test_resource_id01",
                            "resource_metadata": {
                                "_resource_ttl": "604800"
                            },
                            "resource_plugin": "test_plugin",
                            "resource_site": "test_site",
                            "resource_subclass": "test_subclass",
                            "resource_type": "test_type"
                        }
                    },
                    {
                        "enrichment": [
                            {
                                "data": [
                                    {
                                        "int_001": {
                                            "index": 1,
                                            "speed": 1000,
                                            "status": "up"
                                        }
                                    }
                                ],
                                "metadata": {
                                    "_enrichment_group_creation_timestamp": mock_time.return_value,
                                    "_enrichment_ttl": 300,
                                    "_execute_frequency": 60
                                },
                                "namespace": "interface"
                            },
                            {
                                "data": [
                                    {
                                        "host_name": {
                                            "mac": "aa:bb:cc:dd:ee:ff",
                                            "property": "Test Property",
                                            "vlan_id": 501
                                        }
                                    }
                                ],
                                "metadata": {
                                    "_enrichment_group_creation_timestamp": mock_time.return_value,
                                    "_enrichment_ttl": 600,
                                    "_execute_frequency": 120
                                },
                                "namespace": "neighbor"
                            }
                        ],
                        "enrichment_group_set_creation_timestamp": mock_time.return_value,
                        "resource": {
                            "resource_class": "test",
                            "resource_creation_timestamp": mock_time.return_value,
                            "resource_endpoint": "test",
                            "resource_id": "test",
                            "resource_metadata": {
                                "_resource_ttl": "604800",
                                "test": "test"
                            },
                            "resource_plugin": "test",
                            "resource_site": "test",
                            "resource_subclass": "test",
                            "resource_type": "test"
                        }
                    }
                ]
            }

        enrichment_set1 = PanoptesEnrichmentSet('int_001')
        enrichment_set1.add('speed', 1000)
        enrichment_set1.add('index', 001)
        enrichment_set1.add('status', 'up')

        enrichment_group1 = PanoptesEnrichmentGroup(
            'interface', interface_validation_object, 300, 60)
        enrichment_group1.add_enrichment_set(enrichment_set1)

        enrichment_set3 = PanoptesEnrichmentSet('host_name')
        enrichment_set3.add('vlan_id', 501)
        enrichment_set3.add('property', 'Test Property')
        enrichment_set3.add('mac', 'aa:bb:cc:dd:ee:ff')

        enrichment_group2 = PanoptesEnrichmentGroup(
            'neighbor', neighbor_validation_object, 600, 120)
        enrichment_group2.add_enrichment_set(enrichment_set3)

        enrichment_group_set1 = PanoptesEnrichmentGroupSet(panoptes_resource)
        enrichment_group_set1.add_enrichment_group(enrichment_group1)
        enrichment_group_set1.add_enrichment_group(enrichment_group2)

        panoptes_resource01 = PanoptesResource(
            resource_site='test_site',
            resource_class='test_class',
            resource_subclass='test_subclass',
            resource_type='test_type',
            resource_id='test_resource_id01',
            resource_endpoint='test_endpoint01',
            resource_plugin='test_plugin')

        panoptes_resource02 = PanoptesResource(
            resource_site='test_site',
            resource_class='test_class',
            resource_subclass='test_subclass',
            resource_type='test_type',
            resource_id='test_resource_id02',
            resource_endpoint='test_endpoint02',
            resource_plugin='test_plugin')

        enrichment_set4 = PanoptesEnrichmentSet('host_name01')
        enrichment_set4.add('vlan_id', 502)
        enrichment_set4.add('property', 'Test Property')
        enrichment_set4.add('mac', 'aa:bb:cc:dd:ee:ff')

        enrichment_group3 = PanoptesEnrichmentGroup(
            'neighbor', neighbor_validation_object, 600, 120)
        enrichment_group3.add_enrichment_set(enrichment_set3)
        enrichment_group3.add_enrichment_set(enrichment_set4)

        enrichment_group_set2 = PanoptesEnrichmentGroupSet(panoptes_resource01)
        enrichment_group_set2.add_enrichment_group(enrichment_group1)
        enrichment_group_set2.add_enrichment_group(enrichment_group3)

        multi_enrichment_group_set = PanoptesEnrichmentMultiGroupSet()
        multi_enrichment_group_set.add_enrichment_group_set(
            enrichment_group_set1)
        multi_enrichment_group_set.add_enrichment_group_set(
            enrichment_group_set2)

        multi_enrichment_group_set_repr = \
            "PanoptesEnrichmentMultiGroupSet({{'group_sets': set([PanoptesEnrichmentGroupSet({{" \
            "'enrichment_group_set_creation_timestamp': {:.5f}, 'resource': plugin|test_plugin|" \
            "site|test_site|class|test_class|subclass|test_subclass|type|test_type|id|test_resource_id01|" \
            "endpoint|test_endpoint01, 'enrichment': set([PanoptesEnrichmentGroup({{'data': set([" \
            "PanoptesEnrichmentSet({{'int_001': {{'status': 'up', 'index': 1, 'speed': 1000}}}})]), " \
            "'namespace': 'interface', 'metadata': {{'_enrichment_group_creation_timestamp': {:.5f}, " \
            "'_enrichment_ttl': 300, '_execute_frequency': 60}}}}), PanoptesEnrichmentGroup({{" \
            "'data': set([PanoptesEnrichmentSet({{'host_name': {{" \
            "'mac': 'aa:bb:cc:dd:ee:ff', 'property': 'Test Property', " \
            "'vlan_id': 501}}}}), PanoptesEnrichmentSet({{'host_name01': {{'mac': 'aa:bb:cc:dd:ee:ff', " \
            "'property': 'Test Property', 'vlan_id': 502}}}})]), 'namespace': 'neighbor', 'metadata': {{" \
            "'_enrichment_group_creation_timestamp': {:.5f}, '_enrichment_ttl': 600, " \
            "'_execute_frequency': 120}}}})])}}), PanoptesEnrichmentGroupSet({{" \
            "'enrichment_group_set_creation_timestamp': {:.5f}, 'resource': plugin|test|site|test|" \
            "class|test|subclass|test|type|test|id|test|endpoint|test, 'enrichment': set([PanoptesEnrichmentGroup({{" \
            "'data': set([PanoptesEnrichmentSet({{'int_001': {{'status': 'up', 'index': 1, 'speed': 1000}}}})]), " \
            "'namespace': 'interface', 'metadata': {{'_enrichment_group_creation_timestamp': {:.5f}, " \
            "'_enrichment_ttl': 300, '_execute_frequency': 60}}}}), PanoptesEnrichmentGroup({{'data': set([" \
            "PanoptesEnrichmentSet({{'host_name': {{'mac': 'aa:bb:cc:dd:ee:ff', 'property': 'Test Property', " \
            "'vlan_id': 501}}}})]), 'namespace': 'neighbor', 'metadata': {{'_enrichment_group_creation_timestamp': " \
            "{:.5f}, '_enrichment_ttl': 600, '_execute_frequency': 120}}}})])}})])}})".format(
                mock_time.return_value,
                mock_time.return_value,
                mock_time.return_value,
                mock_time.return_value,
                mock_time.return_value,
                mock_time.return_value)

        self.assertEquals(repr(multi_enrichment_group_set),
                          multi_enrichment_group_set_repr)

        self.assertEquals(
            len(multi_enrichment_group_set.enrichment_group_sets), 2)

        self.assertEquals(
            ordered(json.loads(multi_enrichment_group_set.json())),
            ordered(multi_enrichment_results_data))

        self.assertEquals(len(multi_enrichment_group_set), 2)

        multi_enrichment_group_set.add_enrichment_group_set(
            enrichment_group_set2)
        self.assertEquals(len(multi_enrichment_group_set), 2)

        enrichment_group_set3 = PanoptesEnrichmentGroupSet(panoptes_resource02)
        enrichment_group_set3.add_enrichment_group(enrichment_group1)
        multi_enrichment_group_set.add_enrichment_group_set(
            enrichment_group_set3)
        self.assertEquals(len(multi_enrichment_group_set), 3)

        with self.assertRaises(AssertionError):
            multi_enrichment_group_set.add_enrichment_group_set(
                'non_enrichment_group')

        enrichment_group_set3 = PanoptesEnrichmentGroupSet(panoptes_resource01)
        with self.assertRaises(AssertionError):
            multi_enrichment_group_set.add_enrichment_group_set(
                enrichment_group_set3)
    def test_enrichment_group_set(self):
        interface_validation_object = PanoptesEnrichmentInterfaceSchemaValidator(
        )
        neighbor_validation_object = PanoptesEnrichmentNeighborSchemaValidator(
        )

        panoptes_resource = self.__panoptes_resource

        enrichment_data = \
            '''{{"enrichment": [{{"metadata": {{"_enrichment_group_creation_timestamp": {:.5f}, "_enrichment_ttl": 600,
            "_execute_frequency": 120}}, "data": [{{"host_name":
            {{"mac": "aa:bb:cc:dd:ee:ff", "property": "Test Property", "vlan_id": 501}}}}],
            "namespace": "neighbor"}}, {{"metadata": {{"_enrichment_group_creation_timestamp": {:.5f},
            "_enrichment_ttl": 300,
            "_execute_frequency": 60}}, "data": [
            {{"int_001": {{"index": 1, "speed": 1000, "status": "up"}}}}, {{"int_002": {{"index": 2, "speed": 1000,
            "status": "down"}}}}], "namespace": "interface"}}],
            "enrichment_group_set_creation_timestamp": {:.5f}, "resource": {{"resource_class": "test",
            "resource_creation_timestamp": {:.5f}, "resource_endpoint": "test", "resource_id": "test",
            "resource_metadata": {{"_resource_ttl": "604800", "test": "test"}}, "resource_plugin": "test",
            "resource_site": "test",
            "resource_subclass": "test", "resource_type": "test"}}}}'''.format(mock_time.return_value,
                                                                               mock_time.return_value,
                                                                               mock_time.return_value,
                                                                               mock_time.return_value)

        enrichment_set1 = PanoptesEnrichmentSet('int_001')
        enrichment_set1.add('speed', 1000)
        enrichment_set1.add('index', 001)
        enrichment_set1.add('status', 'up')

        enrichment_set2 = PanoptesEnrichmentSet('int_002')
        enrichment_set2.add('speed', 1000)
        enrichment_set2.add('index', 002)
        enrichment_set2.add('status', 'down')

        enrichment_group1 = PanoptesEnrichmentGroup(
            'interface', interface_validation_object, 300, 60)
        enrichment_group1.add_enrichment_set(enrichment_set1)
        enrichment_group1.add_enrichment_set(enrichment_set2)

        enrichment_set3 = PanoptesEnrichmentSet('host_name')
        enrichment_set3.add('vlan_id', 501)
        enrichment_set3.add('property', 'Test Property')
        enrichment_set3.add('mac', 'aa:bb:cc:dd:ee:ff')

        enrichment_group2 = PanoptesEnrichmentGroup(
            'neighbor', neighbor_validation_object, 600, 120)
        enrichment_group2.add_enrichment_set(enrichment_set3)

        enrichment_group_set1 = PanoptesEnrichmentGroupSet(panoptes_resource)
        enrichment_group_set1.add_enrichment_group(enrichment_group1)
        enrichment_group_set1.add_enrichment_group(enrichment_group2)
        self.assertEquals(len(enrichment_group_set1), 2)
        group_set_repr = "PanoptesEnrichmentGroupSet({{'enrichment_group_set_creation_timestamp': {:.5f}, " \
                         "'resource': plugin|test|site|test|class|test|subclass|test" \
                         "|type|test|id|test|endpoint|test, " \
                         "'enrichment': set([PanoptesEnrichmentGroup({{'data': set([PanoptesEnrichmentSet({{" \
                         "'int_001': {{'status': 'up', 'index': 1, 'speed': 1000}}}}), " \
                         "PanoptesEnrichmentSet({{'int_002': {{'status': 'down', 'index': 2, 'speed': 1000}}}})]), " \
                         "'namespace': 'interface', 'metadata': " \
                         "{{'_enrichment_group_creation_timestamp': {:.5f}, '_enrichment_ttl': 300, " \
                         "'_execute_frequency': 60}}}}), PanoptesEnrichmentGroup({{" \
                         "'data': set([PanoptesEnrichmentSet(" \
                         "{{'host_name': {{" \
                         "'mac': 'aa:bb:cc:dd:ee:ff', 'property': 'Test Property', 'vlan_id': 501}}}})]), " \
                         "'namespace': 'neighbor', 'metadata': {{'_enrichment_group_creation_timestamp': " \
                         "{:.5f}, '_enrichment_ttl': 600, " \
                         "'_execute_frequency': 120}}}})])}})".format(mock_time.return_value,
                                                                      mock_time.return_value,
                                                                      mock_time.return_value)
        self.assertEquals(repr(enrichment_group_set1), group_set_repr)

        self.assertIsInstance(enrichment_group_set1.resource, PanoptesResource)
        self.assertEqual(
            enrichment_group_set1.enrichment_group_set_creation_timestamp,
            mock_time.return_value)

        self.assertEqual(
            ordered(
                json.loads(
                    json.dumps(enrichment_group_set1.enrichment,
                               cls=PanoptesEnrichmentEncoder))),
            ordered(json.loads(enrichment_data)['enrichment']))

        self.assertEqual(
            ordered(json.loads(enrichment_group_set1.json())['enrichment']),
            ordered(json.loads(enrichment_data)['enrichment']))

        with self.assertRaises(AssertionError):
            PanoptesEnrichmentGroupSet('bad_resource')

        with self.assertRaises(AssertionError):
            PanoptesEnrichmentGroupSet(panoptes_resource).add_enrichment_group(
                'non_PanoptesEnrichmentGroup_obj')

        enrichment_group_set2 = PanoptesEnrichmentGroupSet(panoptes_resource)
        enrichment_group3 = PanoptesEnrichmentGroup(
            'interface', interface_validation_object, 300, 60)

        with self.assertRaises(AssertionError):
            enrichment_group_set2.add_enrichment_group(enrichment_group3)

        self.assertFalse(enrichment_group_set1 == enrichment_group1)
        self.assertFalse(enrichment_group_set1 == enrichment_group_set2)