示例#1
0
 def test_managed_path(self):
     self.assertEqual(
         Repo('github.com/app/a').managed_path,
         '/etc/dusty/repos/github.com/app/a')
     self.assertEqual(
         Repo('/gc/repos/dusty').managed_path,
         '/etc/dusty/repos/gc/repos/dusty')
示例#2
0
    def test_get_same_container_repos_app(self, fake_get_specs):
        fake_get_specs.return_value = self.make_test_specs(apply_required_keys(
                                      {'apps': {'app1': {
                                                    'commands': {
                                                        'always': ['sleep 10']
                                                    },
                                                    'depends': {'apps': ['app2', 'app3'],
                                                                 'libs': ['lib1']},
                                                    'repo': '/gc/app1'},
                                                'app2': {
                                                    'commands': {
                                                        'always': ['sleep 10']
                                                    },
                                                    'depends': {'apps': ['app4'],
                                                    'libs': []},
                                                    'repo': '/gc/app2'
                                                },
                                                'app3': {
                                                    'commands': {
                                                        'always': ['sleep 10']
                                                    },
                                                    'depends': {'apps': [], 'libs': []}, 'repo': '/gc/app3'
                                                },
                                                'app4': {
                                                    'commands': {
                                                        'always': ['sleep 10']
                                                    },
                                                    'depends': {'apps': [], 'libs': []}, 'repo': '/gc/app4'}
                                                },
                                       'libs': {'lib1': {'depends': {'libs': ['lib2']}, 'repo': '/gc/lib1'},
                                                'lib2': {'depends': {'libs': []}, 'repo': '/gc/lib2'}}}))

        self.assertEquals(set(spec_assembler.get_same_container_repos('app1')),
                          set([Repo('/gc/app1'), Repo('/gc/lib1'), Repo('/gc/lib2')]))
示例#3
0
 def test_rel_path_ssh(self):
     self.assertEqual(
         Repo('ssh://[email protected]/app/a.git').rel_path,
         'github.com/app/a')
     self.assertEqual(
         Repo('ssh://[email protected]:2222/app/a').rel_path,
         'github.com/app/a')
     self.assertEqual(
         Repo('ssh://[email protected]:2222/app/a.js').rel_path,
         'github.com/app/a.js')
     self.assertEqual(
         Repo('ssh://[email protected]:2222/app/a.js.git').rel_path,
         'github.com/app/a.js')
示例#4
0
 def test_restart_sync(self):
     new_file_name = 'sync_file'
     repo = Repo.resolve(get_all_repos(include_specs_repo=False), 'repo-app-a')
     with open(os.path.join(repo.local_path, new_file_name), 'w+') as f:
         f.write('new file!')
     self.run_command('restart appa')
     self.assertFileInContainer('appa', os.path.join('/app/a/', new_file_name))
示例#5
0
文件: nfs_test.py 项目: thieman/dusty
 def test_managed_repo_mount(self):
     local_dir = Repo('github.com/app/a').managed_path
     if not os.path.exists(local_dir):
         os.makedirs(local_dir)
     self.run_command('bundles activate bundle-a')
     self.run_command('up --no-pull')
     self.run_command('scripts appa example')
     self.assertLocalFileExists(os.path.join(local_dir, 'foo'))
示例#6
0
 def test_restart_sync(self):
     new_file_name = 'sync_file'
     repo = Repo.resolve(get_all_repos(include_specs_repo=False),
                         'repo-app-a')
     with open(os.path.join(repo.local_path, new_file_name), 'w+') as f:
         f.write('new file!')
     self.run_command('restart appa')
     self.assertFileInContainer('appa',
                                os.path.join('/app/a/', new_file_name))
示例#7
0
 def test_update_local_repo(self, fake_local_repo, fake_local_up_to_date,
                            fake_repo):
     repo_mock = Mock()
     fake_local_up_to_date = Mock()
     pull_mock = Mock()
     repo_mock.remote.return_value = pull_mock
     fake_local_up_to_date.return_value = True
     fake_repo.return_value = repo_mock
     Repo('github.com/app/a').update_local_repo()
     pull_mock.pull.assert_called_once_with('master')
