'Check we can run command based artifacts and get anomalies.'

def testCmdArtifact(self):

    client_mock = self.MockClient(standard.ExecuteCommand, client_id=self.client_id)
    with utils.Stubber(subprocess, 'Popen', client_test_lib.Popen):
        for _ in flow_test_lib.TestFlowHelper(collectors.ArtifactCollectorFlow.__name__, client_mock, client_id=self.client_id, store_results_in_aff4=True, use_tsk=False, artifact_list=['TestCmdArtifact'], token=self.token):
            pass
    urn = self.client_id.Add('info/software')
    fd = aff4.FACTORY.Open(urn, token=self.token)
    packages = fd.Get(fd.Schema.INSTALLED_PACKAGES)
    self.assertEqual(len(packages), 2)
    self.assertEqual(packages[0].__class__.__name__, 'SoftwarePackage')
    anomaly_coll = aff4_grr.VFSGRRClient.AnomalyCollectionForCID(self.client_id, token=self.token)
    self.assertEqual(len(anomaly_coll), 1)
    self.assertTrue(('gremlin' in anomaly_coll[0].symptom))
