def testSplitLongCommandExampleLineActuallyShort(self): example = """\ $ gcloud compute instances list --verbosity=info\ """ expected = example actual = markdown.ExampleCommandLineSplitter().Split(example) self.assertEqual(expected, actual)
def testgSplitLongCommandExampleLineWithNestedQuotes(self): example = """\ $ gcloud beta logging write LOG_NAME extra args '{"key": "value"}' --payload-type=struct\ """ expected = """\ $ gcloud beta logging write LOG_NAME extra args '{"key": "value"}' \\ --payload-type=struct\ """ actual = markdown.ExampleCommandLineSplitter().Split(example) self.assertEqual(expected, actual)
def testSplitLongCommandExampleLineWithFlags(self): example = """\ $ gcloud compute instances list --verbosity=info --format=json --xyz abc --abc=xyz\ """ expected = """\ $ gcloud compute instances list --verbosity=info --format=json \\ --xyz abc --abc=xyz\ """ actual = markdown.ExampleCommandLineSplitter().Split(example) self.assertEqual(expected, actual)
def testgSplitLongCommandExampleLineOffByOne(self): example = """\ $ gcloud alpha compute ssh example-instance --zone us-central1-a -- -vvv -L 80:%INSTANCE%:80\ """ expected = """\ $ gcloud alpha compute ssh example-instance --zone us-central1-a \\ -- -vvv -L 80:%INSTANCE%:80\ """ actual = markdown.ExampleCommandLineSplitter().Split(example) self.assertEqual(expected, actual)
def testgSplitLongCommandExampleLineCloseToBoundary(self): example = """\ $ gcloud alpha compute instance-templates create example-instance --scopes compute-rw,[email protected]=storage-rw\ """ expected = """\ $ gcloud alpha compute instance-templates create example-instance \\ --scopes compute-rw,[email protected]=storage-rw\ """ actual = markdown.ExampleCommandLineSplitter().Split(example) self.assertEqual(expected, actual)
def testgSplitLongCommandExampleLineWithDoubleQuoteSplit(self): example = """\ $ gcloud alpha dns record-sets transaction remove -z MANAGED_ZONE --name my.domain. --ttl 2345 --type TXT "Hello world","Bye world"\ """ expected = """\ $ gcloud alpha dns record-sets transaction remove -z MANAGED_ZONE \\ --name my.domain. --ttl 2345 --type TXT \\ "Hello world","Bye world"\ """ actual = markdown.ExampleCommandLineSplitter().Split(example) self.assertEqual(expected, actual)
def testgSplitLongCommandExampleLineWithDoubleQuote(self): example = """\ $ gcloud compute instances list --format="table[box,title=Instances](name:sort=1, zone:title=zone, status)"\ """ expected = """\ $ gcloud compute instances list \\ --format="table[box,title=Instances](name:sort=1,\\ zone:title=zone, status)"\ """ actual = markdown.ExampleCommandLineSplitter().Split(example) self.assertEqual(expected, actual)
def testgSplitLongCommandExampleLineWithReallyLongArgWithSlash(self): example = """\ $ gcloud compute instances list --format=http://zyx.bca/abcdefg/hijklmno/pqrstuvwxyz/abcdefg/hijklmno/pqrstuvwxyz\ """ expected = """\ $ gcloud compute instances list \\ --format=http://zyx.bca/abcdefg/hijklmno/pqrstuvwxyz/abcdefg/\\ hijklmno/pqrstuvwxyz\ """ actual = markdown.ExampleCommandLineSplitter().Split(example) self.assertEqual(expected, actual)
def testgSplitLongCommandExampleLineWithReallyLongArg(self): example = """\ $ gcloud compute instances list --format=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\ """ expected = """\ $ gcloud compute instances list \\ --format=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc\\ defghijklmnopqrstuvwxyz\ """ actual = markdown.ExampleCommandLineSplitter().Split(example) self.assertEqual(expected, actual)
def testgSplitLongCommandExampleLineStrangeSplit(self): example = """\ $ python -c "from time import mktime, strptime; print int(mktime(strptime('01 July 2015', '%d %B %Y')))"\ """ expected = """\ $ python \\ -c \\ "from time import mktime, strptime; print\\ int(mktime(strptime('01 July 2015', '%d %B %Y')))"\ """ actual = markdown.ExampleCommandLineSplitter().Split(example) self.assertEqual(expected, actual)
def testgSplitLongCommandExampleLineWithReallyLongDoubleQuote(self): example = """\ $ gcloud compute instances list --format="table(name:sort=2:align=center:label=INSTANCE, zone:sort=1:reverse, creationTimestamp.date('%Y-%m-%d'):label=START)"\ """ expected = """\ $ gcloud compute instances list \\ --format="table(name:sort=2:align=center:label=INSTANCE,\\ zone:sort=1:reverse,\\ creationTimestamp.date('%Y-%m-%d'):label=START)"\ """ actual = markdown.ExampleCommandLineSplitter().Split(example) self.assertEqual(expected, actual)