[cs615asa] [git commit] CS615 EBS-BACKUP; backup a directory into Elastic Block Storage (EBS) branch main updated. fc0b01d4fc4d411dc24b9225fef0f95924e4a397
Git Owner
jschauma at stevens.edu
Sun May 9 19:18:05 EDT 2021
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CS615 EBS-BACKUP; backup a directory into Elastic Block Storage (EBS)".
The branch, main has been updated
via fc0b01d4fc4d411dc24b9225fef0f95924e4a397 (commit)
via cf5685373fb6dcedd883e797acb0a54c50f1c454 (commit)
from 5fe2c86849d21c5b80d99c34baf62d472a7d5ec5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit fc0b01d4fc4d411dc24b9225fef0f95924e4a397
Author: ngoldstein51 <ngoldstein51 at gmail.com>
Date: Sun May 9 19:20:44 2021 -0400
test comments from msnajder and change to arg test
diff --git a/test/test_arg_parsing.py b/test/test_arg_parsing.py
index 7532c9e..958d9c4 100644
--- a/test/test_arg_parsing.py
+++ b/test/test_arg_parsing.py
@@ -34,7 +34,7 @@ from src import parse_args
class ArgParseTest(unittest.TestCase):
def test_parse_args_success(self):
args = vars(parse_args(['-l', 'hello_tests', '.']))
- expected_args = {'l': 'hello_tests', 'r': None, 'v': None, 'dir': '.', 'i': None}
+ expected_args = {'l': 'hello_tests', 'r': None, 'v': None, 'dir': '.'}
self.assertEqual(args, expected_args)
def test_parse_failure(self):
commit cf5685373fb6dcedd883e797acb0a54c50f1c454
Author: msnajder <msnajder at stevens.edu>
Date: Sun May 9 19:11:51 2021 -0400
added some documentation to the test files
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 986e586..351d8e1 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -13,3 +13,4 @@ camatang 2021-02-20 yes
zxie11 2021-02-28 yes
ddelaus 2021-05-05 yes
jho1 2021-03-08 yes
+msnajder 2021-05-05 yes
diff --git a/test/test_arg_parsing.py b/test/test_arg_parsing.py
index f9dad3a..7532c9e 100644
--- a/test/test_arg_parsing.py
+++ b/test/test_arg_parsing.py
@@ -1,3 +1,4 @@
+""" test_arg_parsing does testing on the argument_parsing.py file. """
import unittest
import sys
import os
@@ -6,6 +7,30 @@ from unittest.mock import patch
sys.path.append('..')
from src import parse_args
+"""
+
+ This class creates two test functions.The two functions are
+ test_parse_args_success and test_parse_failure.
+
+ For test_parse_args_success the test tries two arguements
+ that are valid and hopes for a successful result
+
+ Args:
+ ['-l', 'hello_tests']
+ Returns:
+ 'l': 'hello_tests', 'r': None, 'v': None
+
+ For test_parse_args_failure the test tries two arguements
+ that are invalid and hopes for a failure
+
+ Args:
+ ['-w', 'hello_tests']
+ Returns:
+ a system error and a system exit
+
+
+"""
+
class ArgParseTest(unittest.TestCase):
def test_parse_args_success(self):
args = vars(parse_args(['-l', 'hello_tests', '.']))
diff --git a/test/test_ec2.py b/test/test_ec2.py
index 76a53be..18e53e5 100644
--- a/test/test_ec2.py
+++ b/test/test_ec2.py
@@ -1,3 +1,4 @@
+""" test_ec2 does the testing on the ec2.py file """
import unittest
import sys
import os
@@ -8,18 +9,57 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) #
sys.path.append('..')
from src.ec2 import EC2
+
+"""
+
+ This class creates three test functions. The three functions are
+ test_primitive_check01, test_primitive_check02, and test_createEC2_01
+
+ For test_primitive_check01 the test inserts a string that is invalid
+ and hopes for a negative result meaning the value is not primitive.
+
+ Args:
+ "{'ResponseMetadata': {'RetryAttempts': 0, 'HTTPHe..."
+ this is false because of {}
+
+ Result:
+ False
+
+ For test_primitive_check02 the test inserts a string that is valid
+ and hopes for a successful result meaning the value is primitive.
+
+
+ Args:
+ "ResponseMetadata TTPHe..."
+
+ Result:
+ True
+
+ For test_createEC2_01 the test tries to create a new ec2 instance
+ and checks that an instance ID is created
+
+ Args:
+ 'ImageId': 'ami-0018b2d98332ba7e3',
+ 'MinCount': 1,
+ 'MaxCount': 1,
+ 'InstanceType': 't2.micro',
+ 'KeyName': 'ebs-backup',
+ 'Placement': {"AvailabilityZone": 'us-east-1a'
+
+ Result:
+ An instance ID has been created
+"""
+
+
class EC2Test(unittest.TestCase):
def test_primitive_check01(self):
with patch.object(EC2, "__init__", lambda x, y, z: None):
ec2 = EC2(None, None)
- # self.assertTrue(True)
- #print("Zehui->>>>>>>>>>>>>",ec2.primitive_check("{'ResponseMetadata': {'RetryAttempts': 0, 'HTTPHe..."))
assert ec2.primitive_check("{'ResponseMetadata': {'RetryAttempts': 0, 'HTTPHe...") is False
def test_primitive_check02(self):
with patch.object(EC2, "__init__", lambda x, y, z: None):
ec2 = EC2(None, None)
- # self.assertTrue(True)
assert ec2.primitive_check("ResponseMetadata TTPHe...") is True
@@ -48,7 +88,6 @@ class EC2Test(unittest.TestCase):
print(ec2.instance,"----test_createEC2_01-----")
# with patch.object(EC2, "__init__", lambda x, y, z: None):
# ec2 = EC2(None, None)
- # print("Zehui->>>>>>>>>>>>>",ec2.parse_overrides("{'ResponseMetadata': {'RetryAttempts': 0, 'HTTPHe..."))
assert instance_id is not None
diff --git a/test/test_env_parsing.py b/test/test_env_parsing.py
index 303b8e0..50a8b54 100644
--- a/test/test_env_parsing.py
+++ b/test/test_env_parsing.py
@@ -1,3 +1,4 @@
+""" test_env_parsing does testing on the env_parsing.py file. """
import unittest
import sys
import os
@@ -5,7 +6,28 @@ from unittest.mock import patch
sys.path.append('..')
from src import parse_env
+"""
+ This class creates one test function.
+
+ For test_parse_env_success the test tries one arguement
+ that is valid and hopes for a successful result
+
+ Args:
+ expected_env = {
+ 'EBS_BACKUP_FLAGS_SSH': None,
+ 'EC2_CERT': None,
+ 'EBS_BACKUP_FLAGS_AWS': None,
+ 'EBS_BACKUP_VERBOSE': None,
+ 'AWS_CONFIG_FILE': None,
+ 'EC2_PRIVATE_KEY': None,
+ 'EC2_HOME': None
+ }
+
+ Returns:
+ a successful env test
+
+"""
class EnvParseTest(unittest.TestCase):
def test_parse_env_success(self):
expected_env = {
diff --git a/test/test_volume.py b/test/test_volume.py
index 233871f..968a853 100644
--- a/test/test_volume.py
+++ b/test/test_volume.py
@@ -1,3 +1,4 @@
+""" test_volume does the testing on the volume.py file """
import unittest
import sys
import os
@@ -22,7 +23,24 @@ config = {'volume_id': volume_id, 'size': 2048, 'instanceid': instanceid}
# ])#no pytest used
+"""
+ This class creates one test function. The function is
+ test_attach_to_instance01.
+
+ For test_attach_to_instance01 the test attempts to create an instance
+ To do this a standard volume is created and then inserted into the
+ original function. The result will hope to not be 0 showing that a
+ volume was created.
+
+
+ Args:
+ Volume
+
+ Result:
+ res 2 is not zero meaning a volume was created
+
+"""
class VolumeTest(unittest.TestCase):
instanceid = 'i-076aee001cb41dd2a'
@@ -36,7 +54,7 @@ class VolumeTest(unittest.TestCase):
self.volume_id = config['volume_id']
self.device_name="/dev/sdf"
- #TODO if exist volum
+
def test_attach_to_instance01(self):
with patch.object(Volume, "__init__", lambda x, y: None):
@@ -49,7 +67,7 @@ class VolumeTest(unittest.TestCase):
AvailabilityZone='us-east-1a',
Size=config['size'],
)
- #print(res2)
+
vol.volume_id = res2['VolumeId']
count=0
ec2_resource = boto3.resource('ec2')
@@ -57,11 +75,8 @@ class VolumeTest(unittest.TestCase):
for instance in ec2_resource.instances.all():
for volume in instance.volumes.all():
- #print(instance.id, volume.id, volume.volume_type, volume.size)
count+=1
vol.ec2_volume = res2['VolumeId']
- #print(vol.attach_to_instance(instanceid))
- #vol.ec2_volume.attach_to_instance(instanceid) TODO :has issue
assert res2 is not 0
-----------------------------------------------------------------------
Summary of changes:
CONTRIBUTORS | 1 +
test/test_arg_parsing.py | 27 ++++++++++++++++++++++++++-
test/test_ec2.py | 47 +++++++++++++++++++++++++++++++++++++++++++----
test/test_env_parsing.py | 22 ++++++++++++++++++++++
test/test_volume.py | 25 ++++++++++++++++++++-----
5 files changed, 112 insertions(+), 10 deletions(-)
hooks/post-receive
--
CS615 EBS-BACKUP; backup a directory into Elastic Block Storage (EBS)
More information about the cs615asa
mailing list