def get_command(self, path, command, arguments=None, queries=None, tag=None, additional_queries=()): arguments = arguments or {} queries = queries or {} command = sentence.CommandSentence(path, command, tag=tag) for key, value in arguments.items(): command.set(key, value) for key, value in queries.items(): command.filter(query.IsEqualQuery(key, value)) for additional_query in additional_queries: command.filter(additional_query) return command
def test_query_sentence_with_tag(self): command = sentence.CommandSentence(b'/interface/', b'print', tag=b'0') command.filter(name=b'wlan0') self.assertEqual(command.get_api_format(), [b'/interface/print', b'?name=wlan0', b'.tag=0'])
def test_login_sentence(self): command = sentence.CommandSentence(b'/', b'login') command.set(b'username', b'admin') self.assertEqual(command.get_api_format(), [b'/login', b'=username=admin'])