def test_addon1(): """ addon1 has 4 commit after version 8.0.1.0.0 """ addon1_dir = os.path.join(DATA_DIR, "addon1") version = get_git_postversion(addon1_dir, STRATEGY_99_DEVN) assert version == "8.0.1.0.0.99.dev4" version = get_git_postversion(addon1_dir, STRATEGY_P1_DEVN) assert version == "8.0.1.0.1.dev4"
def test_addon2(): """ addon2 has not changed since 8.0.1.0.1 """ addon2_dir = os.path.join(DATA_DIR, "addon2") version = get_git_postversion(addon2_dir, STRATEGY_99_DEVN) assert version == "8.0.1.0.1" version = get_git_postversion(addon2_dir, STRATEGY_P1_DEVN) assert version == "8.0.1.0.1"
def test_no_git(tmpdir): """ get version outisde of git repo, get it from manifest """ tmpdir.join("__openerp__.py").write( textwrap.dedent("""\ { 'version': '10.0.1.2.3', } """)) version = get_git_postversion(str(tmpdir), STRATEGY_99_DEVN) assert version == "10.0.1.2.3" version = get_git_postversion(str(tmpdir), STRATEGY_P1_DEVN) assert version == "10.0.1.2.3"
def test_addon1_uncommitted_change(): """ test with a local uncommitted change without version change """ addon1_dir = os.path.join(DATA_DIR, "addon1") manifest_path = os.path.join(addon1_dir, "__openerp__.py") with open(manifest_path) as f: manifest = f.read() try: with open(manifest_path, "w") as f: f.write(manifest.replace("summary", "great summary")) version = get_git_postversion(addon1_dir, STRATEGY_99_DEVN) assert version == "8.0.1.0.0.99.dev5" version = get_git_postversion(addon1_dir, STRATEGY_P1_DEVN) assert version == "8.0.1.0.1.dev5" finally: with open(manifest_path, "w") as f: f.write(manifest)
def test_addon2_uncommitted_version_change(): """ test with a local uncommitted version change """ addon2_dir = os.path.join(DATA_DIR, "addon2") manifest_path = os.path.join(addon2_dir, "__openerp__.py") with open(manifest_path) as f: manifest = f.read() try: with open(manifest_path, "w") as f: f.write(manifest.replace("8.0.1.0.1", "8.0.1.0.2")) version = get_git_postversion(addon2_dir, STRATEGY_99_DEVN) assert version == "8.0.1.0.2.dev1" version = get_git_postversion(addon2_dir, STRATEGY_P1_DEVN) assert version == "8.0.1.0.2.dev1" finally: with open(manifest_path, "w") as f: f.write(manifest)
def test_no_git(tmpdir): """ get version outisde of git repo, get it from manifest """ tmpdir.join('__openerp__.py').write( textwrap.dedent("""\ { 'version': '10.0.1.2.3', } """)) version = git_postversion.get_git_postversion(str(tmpdir)) assert version == '10.0.1.2.3'
def test_addon1_uncommitted_change(self): """ test with a local uncommitted change without version change """ addon1_dir = os.path.join(DATA_DIR, "addon1") manifest_path = os.path.join(addon1_dir, "__openerp__.py") manifest = open(manifest_path).read() try: open(manifest_path, "w").write(manifest.replace("summary", "great summary")) version = git_postversion.get_git_postversion(addon1_dir) assert version == "8.0.1.0.0.99.dev3" finally: open(manifest_path, "w").write(manifest)
def test_addon2_uncommitted_version_change(self): """ test with a local uncommitted version change """ addon2_dir = os.path.join(DATA_DIR, "addon2") manifest_path = os.path.join(addon2_dir, "__openerp__.py") manifest = open(manifest_path).read() try: open(manifest_path, "w").write(manifest.replace("8.0.1.0.1", "8.0.1.0.2")) version = git_postversion.get_git_postversion(addon2_dir) assert version == "8.0.1.0.2.dev1" finally: open(manifest_path, "w").write(manifest)
def test_addon1_uncommitted_change(self): """ test with a local uncommitted change without version change """ addon1_dir = os.path.join(DATA_DIR, 'addon1') manifest_path = os.path.join(addon1_dir, '__openerp__.py') manifest = open(manifest_path).read() try: open(manifest_path, "w").write(manifest.replace("summary", "great summary")) version = git_postversion.get_git_postversion(addon1_dir) assert version == '8.0.1.0.0.99.dev3' finally: open(manifest_path, "w").write(manifest)
def test_addon2_uncommitted_version_change(self): """ test with a local uncommitted version change """ addon2_dir = os.path.join(DATA_DIR, 'addon2') manifest_path = os.path.join(addon2_dir, '__openerp__.py') manifest = open(manifest_path).read() try: open(manifest_path, "w").write(manifest.replace("8.0.1.0.1", "8.0.1.0.2")) version = git_postversion.get_git_postversion(addon2_dir) assert version == '8.0.1.0.2.dev1' finally: open(manifest_path, "w").write(manifest)
def check_module_version(directory, raise_if_dev_version=True): version = get_git_postversion(directory, STRATEGY_99_DEVN) if DEV_REGEX.search(version): module_name = os.path.basename(directory) error_message = "The version of the \"{}\" module is \"{}\".".format(module_name, version) if raise_if_dev_version: raise ValueError(error_message) else: print(error_message)
def test_no_manifest(self): with self.assertRaises(manifest.NoManifestFound): git_postversion.get_git_postversion(DATA_DIR)
def test_addon2(self): """ addon2 has not changed since 8.0.1.0.1 """ addon2_dir = os.path.join(DATA_DIR, "addon2") version = git_postversion.get_git_postversion(addon2_dir) assert version == "8.0.1.0.1"
def test_no_manifest(): with pytest.raises(manifest.NoManifestFound): git_postversion.get_git_postversion(DATA_DIR)
def test_addon1(): """ addon1 has 2 commit after version 8.0.1.0.0 """ addon1_dir = os.path.join(DATA_DIR, 'addon1') version = git_postversion.get_git_postversion(addon1_dir) assert version == '8.0.1.0.0.99.dev3'
def test_addon2(): """ addon2 has not changed since 8.0.1.0.1 """ addon2_dir = os.path.join(DATA_DIR, 'addon2') version = git_postversion.get_git_postversion(addon2_dir) assert version == '8.0.1.0.1'
def test_no_manifest(): with pytest.raises(manifest.NoManifestFound): get_git_postversion(DATA_DIR, STRATEGY_99_DEVN) get_git_postversion(DATA_DIR, STRATEGY_DOT_N) get_git_postversion(DATA_DIR, STRATEGY_P1_DEVN) get_git_postversion(DATA_DIR, STRATEGY_NONE)
def test_addon1(self): """ addon1 has 2 commit after version 8.0.1.0.0 """ addon1_dir = os.path.join(DATA_DIR, "addon1") version = git_postversion.get_git_postversion(addon1_dir) assert version == "8.0.1.0.0.99.dev2"