当前位置: 首页>>代码示例>>Python>>正文


Python User.add_coach方法代码示例

本文整理汇总了Python中user.User.add_coach方法的典型用法代码示例。如果您正苦于以下问题:Python User.add_coach方法的具体用法?Python User.add_coach怎么用?Python User.add_coach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在user.User的用法示例。


在下文中一共展示了User.add_coach方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_limited_infection1

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_coach [as 别名]
 def test_limited_infection1(self):
     a = User('A')
     b = User('B')
     c = User('C')
     d = User('D')
     e = User('E')
     f = User('F')
     e.add_student(f)
     a.add_coach(b)
     b.add_student(c)
     d.add_student(a)
     self.assertEqual(a.get_status(), 'Clean')
     self.assertEqual(b.get_status(), 'Clean')
     self.assertEqual(c.get_status(), 'Clean')
     self.assertEqual(d.get_status(), 'Clean')
     self.assertEqual(e.get_status(), 'Clean')
     self.assertEqual(f.get_status(), 'Clean')
     infections.limited_infection(a, 3)
     self.assertEqual(a.get_status(), 'Infected')
     self.assertEqual(b.get_status(), 'Infected')
     self.assertEqual(c.get_status(), 'Clean')
     self.assertEqual(d.get_status(), 'Infected')
     self.assertEqual(e.get_status(), 'Clean')
     self.assertEqual(f.get_status(), 'Clean')
     infections.limited_infection(f, 0)
     self.assertEqual(e.get_status(), 'Clean')
     self.assertEqual(f.get_status(), 'Clean')
     infections.limited_infection(f, 10)
     self.assertEqual(e.get_status(), 'Infected')
     self.assertEqual(f.get_status(), 'Infected')
开发者ID:chenhoward,项目名称:infections,代码行数:32,代码来源:unit_test.py

示例2: test_total_infection1

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_coach [as 别名]
 def test_total_infection1(self):
     a = User()
     b = User()
     c = User()
     d = User()
     e = User()
     f = User()
     e.add_student(f)
     a.add_coach(b)
     b.add_student(c)
     d.add_student(a)
     self.assertEqual(a.get_status(), 'Clean')
     self.assertEqual(b.get_status(), 'Clean')
     self.assertEqual(c.get_status(), 'Clean')
     self.assertEqual(d.get_status(), 'Clean')
     self.assertEqual(e.get_status(), 'Clean')
     self.assertEqual(f.get_status(), 'Clean')
     infections.total_infection(a)
     self.assertEqual(a.get_status(), 'Infected')
     self.assertEqual(b.get_status(), 'Infected')
     self.assertEqual(c.get_status(), 'Infected')
     self.assertEqual(d.get_status(), 'Infected')
     self.assertEqual(e.get_status(), 'Clean')
     self.assertEqual(f.get_status(), 'Clean')
     infections.total_infection(f)
     self.assertEqual(e.get_status(), 'Infected')
     self.assertEqual(f.get_status(), 'Infected')
开发者ID:chenhoward,项目名称:infections,代码行数:29,代码来源:unit_test.py

示例3: test_exact_infection1

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_coach [as 别名]
 def test_exact_infection1(self):
     a = User('A')
     b = User('B')
     c = User('C')
     d = User('D')
     e = User('E')
     f = User('F')
     user_lst = [a, b, c, d]
     e.add_student(f)
     a.add_coach(b)
     b.add_student(c)
     d.add_student(a)
     self.assertEqual(a.get_status(), 'Clean')
     self.assertEqual(b.get_status(), 'Clean')
     self.assertEqual(c.get_status(), 'Clean')
     self.assertEqual(d.get_status(), 'Clean')
     self.assertEqual(e.get_status(), 'Clean')
     self.assertEqual(f.get_status(), 'Clean')
     result = infections.exact_infection(a, 4)
     self.assertTrue(result)
     infected_count = 0
     for user in user_lst:
         infected_count += user.get_status_num()
     self.assertEqual(infected_count, 4)
     result = infections.exact_infection(f, 10)
     self.assertFalse(result)
     self.assertEqual(e.get_status(), 'Clean')
     self.assertEqual(f.get_status(), 'Clean')
开发者ID:chenhoward,项目名称:infections,代码行数:30,代码来源:unit_test.py

示例4: add_coach

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_coach [as 别名]
    def add_coach(self, other):
        """
        Adds coach to self.coaches and adds an edge for the connection on the graph

        :param other: The coach of self
        :type other: VisualUser
        :return: None
        """
        User.add_coach(self, other)
        other.edges.append(Edge(other.node, self.node, weight=1, stroke=VisualUser.EDGE_COLOR, strokewidth=2))
开发者ID:lemonade512,项目名称:KhanAcademyProject,代码行数:12,代码来源:visual_user.py

示例5: test_user_remove_single_coach

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_coach [as 别名]
    def test_user_remove_single_coach(self):
        """
        Tests removing a coach from a user's coaches
        """
        u1 = User("u1", 1)
        u2 = User("u2", 1)
        u1.add_coach(u2)
        u1.remove_coach(u2)

        self.assertEqual(len(u1.coaches), 0)
        self.assertFalse(u2 in u1.coaches)
        self.assertFalse(u1 in u2.students)
开发者ID:lemonade512,项目名称:KhanAcademyProject,代码行数:14,代码来源:test_user.py

示例6: test_user_add_single_coach

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_coach [as 别名]
    def test_user_add_single_coach(self):
        """
        Tests adding a single coach to a user's coaches
        """
        u1 = User("u1", 1)
        u2 = User("u2", 1)
        u1.add_coach(u2)
        self.assertEqual(len(u1.coaches), 1)
        self.assertTrue(u2 in u1.coaches)

        self.assertEqual(len(u2.students), 1)
        self.assertTrue(u1 in u2.students)
