def test_to_join(self): join = ("left", "right") self.assertEqual( to_join(join), Join(to_join_key("left"), to_join_key("right"), None, None)) join = ("left", "right", "alias") self.assertEqual( to_join(join), Join(to_join_key("left"), to_join_key("right"), "alias", None)) join = ("left", "right", "alias", "match") self.assertEqual( to_join(join), Join(to_join_key("left"), to_join_key("right"), "alias", "match")) # Dict join = {"master": "left", "detail": "right"} self.assertEqual( to_join(join), Join(to_join_key("left"), to_join_key("right"), None, None)) join = {"master": "left", "detail": "right", "alias": "alias"} self.assertEqual( to_join(join), Join(to_join_key("left"), to_join_key("right"), "alias", None)) join = {"master": "left", "detail": "right", "method": "match"} self.assertEqual( to_join(join), Join(to_join_key("left"), to_join_key("right"), None, "match")) join = { "master": "left", "detail": "right", "alias": "alias", "method": "match" } self.assertEqual( to_join(join), Join(to_join_key("left"), to_join_key("right"), "alias", "match")) # Error with self.assertRaises(ArgumentError): to_join(["left", "right", "detail", "master", "something"]) # Error with self.assertRaises(ArgumentError): to_join(["onlyone"])
def test_to_join(self): join = ("left", "right") self.assertEqual(to_join(join), Join(to_join_key("left"), to_join_key("right"), None, None)) join = ("left", "right", "alias") self.assertEqual(to_join(join), Join(to_join_key("left"), to_join_key("right"), "alias", None)) join = ("left", "right", "alias", "match") self.assertEqual(to_join(join), Join(to_join_key("left"), to_join_key("right"), "alias", "match")) # Dict join = {"master": "left", "detail": "right"} self.assertEqual(to_join(join), Join(to_join_key("left"), to_join_key("right"), None, None)) join = {"master": "left", "detail": "right", "alias": "alias"} self.assertEqual(to_join(join), Join(to_join_key("left"), to_join_key("right"), "alias", None)) join = {"master": "left", "detail": "right", "method": "match"} self.assertEqual(to_join(join), Join(to_join_key("left"), to_join_key("right"), None, "match")) join = {"master": "left", "detail": "right", "alias": "alias", "method": "match"} self.assertEqual(to_join(join), Join(to_join_key("left"), to_join_key("right"), "alias", "match")) # Error with self.assertRaises(ArgumentError): to_join(["left", "right", "detail", "master", "something"]) # Error with self.assertRaises(ArgumentError): to_join(["onlyone"])
def test_to_join_key(self): """Test basic structure conversions.""" self.assertEqual(JoinKey(None, None, None), to_join_key(None)) key = to_join_key("col") self.assertEqual(JoinKey(None, None, "col"), key) key = to_join_key("table.col") self.assertEqual(JoinKey(None, "table", "col"), key) key = to_join_key("schema.table.col") self.assertEqual(JoinKey("schema", "table", "col"), key) key = to_join_key(["col"]) self.assertEqual(JoinKey(None, None, "col"), key) key = to_join_key(["table", "col"]) self.assertEqual(JoinKey(None, "table", "col"), key) key = to_join_key(["schema", "table", "col"]) self.assertEqual(JoinKey("schema", "table", "col"), key) key = to_join_key({"column": "col"}) self.assertEqual(JoinKey(None, None, "col"), key) key = to_join_key({"table": "table", "column": "col"}) self.assertEqual(JoinKey(None, "table", "col"), key) key = to_join_key({ "schema": "schema", "table": "table", "column": "col" }) self.assertEqual(JoinKey("schema", "table", "col"), key) # Test exceptions # with self.assertRaises(ArgumentError): to_join_key([]) with self.assertRaises(ArgumentError): to_join_key(["one", "two", "three", "four"]) with self.assertRaises(ArgumentError): to_join_key("one.two.three.four")
def test_to_join_key(self): """Test basic structure conversions.""" self.assertEqual(JoinKey(None, None, None), to_join_key(None)) key = to_join_key("col") self.assertEqual(JoinKey(None, None, "col"), key) key = to_join_key("table.col") self.assertEqual(JoinKey(None, "table", "col"), key) key = to_join_key("schema.table.col") self.assertEqual(JoinKey("schema", "table", "col"), key) key = to_join_key(["col"]) self.assertEqual(JoinKey(None, None, "col"), key) key = to_join_key(["table", "col"]) self.assertEqual(JoinKey(None, "table", "col"), key) key = to_join_key(["schema", "table", "col"]) self.assertEqual(JoinKey("schema", "table", "col"), key) key = to_join_key({"column": "col"}) self.assertEqual(JoinKey(None, None, "col"), key) key = to_join_key({"table":"table", "column": "col"}) self.assertEqual(JoinKey(None, "table", "col"), key) key = to_join_key({"schema":"schema", "table":"table", "column": "col"}) self.assertEqual(JoinKey("schema", "table", "col"), key) # Test exceptions # with self.assertRaises(ArgumentError): to_join_key([]) with self.assertRaises(ArgumentError): to_join_key(["one", "two", "three", "four"]) with self.assertRaises(ArgumentError): to_join_key("one.two.three.four")