コード例 #1
0
 def test_move_case2(self):
     user = UserModel.get_one_user(self.user)
     case3 = CaseModel.get_one_object(user=user, idx=3)
     case11 = CaseModel.get_one_object(user=user, idx=11)
     case9 = CaseModel.get_one_object(user=user, idx=9)
     case10 = CaseModel.get_one_object(user=user, idx=10)
     case3.move_to(case11)
     case9.move_to(case3)
     self.assertEqual(case10.path, "1/7/11/3/9/")
コード例 #2
0
    def setUp(self):
        super().setUp()

        def load_file(_file):
            with open(_file) as f:
                temp = json.load(f)
            return temp

        self.payload = load_file(INSTANCE_PATH)
        self.payloads = [load_file(f) for f in INSTANCES_LIST]
        parents = [None, 1, 1, 3, 3, 3, 1, 7, 7, 9, 7]
        user = UserModel.get_one_user(self.user)
        data = {**self.payload, **dict(user_id=user.id)}
        for parent in parents:
            if parent is not None:
                parent = CaseModel.get_one_object(user=user, idx=parent)
            node = CaseModel(data=data, parent=parent)
            node.save()
コード例 #3
0
    def test_copy_case(self):
        new_case = self.create_new_row(self.url + str(self.case_id) + "/copy/",
                                       self.model, {},
                                       check_payload=False)
        user = UserModel.get_one_user(self.user)

        original_case = CaseModel.get_one_object(user=user, idx=self.case_id)
        new_case = CaseModel.get_one_object(user=user, idx=new_case["id"])

        for key in self.copied_items:
            self.assertEqual(getattr(original_case, key),
                             getattr(new_case, key))

        for key in self.modified_items:
            self.assertNotEqual(getattr(original_case, key),
                                getattr(new_case, key))
            self.assertEqual("Copy_" + getattr(original_case, key),
                             getattr(new_case, key))

        for key in self.new_items:
            self.assertNotEqual(getattr(original_case, key),
                                getattr(new_case, key))
コード例 #4
0
 def test_depth(self):
     user = UserModel.get_one_user(self.user)
     case10 = CaseModel.get_one_object(user=user, idx=10)
     self.assertEqual(case10.depth, 4)
コード例 #5
0
 def test_descendants(self):
     user = UserModel.get_one_user(self.user)
     case7 = CaseModel.get_one_object(user=user, idx=7)
     self.assertEqual(len(case7.descendants), 4)
コード例 #6
0
 def test_delete_case(self):
     user = UserModel.get_one_user(self.user)
     case7 = CaseModel.get_one_object(user=user, idx=7)
     case7.delete()
     case11 = CaseModel.get_one_object(user=user, idx=11)
     self.assertIsNone(case11)
コード例 #7
0
 def test_move_case(self):
     user = UserModel.get_one_user(self.user)
     case6 = CaseModel.get_one_object(user=user, idx=6)
     case11 = CaseModel.get_one_object(user=user, idx=11)
     case6.move_to(case11)
     self.assertEqual(case6.path, "1/7/11/")
コード例 #8
0
 def test_new_case(self):
     user = UserModel.get_one_user(self.user)
     case = CaseModel.get_one_object(user=user, idx=6)
     self.assertEqual(case.path, "1/3/")
     case = CaseModel.get_one_object(user=user, idx=11)
     self.assertEqual(case.path, "1/7/")