def test_remove(self): n.add_rule("test", "description", "side", "type") result = n.remove_rule("test") self.assertTrue(result) result = n.remove_rule("test2") self.assertFalse(result)
def test_save_load_session(self): n.add_token("description") n.add_token("side", left="L", right="R", middle="M", default="M") n.add_token("type", animation="anim", control="ctrl", joint="jnt", default="ctrl") n.add_rule("test1", "description", "side", "type") n.add_rule("test2", "side", "description") n.set_active_rule("test1") repo = tempfile.mkdtemp() n.save_session(repo) n.flush_rules() n.flush_tokens() n.load_session(repo) self.assertTrue(n.has_token("description")) self.assertTrue(n.has_token("side")) self.assertTrue(n.has_token("type")) self.assertTrue(n.has_rule("test1")) self.assertTrue(n.has_rule("test2")) self.assertEqual(n.active_rule().name(), "test1")
def test_save_load_rule(self): n.add_rule("test", "description", "side", "type") filepath = tempfile.mktemp() n.save_rule("test", filepath) n.flush_rules() n.load_rule(filepath) self.assertTrue(n.has_rule("test"))
def test_has(self): name = "foo" n.add_rule(name, "description", "side", "type") r = n.has_rule(name) self.assertTrue(r) n.remove_rule(name) r = n.has_rule(name) self.assertFalse(r)
def setUp(self): n.flush_tokens() n.add_token("description") n.add_token("side", left="L", right="R", middle="M", default="M") n.add_token("type", animation="anim", control="ctrl", joint="jnt", default="ctrl") n.flush_rules() n.add_rule("test1", "description", "side", "type") n.add_rule("test2", "side", "description") n.set_active_rule("test1")
def test_validation(self): token = n.add_token("side", left="L", right="R", middle="M", default="M") rule = n.add_rule("test", "description", "side", "type") self.assertIsNone(n.Rule.from_data(token.data())) self.assertIsNone(n.Token.from_data(rule.data()))
def test_rules(self): rule1 = n.add_rule("test", "description", "side", "type") rule2 = n.Rule.from_data(rule1.data()) self.assertEqual(rule1.data(), rule2.data())
def test_active(self): name = "foo" n.add_rule(name, "description", "side", "type") r = n.active_rule() self.assertIsNotNone(r)
def test_add(self): result = n.add_rule("test", "description", "side", "type") self.assertTrue(result)