示例#8
0
def _write(spec_type, name, spec_doc):
    spec_type_path = os.path.join(get_specs_path(), '{}s'.format(spec_type))

    try:
        os.makedirs(spec_type_path)
    except OSError:
        pass

    spec_path = os.path.join(spec_type_path, '{}.yml'.format(name))
    if os.path.exists(spec_path):
        os.remove(spec_path)
    with open(spec_path, 'w') as f:
        f.write(yaml.safe_dump(spec_doc, default_flow_style=False))

    if 'repo' in spec_doc:
        repo = Repo(spec_doc['repo'])
        if repo.is_local_repo:
            set_up_fake_local_repo('/{}'.format(repo.rel_path))
示例#9
0
 def test_restart_apps_or_services_without_arguments_1(self, fake_get_assembled_specs, fake_get_specs, fake_nfs, fake_restart):
     fake_get_assembled_specs.return_value = self.specs
     fake_get_specs.return_value = self.specs
     restart_apps_or_services()
     fake_nfs.update_nfs_with_repos.assert_has_calls([call(set([Repo('github.com/app/a'), Repo('github.com/app/b'),
                                                       Repo('github.com/lib/a'), Repo('github.com/lib/b')]))])
示例#10
0
 def test_resolve_not_found(self):
     with self.assertRaises(RuntimeError):
         Repo.resolve(get_all_repos(), 'definitely-not-a-repo')
示例#11
0
 def test_resolve_short_name(self):
     self.assertEqual(Repo.resolve(get_all_repos(), 'b'), Repo('github.com/app/b'))
示例#12
0
    def test_assemble_remote_path_2(self):
        repo_url = '/path/to/repo'
        repo = Repo(repo_url)
        expected_url = 'file:///path/to/repo'

        self.assertEqual(repo.assemble_remote_path(), expected_url)
示例#13
0
 def test_rel_path_file(self):
     self.assertEqual(
         Repo('file:///github.com/app/a.git').rel_path, 'github.com/app/a')
     self.assertEqual(
         Repo('file:///github.com/app/a.js.git').rel_path,
         'github.com/app/a.js')
示例#14
0
 def test_rel_path(self):
     self.assertEqual(Repo('github.com/app/a').rel_path, 'github.com/app/a')
     self.assertEqual(
         Repo('github.com/app/a.js').rel_path, 'github.com/app/a.js')
     self.assertEqual(Repo('/gc/repos/dusty').rel_path, 'gc/repos/dusty')
示例#15
0
 def test_managed_path_file(self):
     self.assertEqual(
         Repo('file:///github.com/app/a').managed_path,
         '/etc/dusty/repos/github.com/app/a')
示例#16
0
    def test_assemble_remote_path_9(self):
        repo_url = 'path/to/repo'
        repo = Repo(repo_url)
        expected_url = 'ssh://git@path/to/repo'

        self.assertEqual(repo.assemble_remote_path(), expected_url)
示例#17
0
 def test_equality_false(self):
     self.assertNotEqual(Repo('github.com/app/a'), Repo('github.com/app/b'))
示例#18
0
    def test_assemble_remote_path_7(self):
        repo_url = 'ssh://user@path/to/repo:80/more_stuff'
        repo = Repo(repo_url)
        expected_url = 'ssh://user@path/to/repo:80/more_stuff'

        self.assertEqual(repo.assemble_remote_path(), expected_url)
示例#19
0
    def test_assemble_remote_path_4(self):
        repo_url = 'http://path/to/repo'
        repo = Repo(repo_url)
        expected_url = 'http://path/to/repo.git'

        self.assertEqual(repo.assemble_remote_path(), expected_url)
示例#20
0
 def test_equality_true(self):
     self.assertEqual(Repo('github.com/app/a'), Repo('github.com/app/a'))
