Add -json flag to snapshot show|list

Signed-off-by: Joshua Colson <joshua.colson@gmail.com>
This commit is contained in:
Joshua Colson
2021-09-21 06:11:45 -07:00
committed by Lorenzo Bolla
parent f9c0d99790
commit 0f1575d5af
20 changed files with 583 additions and 15 deletions
@@ -0,0 +1,42 @@
[
{
"Name": "snap2",
"SourceKind": "repo",
"Description": "Snapshot from mirror [wheezy-main]: http://mirror.yandex.ru/debian/ wheezy",
"Origin": "Debian",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
},
{
"Name": "snap1",
"SourceKind": "repo",
"Description": "Snapshot from mirror [wheezy-contrib]: http://mirror.yandex.ru/debian/ wheezy",
"Origin": "Debian",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
},
{
"Name": "snap3",
"SourceKind": "snapshot",
"Description": "Merged from sources: 'snap1', 'snap2'",
"Origin": "",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
},
{
"Name": "snap4",
"SourceKind": "snapshot",
"Description": "Pulled into 'snap1' with 'snap2' as source, pull request was: 'mame unrar'",
"Origin": "",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
},
{
"Name": "snap5",
"SourceKind": "local",
"Description": "Snapshot from local repo [local-repo]",
"Origin": "",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
}
]
@@ -0,0 +1,42 @@
[
{
"Name": "snap1",
"SourceKind": "repo",
"Description": "Snapshot from mirror [wheezy-main]: http://mirror.yandex.ru/debian/ wheezy",
"Origin": "Debian",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
},
{
"Name": "snap2",
"SourceKind": "repo",
"Description": "Snapshot from mirror [wheezy-contrib]: http://mirror.yandex.ru/debian/ wheezy",
"Origin": "Debian",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
},
{
"Name": "snap3",
"SourceKind": "snapshot",
"Description": "Merged from sources: 'snap1', 'snap2'",
"Origin": "",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
},
{
"Name": "snap4",
"SourceKind": "snapshot",
"Description": "Pulled into 'snap1' with 'snap2' as source, pull request was: 'mame unrar'",
"Origin": "",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
},
{
"Name": "snap5",
"SourceKind": "local",
"Description": "Snapshot from local repo [local-repo]",
"Origin": "",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
}
]
@@ -0,0 +1 @@
[]
@@ -0,0 +1,45 @@
{
"Name": "snap1",
"SourceKind": "repo",
"RemoteRepos": [
{
"UUID": "d49dfdff-88a2-40d5-a682-ef37e76bdc3f",
"Name": "wheezy-non-free",
"ArchiveRoot": "http://mirror.yandex.ru/debian/",
"Distribution": "wheezy",
"Components": [
"non-free"
],
"Architectures": [
"i386",
"amd64"
],
"Meta": {
"Architectures": "amd64 armel armhf i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc s390 s390x sparc",
"Codename": "wheezy",
"Components": "main contrib non-free",
"Date": "Sat, 26 Apr 2014 09:27:11 UTC",
"Description": " Debian 7.5 Released 26 April 2014\n",
"Label": "Debian",
"Origin": "Debian",
"Suite": "stable",
"Version": "7.5"
},
"LastDownloadDate": "2014-06-28T01:23:26.597799094+04:00",
"ReleaseFiles": null,
"Filter": "",
"Status": 0,
"WorkerPID": 0,
"FilterWithDeps": false,
"SkipComponentCheck": false,
"SkipArchitectureCheck": false,
"DownloadSources": false,
"DownloadUdebs": false,
"DownloadInstaller": false
}
],
"Description": "Snapshot from mirror [wheezy-non-free]: http://mirror.yandex.ru/debian/ wheezy",
"Origin": "Debian",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
}
@@ -0,0 +1,55 @@
{
"Name": "snap1",
"SourceKind": "repo",
"RemoteRepos": [
{
"UUID": "c2e70bbb-0640-45d8-b066-58b598c93b43",
"Name": "gnuplot-maverick",
"ArchiveRoot": "http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/",
"Distribution": "maverick",
"Components": [
"main"
],
"Architectures": [
"amd64",
"armel",
"i386",
"powerpc"
],
"Meta": {
"Architectures": "amd64 armel i386 powerpc",
"Codename": "maverick",
"Components": "main",
"Date": "Mon, 22 Oct 2012 13:19:50 UTC",
"Description": " Ubuntu Maverick 10.10\n",
"Label": "gnuplot",
"Origin": "LP-PPA-gladky-anton-gnuplot",
"Suite": "maverick",
"Version": "10.10"
},
"LastDownloadDate": "2014-06-28T01:24:09.760026156+04:00",
"ReleaseFiles": null,
"Filter": "",
"Status": 0,
"WorkerPID": 0,
"FilterWithDeps": false,
"SkipComponentCheck": false,
"SkipArchitectureCheck": false,
"DownloadSources": false,
"DownloadUdebs": false,
"DownloadInstaller": false
}
],
"Packages": [
"gnuplot-doc_4.6.1-1~maverick2_all",
"gnuplot-nox_4.6.1-1~maverick2_amd64",
"gnuplot-nox_4.6.1-1~maverick2_i386",
"gnuplot-x11_4.6.1-1~maverick2_amd64",
"gnuplot-x11_4.6.1-1~maverick2_i386",
"gnuplot_4.6.1-1~maverick2_all"
],
"Description": "Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick",
"Origin": "LP-PPA-gladky-anton-gnuplot",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
}
@@ -0,0 +1,16 @@
{
"Name": "snap1",
"SourceKind": "local",
"LocalRepos": [
{
"Name": "repo1",
"Comment": "Cool",
"DefaultDistribution": "wheezy",
"DefaultComponent": "contrib"
}
],
"Description": "Snapshot from local repo [repo1]: Cool",
"Origin": "",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
}
@@ -0,0 +1,22 @@
{
"Name": "snap1",
"SourceKind": "local",
"LocalRepos": [
{
"Name": "repo1",
"Comment": "Cool",
"DefaultDistribution": "wheezy",
"DefaultComponent": "contrib"
}
],
"Packages": [
"libboost-program-options-dev_1.49.0.1_i386",
"libboost-program-options-dev_1.62.0.1_i386",
"pyspi_0.6.1-1.3_source",
"pyspi_0.6.1-1.4_source"
],
"Description": "Snapshot from local repo [repo1]: Cool",
"Origin": "",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
}
@@ -0,0 +1,26 @@
{
"Name": "snap3",
"SourceKind": "snapshot",
"Snapshots": [
{
"Name": "snap1",
"SourceKind": "repo",
"Description": "Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick",
"Origin": "LP-PPA-gladky-anton-gnuplot",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
},
{
"Name": "snap2",
"SourceKind": "repo",
"Description": "Snapshot from mirror [sensu]: http://repos.sensuapp.org/apt/ sensu",
"Origin": "Sensu",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
}
],
"Description": "Pulled into 'snap1' with 'snap2' as source, pull request was: 'sensu'",
"Origin": "",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
}
@@ -0,0 +1,36 @@
{
"Name": "snap3",
"SourceKind": "snapshot",
"Snapshots": [
{
"Name": "snap1",
"SourceKind": "repo",
"Description": "Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick",
"Origin": "LP-PPA-gladky-anton-gnuplot",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
},
{
"Name": "snap2",
"SourceKind": "repo",
"Description": "Snapshot from mirror [sensu]: http://repos.sensuapp.org/apt/ sensu",
"Origin": "Sensu",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
}
],
"Packages": [
"gnuplot-doc_4.6.1-1~maverick2_all",
"gnuplot-nox_4.6.1-1~maverick2_amd64",
"gnuplot-nox_4.6.1-1~maverick2_i386",
"gnuplot-x11_4.6.1-1~maverick2_amd64",
"gnuplot-x11_4.6.1-1~maverick2_i386",
"gnuplot_4.6.1-1~maverick2_all",
"sensu_0.12.6-5_amd64",
"sensu_0.12.6-5_i386"
],
"Description": "Pulled into 'snap1' with 'snap2' as source, pull request was: 'sensu'",
"Origin": "",
"NotAutomatic": "",
"ButAutomaticUpgrades": ""
}
+49
View File
@@ -1,3 +1,5 @@
import re
from lib import BaseTest
@@ -92,3 +94,50 @@ class ListSnapshot7Test(BaseTest):
]
runCmd = "aptly -sort=planet snapshot list"
expectedCode = 1
class ListSnapshot8Test(BaseTest):
"""
list snapshots: json regular list
"""
fixtureDB = True
fixtureCmds = [
"aptly snapshot create snap1 from mirror wheezy-main",
"aptly snapshot create snap2 from mirror wheezy-contrib",
"aptly snapshot merge snap3 snap1 snap2",
"aptly snapshot pull snap1 snap2 snap4 mame unrar",
"aptly repo create local-repo",
"aptly repo add local-repo ${files}",
"aptly snapshot create snap5 from repo local-repo",
]
runCmd = "aptly -json snapshot list"
def outputMatchPrepare(self, s):
return re.sub(r'[ ]*"CreatedAt": "[^"]+",?\n', '', s)
class ListSnapshot9Test(BaseTest):
"""
list snapshots: json empty list
"""
runCmd = "aptly snapshot -json list"
class ListSnapshot10Test(BaseTest):
"""
list snapshots: json regular list sorted by time
"""
fixtureDB = True
fixtureCmds = [
"aptly snapshot create snap2 from mirror wheezy-main",
"aptly snapshot create snap1 from mirror wheezy-contrib",
"aptly snapshot merge snap3 snap1 snap2",
"aptly snapshot pull snap1 snap2 snap4 mame unrar",
"aptly repo create local-repo",
"aptly repo add local-repo ${files}",
"aptly snapshot create snap5 from repo local-repo",
]
runCmd = "aptly -json -sort=time snapshot list"
def outputMatchPrepare(self, s):
return re.sub(r'[ ]*"CreatedAt": "[^"]+",?\n', '', s)
+88
View File
@@ -33,3 +33,91 @@ class ShowSnapshot3Test(BaseTest):
def outputMatchPrepare(_, s):
return re.sub(r"Created At: [0-9:A-Za-z -]+\n", "", s)
class ShowSnapshot4Test(BaseTest):
"""
show snapshot json: from mirror w/o packages
"""
fixtureDB = True
fixtureCmds = ["aptly snapshot create snap1 from mirror wheezy-non-free"]
runCmd = "aptly snapshot show -json snap1"
def outputMatchPrepare(_, s):
return re.sub(r'[ ]*"CreatedAt": "[^"]+",?\n', '', s)
class ShowSnapshot5Test(BaseTest):
"""
show snapshot json: from mirror with packages
"""
fixtureDB = True
fixtureCmds = ["aptly snapshot create snap1 from mirror gnuplot-maverick"]
runCmd = "aptly snapshot show -json -with-packages snap1"
def outputMatchPrepare(_, s):
return re.sub(r'[ ]*"CreatedAt": "[^"]+",?\n', '', s)
class ShowSnapshot6Test(BaseTest):
"""
show snapshot json: from local repo w/o packages
"""
fixtureDB = True
fixtureCmds = [
"aptly repo create -comment=Cool -distribution=wheezy -component=contrib repo1",
"aptly repo add repo1 ${files}",
"aptly snapshot create snap1 from repo repo1"
]
runCmd = "aptly snapshot show -json snap1"
def outputMatchPrepare(_, s):
return re.sub(r'[ ]*"CreatedAt": "[^"]+",?\n', '', s)
class ShowSnapshot7Test(BaseTest):
"""
show snapshot json: from local repo with packages
"""
fixtureDB = True
fixtureCmds = [
"aptly repo create -comment=Cool -distribution=wheezy -component=contrib repo1",
"aptly repo add repo1 ${files}",
"aptly snapshot create snap1 from repo repo1"
]
runCmd = "aptly snapshot show -json -with-packages snap1"
def outputMatchPrepare(_, s):
return re.sub(r'[ ]*"CreatedAt": "[^"]+",?\n', '', s)
class ShowSnapshot8Test(BaseTest):
"""
show snapshot json: from local repo w/o packages
"""
fixtureDB = True
fixtureCmds = [
"aptly snapshot create snap1 from mirror gnuplot-maverick",
"aptly snapshot create snap2 from mirror sensu",
"aptly snapshot pull snap1 snap2 snap3 sensu"
]
runCmd = "aptly snapshot show -json snap3"
def outputMatchPrepare(_, s):
return re.sub(r'[ ]*"CreatedAt": "[^"]+",?\n', '', s)
class ShowSnapshot9Test(BaseTest):
"""
show snapshot json: from local repo with packages
"""
fixtureDB = True
fixtureCmds = [
"aptly snapshot create snap1 from mirror gnuplot-maverick",
"aptly snapshot create snap2 from mirror sensu",
"aptly snapshot pull snap1 snap2 snap3 sensu"
]
runCmd = "aptly snapshot show -json -with-packages snap3"
def outputMatchPrepare(_, s):
return re.sub(r'[ ]*"CreatedAt": "[^"]+",?\n', '', s)
+4 -4
View File
@@ -4,9 +4,9 @@
"DefaultDistribution": "wheezy",
"DefaultComponent": "contrib",
"Packages": [
"Pi386 libboost-program-options-dev 1.49.0.1 918d2f433384e378",
"Pi386 libboost-program-options-dev 1.62.0.1 7760e62f99c551cb",
"Psource pyspi 0.6.1-1.3 3a8b37cbd9a3559e",
"Psource pyspi 0.6.1-1.4 f8f1daa806004e89"
"libboost-program-options-dev_1.49.0.1_i386",
"libboost-program-options-dev_1.62.0.1_i386",
"pyspi_0.6.1-1.3_source",
"pyspi_0.6.1-1.4_source"
]
}