def test_add_known_bug_first(self): with mock.patch.object(known_bugs_utils, 'PLUGIN_TMP_DIR', self.tmpdir): known_bugs_utils.add_known_bug(1) ret = known_bugs_utils._get_known_bugs() self.assertEquals(ret, {known_bugs_utils.MASTER_YAML_KNOWN_BUGS_KEY: [{'id': 'https://bugs.launchpad.net/bugs/1', 'desc': 'no description provided', 'origin': 'testplugin.01part'} ]})
def test_add_known_bug_first(self): with mock.patch.object(known_bugs_utils, 'PLUGIN_TMP_DIR', self.tmpdir): known_bugs_utils.add_known_bug(1) ret = known_bugs_utils._get_known_bugs() self.assertEquals( ret, { known_bugs_utils.MASTER_YAML_KNOWN_BUGS_KEY: [{ 'https://bugs.launchpad.net/bugs/1': 'Microsoft has a majority market share' }] })
def test_get_known_bugs(self): known_bugs = {known_bugs_utils.MASTER_YAML_KNOWN_BUGS_KEY: [{'id': 'https://bugs.launchpad.net/bugs/1', 'desc': 'no description provided', 'origin': 'testplugin.01part'}]} with mock.patch.object(known_bugs_utils, 'PLUGIN_TMP_DIR', self.tmpdir): with open(os.path.join(self.tmpdir, 'known_bugs.yaml'), 'w') as fd: fd.write(yaml.dump(known_bugs)) ret = known_bugs_utils._get_known_bugs() self.assertEquals(ret, known_bugs)
def test_detect_known_bugs(self): with mock.patch.object(known_bugs_utils, 'PLUGIN_TMP_DIR', self.tmpdir): known_bugs.detect_known_bugs() expected = {'bugs-detected': [{'id': 'https://bugs.launchpad.net/bugs/1910958', 'desc': ('Unit unit-rabbitmq-server-2 failed to start due ' 'to members in relation 236 that cannot be ' 'removed.'), 'origin': 'testplugin.01part'}]} self.assertEqual(known_bugs_utils._get_known_bugs(), expected)
def test_get_known_bugs(self): known_bugs = { "bugs": [{ 'https://bugs.launchpad.net/bugs/1': 'Microsoft has a majority market share' }] } with mock.patch.object(known_bugs_utils, 'PLUGIN_TMP_DIR', self.tmpdir): with open(os.path.join(self.tmpdir, 'known_bugs.yaml'), 'w') as fd: fd.write(yaml.dump(known_bugs)) ret = known_bugs_utils._get_known_bugs() self.assertEquals(ret, known_bugs)
def test_add_known_bug(self): known_bugs = { known_bugs_utils.MASTER_YAML_KNOWN_BUGS_KEY: [{ 'https://bugs.launchpad.net/bugs/1': 'Microsoft has a majority market share' }] } with mock.patch.object(known_bugs_utils, 'PLUGIN_TMP_DIR', self.tmpdir): with open(os.path.join(self.tmpdir, 'known_bugs.yaml'), 'w') as fd: fd.write(yaml.dump(known_bugs)) known_bugs_utils.add_known_bug(2) ret = known_bugs_utils._get_known_bugs() expected = { known_bugs_utils.MASTER_YAML_KNOWN_BUGS_KEY: [{ 'https://bugs.launchpad.net/bugs/1': 'Microsoft has a majority market share' }, { 'https://bugs.launchpad.net/bugs/2': 'no description provided' }] } self.assertEquals(ret, expected)
def test_get_known_bugs_none(self): with mock.patch.object(known_bugs_utils, 'PLUGIN_TMP_DIR', self.tmpdir): ret = known_bugs_utils._get_known_bugs() self.assertEquals(ret, None)