Пример #1
0
    def test_store_user_entries_all(self):
        self.comp.barcode_1 = "pre_b1"
        self.comp.barcode_2 = "pre_b2"
        self.comp.asset_tag = "pre_asset"
        self.comp.name = "pre_name"

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.dvc.entry_view.barcode_1_entry.delete(0, "end")
        self.dvc.entry_view.barcode_2_entry.delete(0, "end")
        self.dvc.entry_view.asset_entry.delete(0, "end")
        self.dvc.entry_view.name_entry.delete(0, "end")

        self.dvc.entry_view.barcode_1_entry.insert(0, "post_b1")
        self.dvc.entry_view.barcode_2_entry.insert(0, "post_b2")
        self.dvc.entry_view.asset_entry.insert(0, "post_asset")
        self.dvc.entry_view.name_entry.insert(0, "post_name")

        self.dvc._store_user_entries(self.comp, self.vp)

        self.assertEqual("post_b1", self.comp.barcode_1)
        self.assertEqual("post_b2", self.comp.barcode_2)
        self.assertEqual("post_asset", self.comp.asset_tag)
        self.assertEqual("post_name", self.comp.name)
Пример #2
0
    def test_store_user_entries_all_none(self):
        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.assertIsNone(self.comp.barcode_1)
        self.assertIsNone(self.comp.barcode_2)
        self.assertIsNone(self.comp.asset_tag)
        self.assertIsNone(self.comp.name)
Пример #3
0
    def test_get_jss_data_fake_server(self):
        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.assertEqual(self.jss_bc1, self.comp.jss_barcode_1)
        self.assertEqual(self.jss_bc2, self.comp.jss_barcode_2)
        self.assertEqual(self.jss_asset, self.comp.jss_asset_tag)
        self.assertEqual(self.jss_serial, self.comp.jss_serial_number)
        self.assertEqual(self.jss_name, self.comp.jss_name)
Пример #4
0
    def test_fill_user_entries_all_none(self):
        # Instantiate vc with a Computer whose attributes are None.
        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        # Assert that getting None results in empty string.
        self.assertEqual("", self.dvc.entry_view.barcode_1_entry.get())
        self.assertEqual("", self.dvc.entry_view.barcode_2_entry.get())
        self.assertEqual("", self.dvc.entry_view.asset_entry.get())
        self.assertEqual("", self.dvc.entry_view.name_entry.get())
Пример #5
0
    def test_fill_jss_entries_all(self):
        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.assertEqual(self.jss_bc1,
                         self.dvc.entry_view.jss_barcode_1_entry.get())
        self.assertEqual(self.jss_bc2,
                         self.dvc.entry_view.jss_barcode_2_entry.get())
        self.assertEqual(self.jss_asset,
                         self.dvc.entry_view.jss_asset_entry.get())
        self.assertEqual(self.jss_name,
                         self.dvc.entry_view.jss_name_entry.get())
Пример #6
0
    def test_fill_user_entries_all_empty_string(self):
        self.comp.barcode_1 = ""
        self.comp.barcode_2 = ""
        self.comp.asset_tag = ""
        self.comp.serial_number = ""

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.assertEqual("", self.dvc.entry_view.barcode_1_entry.get())
        self.assertEqual("", self.dvc.entry_view.barcode_2_entry.get())
        self.assertEqual("", self.dvc.entry_view.asset_entry.get())
        self.assertEqual("", self.dvc.entry_view.name_entry.get())
Пример #7
0
    def test_fill_jss_entries_all_none(self):
        self.jamf.get_barcode_1 = lambda comp: None
        self.jamf.get_barcode_2 = lambda comp: None
        self.jamf.get_asset_tag = lambda comp: None
        self.jamf.get_serial = lambda comp: None
        self.jamf.get_name = lambda comp: None

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.assertEqual("", self.dvc.entry_view.jss_barcode_1_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_barcode_2_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_asset_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_name_entry.get())
Пример #8
0
    def test_store_conflicts_all_empty_string(self):
        self.comp.barcode_1 = ""
        self.comp.barcode_2 = ""
        self.comp.asset_tag = ""
        self.comp.serial_number = ""

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.dvc._store_conflicts(self.comp)

        self.assertIsNone(self.comp.incorrect_barcode_1)
        self.assertIsNone(self.comp.incorrect_barcode_2)
        self.assertIsNone(self.comp.incorrect_asset)
        self.assertIsNone(self.comp.incorrect_serial)
