Beispiel #1
0
 def test_temp_dir_parent(self):
     with temp_dir() as p:
         with temp_dir(parent=p) as d:
             self.assertTrue(os.path.isdir(d))
             self.assertEqual(p, os.path.dirname(d))
         self.assertFalse(os.path.exists(d))
     self.assertFalse(os.path.exists(p))
 def test_temp_dir_parent(self):
     with temp_dir() as p:
         with temp_dir(parent=p) as d:
             self.assertTrue(os.path.isdir(d))
             self.assertEqual(p, os.path.dirname(d))
         self.assertFalse(os.path.exists(d))
     self.assertFalse(os.path.exists(p))
 def test_temp_dir_keep(self):
     with temp_dir() as p:
         with temp_dir(parent=p, keep=True) as d:
             self.assertTrue(os.path.isdir(d))
             open(os.path.join(d, "a-file"), "w").close()
         self.assertTrue(os.path.exists(d))
         self.assertTrue(os.path.exists(os.path.join(d, "a-file")))
     self.assertFalse(os.path.exists(p))
Beispiel #4
0
 def test_temp_dir_keep(self):
     with temp_dir() as p:
         with temp_dir(parent=p, keep=True) as d:
             self.assertTrue(os.path.isdir(d))
             open(os.path.join(d, "a-file"), "w").close()
         self.assertTrue(os.path.exists(d))
         self.assertTrue(os.path.exists(os.path.join(d, "a-file")))
     self.assertFalse(os.path.exists(p))
 def test_temp_dir(self):
     with temp_dir() as temp:
         temp_file = os.path.join(temp, 'foo')
         open(temp_file, "w").close()
         self.assertTrue(os.path.isdir(temp))
         self.assertTrue(os.path.exists(temp_file))
         self.assertIn('cwr-tmp', temp)
     self.assertFalse(os.path.exists(temp))
Beispiel #6
0
 def test_temp_dir(self):
     with temp_dir() as temp:
         temp_file = os.path.join(temp, 'foo')
         open(temp_file, "w").close()
         self.assertTrue(os.path.isdir(temp))
         self.assertTrue(os.path.exists(temp_file))
         self.assertIn('cwr-tmp', temp)
     self.assertFalse(os.path.exists(temp))
Beispiel #7
0
    def test_remove_test_by_bundle_name(self):
        index_json = {
            "providers": [
                "GCE"
            ],
            "reports": [
                {
                    "bundle_name": "foo",
                    "date": "2017-12-06T21:15:56",
                    "results": {
                        "AWS": "FAIL"
                    },
                    "test_id": "11",
                    "test_label": None,
                    "url": None,
                },
                {
                    "bundle_name": "bar",
                    "date": "2017-11-15T17:44:01",
                    "results": {
                        "Azure": "NONE"
                    },
                    "test_id": "22",
                    "test_label": None,
                    "url": None,
                }

            ]

        }
        with temp_dir() as results_dir:
            full_index = os.path.join(
                results_dir,  model.ReportIndex.full_index_filename_json)
            args = run.parse_args(
                ['aws', 'test_plan', '--remove-test', 'foo', "--results-dir",
                 results_dir])
            with open(full_index, 'w') as f:
                json.dump(index_json, f)
            runner = run.Runner(None, False, args)
            runner.remove_test_by_bundle_name()
            with open(full_index) as f:
                result_index = json.load(f)
            self.assertEqual(len(result_index["reports"]), 1)
            self.assertEqual(result_index["reports"][0]["bundle_name"], "bar")
            os.path.isfile(model.ReportIndex.full_index_filename_html)
            os.path.isfile(model.ReportIndex.summary_filename_html)
            os.path.isfile(model.ReportIndex.summary_filename_json)
 def test_temp_tmpdir(self):
     with temp_dir() as tmp:
         with patch('cloudweatherreport.utils.temp_dir', autosec=True
                    ) as md_mock:
             md_mock.return_value.__enter__.return_value = tmp
             old_tmpdir = gettempdir()
             with temp_tmpdir():
                 self.assertEqual(tmp, gettempdir())
                 f = NamedTemporaryFile(delete=False)
                 self.assertEqual(os.path.dirname(f.name), tmp)
                 self.assertTrue(os.path.exists(
                     os.path.join(tmp, os.path.basename(f.name))))
                 d = mkdtemp()
                 self.assertTrue(os.path.exists(
                     os.path.join(tmp, os.path.basename(d))))
     self.assertFalse(os.path.exists(tmp))
     self.assertEqual(old_tmpdir, gettempdir())
Beispiel #9
0
 def test_temp_tmpdir(self):
     with temp_dir() as tmp:
         with patch('cloudweatherreport.utils.temp_dir',
                    autosec=True) as md_mock:
             md_mock.return_value.__enter__.return_value = tmp
             old_tmpdir = gettempdir()
             with temp_tmpdir():
                 self.assertEqual(tmp, gettempdir())
                 f = NamedTemporaryFile(delete=False)
                 self.assertEqual(os.path.dirname(f.name), tmp)
                 self.assertTrue(
                     os.path.exists(
                         os.path.join(tmp, os.path.basename(f.name))))
                 d = mkdtemp()
                 self.assertTrue(
                     os.path.exists(os.path.join(tmp, os.path.basename(d))))
     self.assertFalse(os.path.exists(tmp))
     self.assertEqual(old_tmpdir, gettempdir())
 def test_remove_test_by_bundle_name(self):
     index_json = {
         "providers": ["GCE"],
         "reports": [{
             "bundle_name": "foo",
             "date": "2017-12-06T21:15:56",
             "results": {
                 "AWS": "FAIL"
             },
             "test_id": "11",
             "test_label": None,
             "url": None,
         }, {
             "bundle_name": "bar",
             "date": "2017-11-15T17:44:01",
             "results": {
                 "Azure": "NONE"
             },
             "test_id": "22",
             "test_label": None,
             "url": None,
         }]
     }
     with temp_dir() as results_dir:
         full_index = os.path.join(
             results_dir, model.ReportIndex.full_index_filename_json)
         args = run.parse_args([
             'aws', 'test_plan', '--remove-test', 'foo', "--results-dir",
             results_dir
         ])
         with open(full_index, 'w') as f:
             json.dump(index_json, f)
         runner = run.Runner(None, False, args)
         runner.remove_test_by_bundle_name()
         with open(full_index) as f:
             result_index = json.load(f)
         self.assertEqual(len(result_index["reports"]), 1)
         self.assertEqual(result_index["reports"][0]["bundle_name"], "bar")
         os.path.isfile(model.ReportIndex.full_index_filename_html)
         os.path.isfile(model.ReportIndex.summary_filename_html)
         os.path.isfile(model.ReportIndex.summary_filename_json)