示例#21
0
    def test_assemble_remote_path_2(self):
        repo_url = '/path/to/repo'
        repo = Repo(repo_url)
        expected_url = 'file:///path/to/repo'

        self.assertEqual(repo.assemble_remote_path(), expected_url)
示例#22
0
 def test_repo_is_overridden_false(self):
     self.assertFalse(Repo('github.com/app/a').is_overridden)
示例#23
0
    def test_assemble_remote_path_7(self):
        repo_url = 'ssh://user@path/to/repo:80/more_stuff'
        repo = Repo(repo_url)
        expected_url = 'ssh://user@path/to/repo:80/more_stuff'

        self.assertEqual(repo.assemble_remote_path(), expected_url)
示例#24
0
    def test_assemble_remote_path_10(self):
        repo_url = 'alex@path/to/repo:more_stuff'
        repo = Repo(repo_url)
        expected_url = 'alex@path/to/repo:more_stuff'

        self.assertEqual(repo.assemble_remote_path(), expected_url)
示例#25
0
 def test_managed_path_ssh(self):
     self.assertEqual(
         Repo('ssh://[email protected]/app/a').managed_path,
         '/etc/dusty/repos/github.com/app/a')
示例#26
0
 def test_resolve_full_name(self):
     self.assertEqual(Repo.resolve(get_all_repos(), 'github.com/app/a'),
                      Repo('github.com/app/a'))
示例#27
0
 def test_rel_path_http(self):
     self.assertEqual(
         Repo('http://github.com/app/a').rel_path, 'github.com/app/a')
示例#28
0
 def test_resolve_short_name(self):
     self.assertEqual(Repo.resolve(get_all_repos(), 'b'),
                      Repo('github.com/app/b'))
示例#29
0
    def test_assemble_remote_path_4(self):
        repo_url = 'http://path/to/repo'
        repo = Repo(repo_url)
        expected_url = 'http://path/to/repo.git'

        self.assertEqual(repo.assemble_remote_path(), expected_url)
示例#30
0
 def test_resolve_short_name_conflict(self):
     with self.assertRaises(RuntimeError):
         Repo.resolve(get_all_repos(), 'a')
示例#31
0
 def test_resolve_full_name(self):
     self.assertEqual(Repo.resolve(get_all_repos(), 'github.com/app/a'), Repo('github.com/app/a'))
示例#32
0
 def test_local_repo_path_no_override(self):
     self.assertEqual(
         Repo('github.com/app/a').local_path,
         '/etc/dusty/repos/github.com/app/a')
示例#33
0
 def test_resolve_short_name_conflict(self):
     with self.assertRaises(RuntimeError):
         Repo.resolve(get_all_repos(), 'a')
示例#34
0
    def test_assemble_remote_path_9(self):
        repo_url = 'path/to/repo'
        repo = Repo(repo_url)
        expected_url = 'ssh://git@path/to/repo'

        self.assertEqual(repo.assemble_remote_path(), expected_url)
示例#35
0
 def test_short_name_remote(self):
     self.assertEqual(Repo('github.com/app/a').short_name, 'a')
示例#36
0
 def test_short_name_local(self):
     self.assertEqual(Repo('/gc/repos/dusty').short_name, 'dusty')
示例#37
0
 def test_resolve_not_found(self):
     with self.assertRaises(RuntimeError):
         Repo.resolve(get_all_repos(), 'definitely-not-a-repo')
示例#38
0
    def test_assemble_remote_path_10(self):
        repo_url = 'alex@path/to/repo:more_stuff'
        repo = Repo(repo_url)
        expected_url = 'alex@path/to/repo:more_stuff'

        self.assertEqual(repo.assemble_remote_path(), expected_url)
示例#39
0
 def test_local_repo_path_with_override(self):
     override_repo('github.com/app/a', self.temp_dir)
     self.assertEqual(Repo('github.com/app/a').local_path, self.temp_dir)
示例#40
0
 def test_is_local_repo(self):
     self.assertFalse(Repo('github.com/app/a').is_local_repo)
     self.assertTrue(Repo('/gc/repos/dusty').is_local_repo)