Пример #9
0
    def test_store_user_entries_empty_string(self):
        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.dvc._store_user_entries(self.comp, self.vp)

        self.dvc.entry_view.barcode_1_entry.insert(0, "")
        self.dvc.entry_view.barcode_2_entry.insert(0, "")
        self.dvc.entry_view.asset_entry.insert(0, "")
        self.dvc.entry_view.name_entry.insert(0, "")

        self.assertIsNone(self.comp.barcode_1)
        self.assertIsNone(self.comp.barcode_2)
        self.assertIsNone(self.comp.asset_tag)
        self.assertIsNone(self.comp.name)
Пример #10
0
    def test_store_conflicts_all_conflicts(self):
        self.comp.barcode_1 = "diff_bc1"
        self.comp.barcode_2 = "diff_bc2"
        self.comp.asset_tag = "diff_asset"
        self.comp.serial_number = "diff_serial"

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.dvc._store_conflicts(self.comp)

        self.assertEqual(self.jss_bc1, self.comp.incorrect_barcode_1)
        self.assertEqual(self.jss_bc2, self.comp.incorrect_barcode_2)
        self.assertEqual(self.jss_asset, self.comp.incorrect_asset)
        self.assertEqual(self.jss_serial, self.comp.incorrect_serial)
Пример #11
0
    def test_fill_user_entries_all(self):
        self.comp.barcode_1 = self.test_bc1
        self.comp.barcode_2 = self.test_bc2
        self.comp.asset_tag = self.test_asset
        self.comp.name = self.test_name

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.assertEqual(self.test_bc1,
                         self.dvc.entry_view.barcode_1_entry.get())
        self.assertEqual(self.test_bc2,
                         self.dvc.entry_view.barcode_2_entry.get())
        self.assertEqual(self.test_asset,
                         self.dvc.entry_view.asset_entry.get())
        self.assertEqual(self.test_name, self.dvc.entry_view.name_entry.get())
Пример #12
0
    def test_store_conflicts_no_conflicts(self):
        self.comp.barcode_1 = self.jss_bc1
        self.comp.barcode_2 = self.jss_bc2
        self.comp.asset_tag = self.jss_asset
        self.comp.serial_number = self.comp.get_serial()

        self.jamf.get_serial = lambda comp: self.comp.get_serial()

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.dvc._store_conflicts(self.comp)

        self.assertIsNone(self.comp.incorrect_barcode_1)
        self.assertIsNone(self.comp.incorrect_barcode_2)
        self.assertIsNone(self.comp.incorrect_asset)
        self.assertIsNone(self.comp.incorrect_serial)
Пример #13
0
    def test_fill_jss_entry_all_empty_string(self):
        self.jamf.get_barcode_1 = lambda comp: ""
        self.jamf.get_barcode_2 = lambda comp: ""
        self.jamf.get_asset_tag = lambda comp: ""
        self.jamf.get_serial = lambda comp: ""
        self.jamf.get_name = lambda comp: ""

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.dvc._fill_jss_entry(self.comp, "barcode_1")
        self.dvc._fill_jss_entry(self.comp, "barcode_2")
        self.dvc._fill_jss_entry(self.comp, "asset_tag")
        self.dvc._fill_jss_entry(self.comp, "name")

        self.assertEqual("", self.dvc.entry_view.jss_barcode_1_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_barcode_2_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_asset_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_name_entry.get())
