def test_run_linter_path_doesnt_exist(self): with pytest.raises(ValueError) as exc: tasks.run_addons_linter('doesntexist') assert exc.value.message == ( 'Path "doesntexist" is not a file or directory or ' 'does not exist.')
def test_run_linter_path_doesnt_exist(self): with pytest.raises(ValueError) as exc: tasks.run_addons_linter('doesntexist') assert exc.value.message == ( 'Path "doesntexist" is not a file or directory or ' 'does not exist.\n')
def test_run_linter_path_doesnt_exist(self): with pytest.raises(ValueError) as exc: tasks.run_addons_linter('doesntexist', amo.RELEASE_CHANNEL_LISTED) assert str( exc.value) == ('Path "doesntexist" is not a file or directory or ' 'does not exist.')
def test_xpi_autoclose_is_enabled(self, subprocess_mock): subprocess_mock.Popen = self.FakePopen tasks.run_addons_linter(path=self.valid_path, channel=amo.RELEASE_CHANNEL_LISTED) assert '--disable-xpi-autoclose' not in self.FakePopen.get_args()
def test_mv3_submissions_waffle_disabled(self): with mock.patch('olympia.devhub.tasks.subprocess') as subprocess_mock: subprocess_mock.Popen = self.FakePopen tasks.run_addons_linter(path=self.valid_path, channel=amo.RELEASE_CHANNEL_LISTED) assert '--max-manifest-version=3' not in self.FakePopen.get_args() assert '--max-manifest-version=2' in self.FakePopen.get_args() mv3_path = get_addon_file('webextension_mv3.xpi') result = tasks.run_addons_linter(mv3_path, channel=amo.RELEASE_CHANNEL_LISTED) assert json.loads(result or '{}').get('errors') == 1
def test_mv3_submission_enabled(self): with mock.patch('olympia.devhub.tasks.subprocess') as subprocess_mock: subprocess_mock.Popen = self.FakePopen tasks.run_addons_linter(path=self.valid_path, channel=amo.RELEASE_CHANNEL_LISTED) assert '--max-manifest-version=3' in self.FakePopen.get_args() assert '--max-manifest-version=2' not in self.FakePopen.get_args() mv3_path = get_addon_file('webextension_mv3.xpi') result = tasks.run_addons_linter(mv3_path, channel=amo.RELEASE_CHANNEL_LISTED) assert result.get('errors') == 0 # double check v2 manifests still work result = tasks.run_addons_linter(self.valid_path, channel=amo.RELEASE_CHANNEL_LISTED) assert result.get('errors') == 0
def test_run_linter_use_temporary_file(self): TemporaryFile = tempfile.TemporaryFile with mock.patch('olympia.devhub.tasks.tempfile.TemporaryFile') as tmpf: tmpf.side_effect = lambda *a, **kw: TemporaryFile(*a, **kw) # This is a relatively small add-on (1.2M) but we are using # a temporary file for all our linter output. result = json.loads( tasks.run_addons_linter(get_addon_file('typo-gecko.xpi'))) assert tmpf.call_count == 2 assert result['success'] assert result['warnings'] == 22 assert not result['errors']
def test_run_linter_use_temporary_file(self): TemporaryFile = tempfile.TemporaryFile with mock.patch('olympia.devhub.tasks.tempfile.TemporaryFile') as tmpf: tmpf.side_effect = lambda *a, **kw: TemporaryFile(*a, **kw) # This is a relatively small add-on (1.2M) but we are using # a temporary file for all our linter output. result = json.loads(tasks.run_addons_linter( get_addon_file('typo-gecko.xpi') )) assert tmpf.call_count == 2 assert result['success'] assert result['warnings'] == 11 assert not result['errors']
def test_run_linter_use_temporary_file(self): TemporaryFile = tempfile.TemporaryFile with mock.patch('olympia.devhub.tasks.tempfile.TemporaryFile') as tmpf: tmpf.side_effect = lambda *a, **kw: TemporaryFile(*a, **kw) # This is a relatively small add-on but we are making sure that # we're using a temporary file for all our linter output. result = json.loads( tasks.run_addons_linter( get_addon_file('webextension_containing_binary_files.xpi'), amo.RELEASE_CHANNEL_LISTED)) assert tmpf.call_count == 2 assert result['success'] assert not result['warnings'] assert not result['errors']