Repository: vmware/tern (python)

Issue:
Create a files_analyzed property in the ImageLayer class
**Description**
Create a property called `files_analyzed` in the ImageLayer class located in `tern/classes/image_layer.py`.

**Implementation**
In `tern/classes/image_layer.py`
1. Add `files_analyzed` to class docstring under `class ImageLayer:`
`files_analyzed: whether the files in this layer are analyzed or not`.
2. Add the property to `__init__` function and set it to False.
3. Add a getter and setter. The setter should first check if the input is a boolean (`True` or `False` in python) and if not then raise a ValueError with a message like "files_analyzed should be boolean".

In `tests/test_class_image_layer.py`, add tests for `files_analyzed` in `testInstance`:
1. Test if the default value is False
2. Test if the value can be set to True
3. Test if it raises a ValueError if you try to set it with a string 

**References**
Look in `tern/classes/image_layer.py` and `tests/test_class_image_layer.py` to see examples of how to implement this.

**Super Issues**
#284 


Pull request description:
Add files_analyzed property for ImageLayer class
Fixes #444 

Signed-off-by: Manaswini Das <dasmanaswini10@gmail.com>

Patch:
diff --git a/tern/classes/image_layer.py b/tern/classes/image_layer.py
index c0b9899..e859152 100644
--- a/tern/classes/image_layer.py
+++ b/tern/classes/image_layer.py
@@ -28,6 +28,7 @@ class ImageLayer:
         last layer of the image that was imported
         import_str: The string from a build tool (like a Dockerfile) that
         created this layer by importing it from another image
+        files_analyzed: whether the files in this layer are analyzed or not
     methods:
         add_package: adds a package to the layer
         remove_package: removes a package from the layer
@@ -45,6 +46,7 @@ class ImageLayer:
         self.__import_str = ''
         self.__pkg_format = ''
         self.__os_guess = ''
+        self.__files_analyzed = False
 
     @property
     def diff_id(self):
@@ -69,7 +71,7 @@ class ImageLayer:
     @property
     def created_by(self):
         return self.__created_by
-
+        
     @created_by.setter
     def created_by(self, create_string):
         self.__created_by = create_string
@@ -106,6 +108,17 @@ class ImageLayer:
     def os_guess(self, os_guess):
         self.__os_guess = os_guess
 
+    @property
+    def files_analyzed(self):
+        return self.__files_analyzed
+        
+    @files_analyzed.setter
+    def files_analyzed(self, x):
+        if isinstance(x, bool):
+            self.__files_analyzed = x
+        else:
+            raise ValueError('files_analyzed should be boolean')
+    
     def add_package(self, package):
         if isinstance(package, Package):
             if package.name not in self.get_package_names():


Test patch:
diff --git a/tests/test_class_image_layer.py b/tests/test_class_image_layer.py
index f291dfa..259ffdd 100644
--- a/tests/test_class_image_layer.py
+++ b/tests/test_class_image_layer.py
@@ -34,6 +34,11 @@ class TestClassImageLayer(unittest.TestCase):
         self.assertEqual(self.layer.pkg_format, 'rpm')
         self.layer.os_guess = 'operating system'
         self.assertEqual(self.layer.os_guess, 'operating system')
+        self.assertFalse(self.layer.files_analyzed)
+        self.layer.files_analyzed = True
+        self.assertTrue(self.layer.files_analyzed)
+        self.assertRaises(ValueError, setattr, self.layer,
+                          'files_analyzed', 'some string')
 
     def testAddPackage(self):
         err = "Object type String, should be Package"