开发者ID:lemonade512,项目名称:KhanAcademyProject,代码行数:14,代码来源:test_user.py

示例7: test_user_add

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_coach [as 别名]
 def test_user_add(self):
     a = User()
     b = User()
     c = User()
     d = User()
     a.add_student(b)
     b.add_coach(c)
     c.add_students([d])
     c.add_students([d])
     self.assertEqual(a.get_num_students(), 1)
     self.assertEqual(c.get_num_students(), 2)
     self.assertEqual(b.get_num_coaches(), 2)
     self.assertEqual(d.get_num_coaches(), 1)
开发者ID:chenhoward,项目名称:infections,代码行数:15,代码来源:unit_test.py

示例8: test_user_double_remove_coach

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_coach [as 别名]
    def test_user_double_remove_coach(self):
        """
        Tests that an error is raised when double removing a coach
        """
        u1 = User("u1", 1)
        u2 = User("u2", 1)
        u1.add_coach(u2)
        u1.remove_coach(u2)
        self.assertRaises(MissingCoachError, u1.remove_coach, u2)

        self.assertEqual(len(u1.coaches), 0)
        self.assertFalse(u1 in u2.students)
        self.assertFalse(u2 in u1.coaches)
开发者ID:lemonade512,项目名称:KhanAcademyProject,代码行数:15,代码来源:test_user.py

示例9: test_user_add_duplicate_coaches

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_coach [as 别名]
    def test_user_add_duplicate_coaches(self):
        """
        Tests that an error is raised when duplicate coaches are added
        """
        u1 = User("u1", 1)
        u2 = User("u2", 1)
        u1.add_coach(u2)
        self.assertRaises(DuplicateCoachError, u1.add_coach, u2)

        self.assertEqual(len(u1.coaches), 1)
        self.assertTrue(u2 in u1.coaches)

        self.assertEqual(len(u2.students), 1)
        self.assertTrue(u1 in u2.students)
开发者ID:lemonade512,项目名称:KhanAcademyProject,代码行数:16,代码来源:test_user.py

示例10: test_user_remove_multiple_coaches_same_name

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_coach [as 别名]
    def test_user_remove_multiple_coaches_same_name(self):
        """
        Tests removing multiple coaches with the same name
        """
        u1 = User("u1", 1)
        u2 = User("u2", 1)
        u3 = User("u2", 1)
        u1.add_coach(u2)
        u1.add_coach(u3)

        u1.remove_coach(u2)
        self.assertEqual(len(u1.coaches), 1)
        self.assertFalse(u2 in u1.coaches)
        self.assertTrue(u3 in u1.coaches)
        self.assertFalse(u1 in u2.students)
        self.assertTrue(u1 in u3.students)
开发者ID:lemonade512,项目名称:KhanAcademyProject,代码行数:18,代码来源:test_user.py

示例11: test_total_infection_rand

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_coach [as 别名]
 def test_total_infection_rand(self):
     users = []
     user_num = 50
     for i in xrange(user_num):
         user = User(i)
         users.append(user)
         coaching = random.randint(0, 1)
         if i:
             related_user = users[random.randint(0, i - 1)]
             if coaching:
                 user.add_student(related_user)
             else:
                 user.add_coach(related_user)
     for user in users:
         self.assertEqual(user.get_status(), 'Clean')
     user = users[random.randint(0, user_num - 1)]
     infections.total_infection(user)
     for user in users:
         self.assertEqual(user.get_status(), 'Infected')
开发者ID:chenhoward,项目名称:infections,代码行数:21,代码来源:unit_test.py

示例12: test_user_add_multiple_coaches

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_coach [as 别名]
    def test_user_add_multiple_coaches(self):
        """
        Tests adding multiple coaches to a user's coaches
        """
        u1 = User("u1", 1)
        u2 = User("u2", 1)
        u3 = User("u3", 1)
        u1.add_coach(u2)
        u1.add_coach(u3)

        self.assertEqual(len(u1.coaches), 2)
        self.assertTrue(u2 in u1.coaches)
        self.assertTrue(u3 in u1.coaches)

        self.assertEqual(len(u2.students), 1)
        self.assertTrue(u1 in u2.students)

        self.assertEqual(len(u3.students), 1)
        self.assertTrue(u1 in u3.students)
开发者ID:lemonade512,项目名称:KhanAcademyProject,代码行数:21,代码来源:test_user.py

示例13: case_1_setup

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_coach [as 别名]
    def case_1_setup(self):
        A = User("A", 1)
        B = User("B", 1)
        C = User("C", 1)
        D = User("D", 1)
        E = User("E", 1)
        F = User("F", 1)
        G = User("G", 1)
        H = User("H", 1)
        I = User("I", 1)
        J = User("J", 1)

        A.add_student(B)
        A.add_student(C)
        A.add_student(D)
        B.add_student(E)
        B.add_student(F)
        C.add_student(F)
        D.add_student(G)

        J.add_coach(H)
        J.add_coach(I)

        network = UserNetwork()
        network.add_user(A)
        network.add_user(B)
        network.add_user(C)
        network.add_user(D)
        network.add_user(E)
        network.add_user(F)
        network.add_user(G)
        network.add_user(H)
        network.add_user(I)
        network.add_user(J)

        return {"A": A, "B": B, "C": C, "D": D, "E": E, "F": F, "G": G,
                "H": H, "I": I, "J": J}, network
开发者ID:lemonade512,项目名称:KhanAcademyProject,代码行数:39,代码来源:test_user_network.py


注:本文中的user.User.add_coach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。