Exemplo n.º 1
0
    def test_is_active(self):
        test_cgroup = CpuCgroup("test_extension", self.tmp_dir)
        self.assertEqual(False, test_cgroup.is_active())

        with open(os.path.join(self.tmp_dir, "tasks"), mode="wb") as tasks:
            tasks.write(str(1000).encode())

        self.assertEqual(True, test_cgroup.is_active())
Exemplo n.º 2
0
    def test_is_active_file_not_present(self, patch_periodic_warn):
        test_cgroup = CpuCgroup("test_extension", self.tmp_dir)
        self.assertEqual(False, test_cgroup.is_active())

        test_cgroup = MemoryCgroup(
            "test_extension",
            os.path.join(self.tmp_dir, "this_cgroup_does_not_exist"))
        self.assertEqual(False, test_cgroup.is_active())

        self.assertEqual(0, patch_periodic_warn.call_count)
Exemplo n.º 3
0
 def test_is_active_incorrect_file(self, patch_periodic_warn):
     open(os.path.join(self.tmp_dir, "tasks"), mode="wb").close()
     test_cgroup = CpuCgroup("test_extension",
                             os.path.join(self.tmp_dir, "tasks"))
     self.assertEqual(False, test_cgroup.is_active())
     self.assertEqual(1, patch_periodic_warn.call_count)