diff --git a/lbrynet/daemon/DaemonCLI.py b/lbrynet/daemon/DaemonCLI.py index d13ab4fe8..d012cd23d 100644 --- a/lbrynet/daemon/DaemonCLI.py +++ b/lbrynet/daemon/DaemonCLI.py @@ -133,6 +133,8 @@ def main(): def guess_type(x, key=None): if not isinstance(x, (unicode, str)): return x + if key in ('uri', 'channel_name', 'name', 'file_name', 'download_directory'): + return x if x in ('true', 'True', 'TRUE'): return True if x in ('false', 'False', 'FALSE'): @@ -143,8 +145,6 @@ def guess_type(x, key=None): except ValueError: # not a float pass - if key == "uri": - return x try: return int(x) except ValueError: diff --git a/tests/unit/lbrynet_daemon/test_DaemonCLI.py b/tests/unit/lbrynet_daemon/test_DaemonCLI.py index 294ce1410..d21996a9d 100644 --- a/tests/unit/lbrynet_daemon/test_DaemonCLI.py +++ b/tests/unit/lbrynet_daemon/test_DaemonCLI.py @@ -7,7 +7,6 @@ class DaemonCLITests(unittest.TestCase): self.assertEqual('0.3.8', DaemonCLI.guess_type('0.3.8')) self.assertEqual(0.3, DaemonCLI.guess_type('0.3')) self.assertEqual(3, DaemonCLI.guess_type('3')) - self.assertEqual('3', DaemonCLI.guess_type('3', key="uri")) self.assertEqual('VdNmakxFORPSyfCprAD/eDDPk5TY9QYtSA==', DaemonCLI.guess_type('VdNmakxFORPSyfCprAD/eDDPk5TY9QYtSA==')) self.assertEqual(0.3, DaemonCLI.guess_type('0.3')) self.assertEqual(True, DaemonCLI.guess_type('TRUE')) @@ -16,3 +15,16 @@ class DaemonCLITests(unittest.TestCase): self.assertEqual(False, DaemonCLI.guess_type('FALSE')) self.assertEqual(False, DaemonCLI.guess_type('false')) self.assertEqual(False, DaemonCLI.guess_type('False')) + + + self.assertEqual('3', DaemonCLI.guess_type('3', key="uri")) + self.assertEqual('0.3', DaemonCLI.guess_type('0.3', key="uri")) + self.assertEqual('True', DaemonCLI.guess_type('True', key="uri")) + self.assertEqual('False', DaemonCLI.guess_type('False', key="uri")) + + self.assertEqual('3', DaemonCLI.guess_type('3', key="file_name")) + self.assertEqual('3', DaemonCLI.guess_type('3', key="name")) + self.assertEqual('3', DaemonCLI.guess_type('3', key="download_directory")) + self.assertEqual('3', DaemonCLI.guess_type('3', key="channel_name")) + + self.assertEqual(3, DaemonCLI.guess_type('3', key="some_other_thing"))