Пример #14
0
    def _open_dual_verify_view(self):
        """Opens a DualVerifyView window.

        Returns:
            void
        """
        # <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
        # Open DualVerifyWindow/Controller
        self._verify_controller = DualVerifyController(self._main_view,
                                                       self._computer,
                                                       self.verify_params,
                                                       self._jss_server)
        # <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
        # Wait for entry view window to close.
        self._main_view.wait_window(window=self._verify_controller.entry_view)
        # <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
        # Store exit status of the view.
        self._proceed = self._verify_controller.proceed
Пример #15
0
class TestDualVerificationController(unittest.TestCase):
    """Test the GUI and the server manually."""
    def setUp(self):
        self.jamf = JssServer()
        self.comp = Computer()

        self.test_bc1 = "test_bc1"
        self.test_bc2 = "test_bc2"
        self.test_asset = "test_asset"
        self.test_serial = "test_serial"
        self.test_name = "test_name"

        self.jss_bc1 = "jss_bc1"
        self.jss_bc2 = "jss_bc2"
        self.jss_asset = "jss_asset"
        self.jss_serial = "jss_serial"
        self.jss_name = "jss_name"

        self.jamf.get_barcode_1 = lambda comp: self.jss_bc1
        self.jamf.get_barcode_2 = lambda comp: self.jss_bc2
        self.jamf.get_asset_tag = lambda comp: self.jss_asset
        self.jamf.get_serial = lambda comp: self.jss_serial
        self.jamf.get_name = lambda comp: self.jss_name

        self.dvc = None
        self.root = tk.Tk()

        self.vp_dict = {
            'barcode_1': 'True',
            'barcode_2': 'True',
            'asset_tag': 'True',
            'computer_name': 'True'
        }
        self.vp = VerifyParams(self.vp_dict)

        self.sp_dict = {
            'barcode_1': 'True',
            'barcode_2': 'True',
            'asset_tag': 'True',
            'serial_number': 'True'
        }
        self.sp = SearchParams(self.sp_dict)

    def tearDown(self):
        self.root.destroy()

    def test_get_jss_data_fake_server(self):
        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.assertEqual(self.jss_bc1, self.comp.jss_barcode_1)
        self.assertEqual(self.jss_bc2, self.comp.jss_barcode_2)
        self.assertEqual(self.jss_asset, self.comp.jss_asset_tag)
        self.assertEqual(self.jss_serial, self.comp.jss_serial_number)
        self.assertEqual(self.jss_name, self.comp.jss_name)

    def test_store_conflicts_all_empty_string(self):
        self.comp.barcode_1 = ""
        self.comp.barcode_2 = ""
        self.comp.asset_tag = ""
        self.comp.serial_number = ""

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.dvc._store_conflicts(self.comp)

        self.assertIsNone(self.comp.incorrect_barcode_1)
        self.assertIsNone(self.comp.incorrect_barcode_2)
        self.assertIsNone(self.comp.incorrect_asset)
        self.assertIsNone(self.comp.incorrect_serial)

    def test_store_conflicts_all_none(self):
        self.comp.barcode_1 = None
        self.comp.barcode_2 = None
        self.comp.asset_tag = None
        self.comp.serial_number = None

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.dvc._store_conflicts(self.comp)

        self.assertIsNone(self.comp.incorrect_barcode_1)
        self.assertIsNone(self.comp.incorrect_barcode_2)
        self.assertIsNone(self.comp.incorrect_asset)
        self.assertIsNone(self.comp.incorrect_serial)

    def test_store_conflicts_all_conflicts(self):
        self.comp.barcode_1 = "diff_bc1"
        self.comp.barcode_2 = "diff_bc2"
        self.comp.asset_tag = "diff_asset"
        self.comp.serial_number = "diff_serial"

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.dvc._store_conflicts(self.comp)

        self.assertEqual(self.jss_bc1, self.comp.incorrect_barcode_1)
        self.assertEqual(self.jss_bc2, self.comp.incorrect_barcode_2)
        self.assertEqual(self.jss_asset, self.comp.incorrect_asset)
        self.assertEqual(self.jss_serial, self.comp.incorrect_serial)

    def test_store_conflicts_no_conflicts(self):
        self.comp.barcode_1 = self.jss_bc1
        self.comp.barcode_2 = self.jss_bc2
        self.comp.asset_tag = self.jss_asset
        self.comp.serial_number = self.comp.get_serial()

        self.jamf.get_serial = lambda comp: self.comp.get_serial()

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.dvc._store_conflicts(self.comp)

        self.assertIsNone(self.comp.incorrect_barcode_1)
        self.assertIsNone(self.comp.incorrect_barcode_2)
        self.assertIsNone(self.comp.incorrect_asset)
        self.assertIsNone(self.comp.incorrect_serial)

    def test_store_user_entries_all(self):
        self.comp.barcode_1 = "pre_b1"
        self.comp.barcode_2 = "pre_b2"
        self.comp.asset_tag = "pre_asset"
        self.comp.name = "pre_name"

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.dvc.entry_view.barcode_1_entry.delete(0, "end")
        self.dvc.entry_view.barcode_2_entry.delete(0, "end")
        self.dvc.entry_view.asset_entry.delete(0, "end")
        self.dvc.entry_view.name_entry.delete(0, "end")

        self.dvc.entry_view.barcode_1_entry.insert(0, "post_b1")
        self.dvc.entry_view.barcode_2_entry.insert(0, "post_b2")
        self.dvc.entry_view.asset_entry.insert(0, "post_asset")
        self.dvc.entry_view.name_entry.insert(0, "post_name")

        self.dvc._store_user_entries(self.comp, self.vp)

        self.assertEqual("post_b1", self.comp.barcode_1)
        self.assertEqual("post_b2", self.comp.barcode_2)
        self.assertEqual("post_asset", self.comp.asset_tag)
        self.assertEqual("post_name", self.comp.name)

    def test_store_user_entries_all_none(self):
        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.assertIsNone(self.comp.barcode_1)
        self.assertIsNone(self.comp.barcode_2)
        self.assertIsNone(self.comp.asset_tag)
        self.assertIsNone(self.comp.name)

    def test_store_user_entries_empty_string(self):
        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.dvc._store_user_entries(self.comp, self.vp)

        self.dvc.entry_view.barcode_1_entry.insert(0, "")
        self.dvc.entry_view.barcode_2_entry.insert(0, "")
        self.dvc.entry_view.asset_entry.insert(0, "")
        self.dvc.entry_view.name_entry.insert(0, "")

        self.assertIsNone(self.comp.barcode_1)
        self.assertIsNone(self.comp.barcode_2)
        self.assertIsNone(self.comp.asset_tag)
        self.assertIsNone(self.comp.name)

    def test_fill_user_entries_all_none(self):
        # Instantiate vc with a Computer whose attributes are None.
        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        # Assert that getting None results in empty string.
        self.assertEqual("", self.dvc.entry_view.barcode_1_entry.get())
        self.assertEqual("", self.dvc.entry_view.barcode_2_entry.get())
        self.assertEqual("", self.dvc.entry_view.asset_entry.get())
        self.assertEqual("", self.dvc.entry_view.name_entry.get())

    def test_fill_user_entries_all_empty_string(self):
        self.comp.barcode_1 = ""
        self.comp.barcode_2 = ""
        self.comp.asset_tag = ""
        self.comp.serial_number = ""

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.assertEqual("", self.dvc.entry_view.barcode_1_entry.get())
        self.assertEqual("", self.dvc.entry_view.barcode_2_entry.get())
        self.assertEqual("", self.dvc.entry_view.asset_entry.get())
        self.assertEqual("", self.dvc.entry_view.name_entry.get())

    def test_fill_user_entries_all(self):
        self.comp.barcode_1 = self.test_bc1
        self.comp.barcode_2 = self.test_bc2
        self.comp.asset_tag = self.test_asset
        self.comp.name = self.test_name

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.assertEqual(self.test_bc1,
                         self.dvc.entry_view.barcode_1_entry.get())
        self.assertEqual(self.test_bc2,
                         self.dvc.entry_view.barcode_2_entry.get())
        self.assertEqual(self.test_asset,
                         self.dvc.entry_view.asset_entry.get())
        self.assertEqual(self.test_name, self.dvc.entry_view.name_entry.get())

    def test_fill_jss_entries_all(self):
        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.assertEqual(self.jss_bc1,
                         self.dvc.entry_view.jss_barcode_1_entry.get())
        self.assertEqual(self.jss_bc2,
                         self.dvc.entry_view.jss_barcode_2_entry.get())
        self.assertEqual(self.jss_asset,
                         self.dvc.entry_view.jss_asset_entry.get())
        self.assertEqual(self.jss_name,
                         self.dvc.entry_view.jss_name_entry.get())

    def test_fill_jss_entries_all_empty_string(self):
        self.jamf.get_barcode_1 = lambda comp: ""
        self.jamf.get_barcode_2 = lambda comp: ""
        self.jamf.get_asset_tag = lambda comp: ""
        self.jamf.get_serial = lambda comp: ""
        self.jamf.get_name = lambda comp: ""

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.assertEqual("", self.dvc.entry_view.jss_barcode_1_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_barcode_2_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_asset_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_name_entry.get())

    def test_fill_jss_entries_all_none(self):
        self.jamf.get_barcode_1 = lambda comp: None
        self.jamf.get_barcode_2 = lambda comp: None
        self.jamf.get_asset_tag = lambda comp: None
        self.jamf.get_serial = lambda comp: None
        self.jamf.get_name = lambda comp: None

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.assertEqual("", self.dvc.entry_view.jss_barcode_1_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_barcode_2_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_asset_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_name_entry.get())

    def test_fill_jss_entry_all(self):
        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.dvc._fill_jss_entry(self.comp, "barcode_1")
        self.dvc._fill_jss_entry(self.comp, "barcode_2")
        self.dvc._fill_jss_entry(self.comp, "asset_tag")
        self.dvc._fill_jss_entry(self.comp, "name")

        self.assertEqual(self.jss_bc1,
                         self.dvc.entry_view.jss_barcode_1_entry.get())
        self.assertEqual(self.jss_bc2,
                         self.dvc.entry_view.jss_barcode_2_entry.get())
        self.assertEqual(self.jss_asset,
                         self.dvc.entry_view.jss_asset_entry.get())
        self.assertEqual(self.jss_name,
                         self.dvc.entry_view.jss_name_entry.get())

    def test_fill_jss_entry_all_none(self):
        self.jamf.get_barcode_1 = lambda comp: None
        self.jamf.get_barcode_2 = lambda comp: None
        self.jamf.get_asset_tag = lambda comp: None
        self.jamf.get_serial = lambda comp: None
        self.jamf.get_name = lambda comp: None

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.dvc._fill_jss_entry(self.comp, "barcode_1")
        self.dvc._fill_jss_entry(self.comp, "barcode_2")
        self.dvc._fill_jss_entry(self.comp, "asset_tag")
        self.dvc._fill_jss_entry(self.comp, "name")

        self.assertEqual("", self.dvc.entry_view.jss_barcode_1_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_barcode_2_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_asset_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_name_entry.get())

    def test_fill_jss_entry_all_empty_string(self):
        self.jamf.get_barcode_1 = lambda comp: ""
        self.jamf.get_barcode_2 = lambda comp: ""
        self.jamf.get_asset_tag = lambda comp: ""
        self.jamf.get_serial = lambda comp: ""
        self.jamf.get_name = lambda comp: ""

        self.dvc = DualVerifyController(self.root, self.comp, self.vp,
                                        self.jamf)

        self.dvc._fill_jss_entry(self.comp, "barcode_1")
        self.dvc._fill_jss_entry(self.comp, "barcode_2")
        self.dvc._fill_jss_entry(self.comp, "asset_tag")
        self.dvc._fill_jss_entry(self.comp, "name")

        self.assertEqual("", self.dvc.entry_view.jss_barcode_1_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_barcode_2_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_asset_entry.get())
        self.assertEqual("", self.dvc.entry_view.jss_name_entry.get())