Skip to content

Commit 059779f

Browse files
committed
modernizing the example
1 parent f018355 commit 059779f

File tree

7 files changed

+33
-27
lines changed

7 files changed

+33
-27
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ $ git clone https://github.com/CiscoDevNet/pyats-sample-scripts.git
3030

3131
There are two ways to run a typical pyATS script:
3232

33-
1. through `easypy`, which generates log and archives
33+
1. through `pyats run job`, which generates log and archives
3434
2. as standalone, and prints results to screen
3535

3636
```bash
3737
$ cd pyats-sample-scripts/basic
3838

39-
$ easypy job/basic_example_job.py
39+
$ pyats run job job/basic_example_job.py
4040

4141
$ python basic_example_script.py
4242
```
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
To run:
88
99
cd pyats-sample-scripts/basic
10-
easypy job/basic_example_job.py
10+
pyats run job basic_example_job.py
1111
1212
'''
1313

@@ -20,7 +20,7 @@ def main():
2020
'''
2121

2222
# find the location of the script in relation to the job file
23-
script_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
23+
script_path = os.path.dirname(os.path.abspath(__file__))
2424
testscript = os.path.join(script_path, 'basic_example_script.py')
2525

2626
# execute the testscript

basic/basic_example_script.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,18 @@ def test_1(self, section):
107107
@aetest.test
108108
def test_2(self, section):
109109
'''
110-
same content as last testcase - notice the section id difference.
110+
you can also provide explicit results, reason and data using result API.
111+
These information will be captured in the result summary.
111112
'''
112113
log.info("test section: %s in testcase %s" % (section.uid, self.uid))
113114

114-
# testcase instance is preserved, eg
115-
assert self.b == 2
116-
115+
if self.b == 2:
116+
self.passed('variable b contains the expected value',
117+
data = {'b': self.b})
118+
else:
119+
self.failed('variable b did not contains the expected value',
120+
data = {'b': self.b})
121+
117122
@aetest.cleanup
118123
def cleanup(self):
119124
'''cleanup section

comprehensive/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ walking users through important features and explaining them using live
2020
examples, supplementing the full user guide at:
2121
https://developer.cisco.com/site/pyats/docs/
2222

23-
This example is executable both under standalone execution, and through `easypy`.
24-
You can modify parts of this code to see how it changes execution behaviors.
23+
This example is executable both under standalone execution, and through
24+
pyATS command line `pyats run job`. You can modify parts of this code to see
25+
how it changes execution behaviors.
2526

2627
```
2728
Folder Structure
@@ -55,7 +56,7 @@ $ cd pyats-sample-scripts/comprehensive/
5556
$ python base_example.py --testbed etc/example_testbed.yaml
5657
$ python variant_example.py --testbed etc/example_testbed.yaml
5758

58-
# easypy execution
59-
# ----------------
60-
$ easypy job/example_job.py -testbed_file etc/example_testbed.yaml
59+
# pyats job execution
60+
# -------------------
61+
$ pyats run job job/example_job.py --testbed-file etc/example_testbed.yaml
6162
```

comprehensive/base_example.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
# to run with datafile under command-line
3838
bash$ python base_example.py -datafile=data/base_datafile.yaml
3939
40-
# to run under easypy
41-
bash$ easypy job/example_job.py
40+
# to run under pyats job engine
41+
bash$ pyats run job job/example_job.py
4242
4343
References:
4444
For the complete and up-to-date user guide on pyATS, visit:
@@ -89,8 +89,8 @@
8989
#*******************************************************************************
9090
#* LOGGING
9191
#*
92-
#* Logging should be done by using the standard Python logging module. AEtest
93-
#* and Easypy will take care of configuring the log outputs to be Cisco Logs
92+
#* Logging should be done by using the standard Python logging module. The
93+
#* engine will take care of configuring the log outputs to be Cisco Logs
9494
#* format. There's not much more to say beyond that. :-)
9595
#*
9696
#* Convention:
@@ -380,7 +380,7 @@ def access_runtime(self):
380380
#******************************
381381
#* Access Testbed Information
382382
#*
383-
#* when easypy is called with -testbed_file argument, the 'testbed'
383+
#* when pyats run job is called with --testbed-file argument, the 'testbed'
384384
#* parameter is automatically provided to the testscript with the
385385
#* corresponding topology objects.
386386
#* in standalone execution, users need to create their own testbed

comprehensive/job/example_job.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
# to run under standalone execution
1111
bash$ python base_example.py
1212
13-
# to run under easypy
14-
bash$ easypy job/example_job.py
13+
# to run under pyats job engine
14+
bash$ pyats run job example_job.py
1515
1616
References:
1717
For the complete and up-to-date user guide on pyATS, visit:
@@ -101,11 +101,11 @@
101101
#*******************************************************************************
102102
#* TESTBED INFORMATION
103103
#*
104-
#* when executing a jobfile using easypy, testbed file should be provided to
105-
#* easypy launcher using argument -testbed_file. Easypy will automatically
104+
#* when executing a jobfile using pyats, testbed file should be provided to
105+
#* pyats job launcher using argument --testbed-file. The engine will then
106106
#* load this provided testbed file into topology objects, and pass it to each
107107
#* testscript as script argument "testbed".
108-
#* easypy myjobfile.py -testbed_file mytestbed.yaml
108+
#* pyats run job myjobfile.py --testbed-file mytestbed.yaml
109109
#*
110110
#* as long as the argument is used properly, there's nothing extra the user
111111
#* has to do. Testscripts will automatically be passed the parameter 'testbed',
@@ -189,11 +189,11 @@
189189
#* MAIN FUNCTION
190190
#*
191191
#* Each job file must have a main() function where testscripts/task runs are
192-
#* defined. After a job file is imported, easypy will lookup main() function
192+
#* defined. After a job file is imported, pyats will lookup main() function
193193
#* to run.
194194
#*
195195
#* main() funtion shall have a single argument called 'runtime'. This allows
196-
#* the engine to automatically pass in the current Easypy runtime object. The
196+
#* the engine to automatically pass in the current runtime object. The
197197
#* following should be performed within the main() function:
198198
#* - parse any custom command-line arguments
199199
#* - configure logger log-levels, if any

comprehensive/variant_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
# to run under standalone execution
2626
bash$ python variant_example.py
2727
28-
# to run under easypy
29-
bash$ easypy job/example_job.py
28+
# to run under pyats job engine
29+
bash$ pyats run job job/example_job.py
3030
3131
References:
3232
For the complete and up-to-date user guide on pyATS, visit:

0 commit comments

Comments
 (0)