Пример #1
0
    def test_create_exportdir_ifnotexist(self, mkdir, isdir):
            args = Namespace(**{
                "environment": ["test"],
                "directory": "doesnotexist",
                "overwrite": False,
                "excludesysdata": False,
                "includemeta": True,
                "user": "******",
                "folders": [ "Examples" ]
            })
            isdir.return_value = False

            result = vcexport.run_vcexport(args)

            self.assertEqual(mkdir.called, True)
Пример #2
0
    def test_aborts_when_exportdir_not_empty(self, listdir):
        args = Namespace(**{
            "environment": ["test"],
            "directory": ".",
            "overwrite": False,
            "excludesysdata": False,
            "includemeta": True,
            "user": "******",
            "folders": [ "Examples" ]
        })
        listdir.return_value = ["Afile"]
        self.lambdaMock.reset_mock()

        result = vcexport.run_vcexport(args)

        self.lambdaMock.run_lambda.assert_not_called()
        self.assertEqual(result,False)
Пример #3
0
    def test_asks_for_password_if_not_in_arguments(self, glob, listdir, getpass):
        args = Namespace(**{
            "environment": ["test"],
            "directory": ".",
            "overwrite": False,
            "excludesysdata": False,
            "includemeta": True,
            "user": "******",
            "folders": [ "Examples" ]
        })
        listdir.return_value = []
        getpass.return_value = "thepass"
        glob.return_value = [ "Examples" ]

        result = vcexport.run_vcexport(args)

        self.assertEqual(getpass.called, True)
        self.assertEqual(result,True)
Пример #4
0
    def test_warning_when_not_all_folders_exported(self, listdir, mock_stderr):
            args = Namespace(**{
                "environment": ["test"],
                "directory": "mocktmpdir",
                "overwrite": False,
                "excludesysdata": False,
                "includemeta": True,
                "user": "******",
                "folders": [ "Examples", "Defaults" ]
            })
            listdir.return_value = []
            with self.monkeypatch.context() as m:
                m.setattr('mztools.vcexport.listdir_nohidden', lambda a: [ "Examples" ])

                result = vcexport.run_vcexport(args)

                mock_stderr.assert_has_calls([
                    unittest.mock.call.write('Warning: folder "Defaults" was not found in the export' + "\n")
                ])
Пример #5
0
    def test_does_not_ask_for_passwd_if_given(self, glob, listdir, getpass):
        args = Namespace(**{
            "environment": ["test"],
            "directory": ".",
            "overwrite": False,
            "excludesysdata": False,
            "includemeta": True,
            "user": "******",
            "folders": [ "Examples" ]
        })
        listdir.return_value = []
        getpass.return_value = "thepass"
        glob.return_value = [ "Examples" ]
        self.lambdaMock.reset_mock()

        result = vcexport.run_vcexport(args)

        self.assertEqual(self.lambdaMock.run_lambda.called, True)
        self.assertEqual(getpass.called, False)
        self.assertEqual(result,True)