Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Wiki Replica
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
TPA
Wiki Replica
Commits
053d1e95
Unverified
Commit
053d1e95
authored
5 years ago
by
anarcat
Browse files
Options
Downloads
Patches
Plain Diff
main test from micah data
parent
72fad306
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tsa/howto/upgrades/predict-os.py
+32
-1
32 additions, 1 deletion
tsa/howto/upgrades/predict-os.py
with
32 additions
and
1 deletion
tsa/howto/upgrades/predict-os.py
+
32
−
1
View file @
053d1e95
...
...
@@ -25,9 +25,16 @@ import collections
from
datetime
import
datetime
import
io
import
logging
import
logging.handlers
import
os
import
os.path
import
sys
import
tempfile
try
:
import
pytest
except
ImportError
:
pytest
=
None
import
pandas
as
pd
import
matplotlib
...
...
@@ -107,11 +114,35 @@ def main(args):
try
:
date
=
guess_completion_time
(
records
,
args
.
source
)
print
(
"
completion time of %s major upgrades: %s
"
%
(
args
.
source
,
date
))
except
ValueError
as
e
:
except
(
TypeError
,
ValueError
)
as
e
:
logging
.
warning
(
"
cannot guess completion time: %s
"
,
e
)
date
=
'
N/A
'
plot_records
(
records
,
date
,
args
)
if
pytest
is
not
None
:
@pytest.xfail
(
'
not sure why there is no output, but this should work
'
)
@pytest.mark.parametrize
(
"
test_input,expected
"
,
[(
b
'''
Date,release,count
2019-10-08,stretch,83
2019-10-08,buster,3
2019-10-08,sid,1
2019-10-08,jessie,2
'''
,
'
cannot guess completion time
'
)])
def
test_main
(
test_input
,
expected
):
with
tempfile
.
NamedTemporaryFile
()
as
csv
:
csv
.
write
(
test_input
)
csv
.
flush
()
handler
=
logging
.
handlers
.
MemoryHandler
(
1000
)
handler
.
setLevel
(
'
DEBUG
'
)
logging
.
getLogger
(
''
).
addHandler
(
handler
)
with
tempfile
.
NamedTemporaryFile
(
suffix
=
'
.png
'
)
as
graph
:
args
=
parse_args
([
'
--path
'
,
csv
.
name
,
'
--output
'
,
graph
.
name
])
main
(
args
)
output
=
"
\n
"
.
join
([
record
.
getMessage
()
for
record
in
handler
.
buffer
])
assert
expected
in
output
def
load_csv
(
fp
):
'''
load the data from the CSV
'''
return
pd
.
read_csv
(
fp
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment