コード例 #1
0
 def test_add_parent(self):
     """Can Add Parent to Root Task"""
     root = Task("Root Task")
     pm = ProjMan(root)
     parent = Task("Parent Task")
     pm.add_parent(parent)
     self.assertIn(parent, root.prerequisites)
コード例 #2
0
 def test_add_child2(self):
     """PM Adding a child implies root is a parent for the child"""
     root = Task("Root Task")
     pm = ProjMan(root)
     child = Task("Child Task")
     pm.add_child(child)
     self.assertIn(root, child.prerequisites)
コード例 #3
0
 def test_append_duplicate_dep(self):
     """Test appending duplicate dependants to a task, it should be unique"""
     root = Task("Root Task")
     child = Task("Child Task")
     root.append_dependant(child)
     root.append_dependant(child)
     self.assertNotEqual(2, len(root.dependants))
コード例 #4
0
 def test_add_parent_rebase2(self):
     """Adding Parent to root Task, Makes former root a child to parent"""
     root = Task("Root Task")
     pm = ProjMan(root)
     parent = Task("Parent Task")
     pm.add_parent(parent)
     self.assertIn(root, pm.root.dependants)
コード例 #5
0
 def test_add_parent_rebase1(self):
     """Adding Parent to root Task, Rebase Root to Parent"""
     root = Task("Root Task")
     pm = ProjMan(root)
     parent = Task("Parent Task")
     pm.add_parent(parent)
     self.assertEqual(parent, pm.root)
コード例 #6
0
 def test_add_child(self):
     """PM Can add a child"""
     root = Task("Root Task")
     pm = ProjMan(root)
     child = Task("Child Task")
     pm.add_child(child)
     self.assertIn(child, root.dependants)
コード例 #7
0
 def test_append_duplicate_prereq(self):
     """Test appending duplicate prerequisites to a task, it should be unique"""
     root = Task("Root Task")
     parent = Task("Parent Task")
     root.append_prerequisite(parent)
     root.append_prerequisite(parent)
     self.assertNotEqual(2, len(root.prerequisites))
コード例 #8
0
 def test_planned_dates(self):
     """Define planned start date"""
     expected = datetime(year=2017, month=11, day=30)
     planned = TimeElement()
     planned.start = expected
     t = Task("Sample Task")
     t.planned = planned
     self.assertEqual(expected, t.planned.start)
コード例 #9
0
 def test_actual_dates(self):
     """Define actual start date"""
     expected = datetime(year=2017, month=11, day=30)
     actual = TimeElement()
     actual.start = expected
     t = Task("Sample Task")
     t.actual = actual
     self.assertEqual(expected, t.actual.start)
コード例 #10
0
 def test_append_prereq(self):
     """
     Create a Task
     Create another task and append it to prerequisites of first task
     """
     target = Task()
     prereq = Task()
     target.prerequisites.append(prereq)
     self.assertIn(prereq, target.prerequisites)
コード例 #11
0
 def test_append_dependants(self):
     """
     Create a Task
     Create a second task
     Append second task to first task's list of dependants
     """
     target = Task()
     dep = Task()
     target.append_dependant(dep)
     self.assertIn(dep, target.dependants)
コード例 #12
0
 def test_dependants(self):
     """
     Create a task
     Create a set of tasks
     set set of tasks as dependants of the first task
     """
     target = Task()
     dependants = []
     for i in range(10):
         d = Task("Sub-task {}".format(i))
         dependants.append(d)
     target.dependants = dependants
     self.assertEqual(dependants, target.dependants)
コード例 #13
0
 def test_prerequisites(self):
     """
     Create a list of tasks
     Create a single task
     Assign list of tasks to the single task
     """
     target = Task()
     prereqs = []
     for i in range(10):
         p = Task("Super-task {}".format(i))
         prereqs.append(p)
     target.prerequisites = prereqs
     self.assertEqual(prereqs, target.prerequisites)
コード例 #14
0
    def test_list_tasks_duplicates(self):
        """Listing all tasks in a project, no duplicates"""
        # Create Root
        root = Task("Root Task")
        # Create Project
        pm = ProjMan(root)
        # Append Children
        child1 = Task("Child Task 1")
        pm.add_child(child1)

        child2 = Task("Child Task 2")
        pm.add_child(child2)

        task_list = pm.list_tasks()
        self.assertEqual(3, len(task_list))
コード例 #15
0
    def test_list_tasks(self):
        """Listing all tasks in a project"""
        # Create Root
        root = Task("Root Task")
        # Create Project
        pm = ProjMan(root)
        # Append Children
        child1 = Task("Child Task 1")
        pm.add_child(child1)

        child2 = Task("Child Task 2")
        pm.add_child(child2)

        task_list = pm.list_tasks()
        self.assertTrue(
            root in task_list and
            child1 in task_list and
            child2 in task_list)
コード例 #16
0
 def test_first(self):
     stat = ProjStats()
     first = Task("First")
     stat.first = first
     self.assertEqual(first, stat.first)
コード例 #17
0
 def test_completed(self):
     """Test Task completion percentage"""
     t = Task()
     expected = 0.5
     t.completed = expected
     self.assertEqual(expected, t.completed)
コード例 #18
0
 def test_id(self):
     """Check if Task ID has UUID Version 4"""
     t = Task()
     expected = 4
     self.assertEqual(expected, t.id.version)
コード例 #19
0
ファイル: sand_box.py プロジェクト: burhania2/PyProjMan
# Scrap Paper File to try different Things

# Test How to build a task variable
from PyProjManCore.task import Task

root = Task("Root Task")

# Define 3 Layers of tasks
# Layer 1
l1a = Task("Prerequisite a, Layer 1")
l1b = Task("Prerequisite b, Layer 1")
root.append_prerequisite(l1a)
root.append_prerequisite(l1a)
root.append_prerequisite(l1b)
# Layer 2
l2a = Task("Prerequisite a, Layer 2")
l2b = Task("Prerequisite b, Layer 2")
l1a.append_prerequisite(l2a)
l1a.append_prerequisite(l2b)
l2c = Task("Prerequisite c, Layer 2")
l2d = Task("Prerequisite d, Layer 2")
l1b.append_prerequisite(l2c)
l1b.append_prerequisite(l2d)
# Layer 3
l3a = Task("Prerequisite a, Layer 3")
l2a.append_prerequisite(l3a)
l2b.append_prerequisite(l3a)
l3b = Task("Prerequisite b, Layer 3")
l2a.append_prerequisite(l3b)
# Assign each layer the layer over it as a prerequisite
コード例 #20
0
 def test_root(self):
     """Can create a new project with a root Task"""
     root = Task("Root Task")
     pm = ProjMan(root)
     self.assertEqual(root, pm.root)
コード例 #21
0
 def test_last(self):
     stat = ProjStats()
     last = Task("Last")
     stat.first = last
     self.assertEqual(last, stat.first)
コード例 #22
0
 def test_name(self):
     """Test Task Name Property Setter and Getter"""
     expected = 'Task'
     t = Task(expected)
     t.name = expected
     self.assertEqual(t.name, expected, t.name)