def test_construct_invalid_no_validation(self): block = Add(self.block, 2) graph, name = block.get_graph(serialize=True) graph[name] = graph[name][:2] # chop of one arg, making this invalid result = construct(graph, name, validate=False) self.assertEqual(len(result.args), 1) # token is retrieved from the key self.assertEqual(result.token, block.token)
def test_construct_different_token_no_validation(self): # if the graph key is of a valid name format (produced by Block.name), # then that one is used, skipping the generation of new token block = Add(self.block, 2) graph, name = block.get_graph(serialize=True) different_name = "name_1aed3ec7419dadffb050a1274e1c8dc9" graph[different_name] = graph[name] result = construct(graph, different_name, validate=False) self.assertEqual(result.token, "1aed3ec7419dadffb050a1274e1c8dc9")
def test_construct_invalid_token_no_validation(self): # if the graph key is of an invalid name format then a new one is # generated, but a warning is emitted block = Add(self.block, 2) graph, name = block.get_graph(serialize=True) for invalid_name in [ "", "abc", "a_2", "a_xaed3ec7419dadffb050a1274e1c8dc9" ]: graph[invalid_name] = graph[name] with self.assertLogs(level=logging.WARNING): result = construct(graph, invalid_name, validate=False) self.assertEqual(result.token, block.token)
def test_construct_no_validation(self): block = Add(self.block, 2) graph, name = block.get_graph(serialize=True) result = construct(graph, name, validate=False) self.assertEqual(result.token, block.token)
def test_construct(self): block = Add(self.block, 2) graph, name = block.get_graph(serialize=True) result = construct(graph, name) self.assertEqual(result.token, block.token)