示例#1
0
    def test_from_url_raises_if_dest_dir_contains_program(self, fs):
        fs_root = pathlib.Path(fs, "foo")
        make_mbed_program_files(fs_root)
        url = "https://valid"

        with self.assertRaises(ExistingProgram):
            MbedProgram.from_url(url, fs_root)
示例#2
0
    def test_finds_program_higher_in_dir_tree(self, fs):
        program_root = pathlib.Path(fs, "foo")
        pwd = program_root / "subprojfoo" / "libbar"
        make_mbed_program_files(program_root)
        pwd.mkdir(parents=True)

        self.assertEqual(_find_program_root(pwd), program_root.resolve())
示例#3
0
    def test_from_existing_raises_if_no_mbed_os_dir_found_and_check_mbed_os_is_true(
            self, mock_repo, fs):
        fs_root = pathlib.Path(fs, "foo")
        make_mbed_program_files(fs_root)

        with self.assertRaises(MbedOSNotFound):
            MbedProgram.from_existing(fs_root, check_mbed_os=True)
示例#4
0
    def test_from_existing_finds_existing_program_data(self, fs):
        root = pathlib.Path(fs, "foo")
        make_mbed_program_files(root)

        program = MbedProgramFiles.from_existing(root)

        self.assertTrue(program.app_config_file.exists())
示例#5
0
    def test_from_existing_returns_valid_program(self, mock_repo, fs):
        fs_root = pathlib.Path(fs, "foo")
        make_mbed_program_files(fs_root)
        make_mbed_os_files(fs_root / "mbed-os")

        program = MbedProgram.from_existing(fs_root)

        self.assertTrue(program.files.app_config_file.exists())
        self.assertTrue(program.mbed_os.root.exists())
        self.assertIsNotNone(program.repo)
示例#6
0
    def test_from_url_raises_if_check_mbed_os_is_true_and_mbed_os_dir_nonexistent(
            self, mock_clone, fs):
        fs_root = pathlib.Path(fs, "foo")
        url = "https://validrepo.com"
        mock_clone.side_effect = lambda *args: make_mbed_program_files(fs_root)

        with self.assertRaises(MbedOSNotFound):
            MbedProgram.from_url(url, fs_root, check_mbed_os=True)
示例#7
0
    def test_from_url_returns_valid_program(self, mock_clone, fs):
        fs_root = pathlib.Path(fs, "foo")
        url = "https://valid"
        mock_clone.side_effect = lambda *args: make_mbed_program_files(fs_root)
        program = MbedProgram.from_url(url, fs_root, False)

        self.assertEqual(program.files,
                         MbedProgramFiles.from_existing(fs_root))
        mock_clone.assert_called_once_with(url, fs_root)
示例#8
0
    def test_finds_program_at_current_path(self, fs):
        program_root = pathlib.Path(fs, "foo")
        make_mbed_program_files(program_root)

        self.assertEqual(_find_program_root(program_root),
                         program_root.resolve())
示例#9
0
    def test_from_existing_raises_if_no_repo_found(self, fs):
        fs_root = pathlib.Path(fs, "foo")
        make_mbed_program_files(fs_root)

        with self.assertRaises(VersionControlError):
            MbedProgram.from_existing(fs_root)
示例#10
0
    def test_from_new_raises_if_program_already_exists(self, fs):
        root = pathlib.Path(fs, "foo")
        make_mbed_program_files(root)

        with self.assertRaises(ValueError):
            MbedProgramFiles.from_new(root)