Skip to content

Commit

Permalink
Improve version info and bump version patch level
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Jul 17, 2019
1 parent c65fc02 commit 400c86f
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 71 deletions.
6 changes: 3 additions & 3 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[bumpversion]
current_version = 1.1.0
current_version = 1.1.1
commit = False
tag = False

[bumpversion:file:src/graphql/version.py]
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"
search = version = "{current_version}"
replace = version = "{new_version}"

[bumpversion:file:docs/conf.py]
search = version = release = u'{current_version}'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ a query language for APIs created by Facebook.
[![Python 3 Status](https://pyup.io/repos/github/graphql-python/graphql-core-next/python-3-shield.svg)](https://pyup.io/repos/github/graphql-python/graphql-core-next/)
[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

The current version 1.1.0 of GraphQL-core-next is up-to-date with GraphQL.js version
14.4.0. All parts of the API are covered by an extensive test suite of currently 1882
The current version 1.1.1 of GraphQL-core-next is up-to-date with GraphQL.js version
14.4.0. All parts of the API are covered by an extensive test suite of currently 1885
unit tests.

Development will be continued with the new distribution name GraphQL-core from now on.
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
# The short X.Y version.
# version = u'1.1'
# The full version, including alpha/beta/rc tags.
version = release = u'1.1.0'
version = release = u'1.1.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "graphql-core-next"
version = "1.1.0"
version = "1.1.1"
description = """
GraphQL-core-next is a Python port of GraphQL.js,
the JavaScript reference implementation for GraphQL."""
Expand Down
47 changes: 35 additions & 12 deletions src/graphql/version.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,49 @@
import re
from typing import NamedTuple
from warnings import warn

__all__ = ["version", "version_info", "version_js", "version_info_js"]


version = "1.1.1"

version_js = "14.4.0"


warn(
"GraphQL-core-next has been discontinued."
" It is now released as GraphQL-core v3 and newer.",
DeprecationWarning,
)


_re_version = re.compile(r"(\d+)\.(\d+)\.(\d+)(\D*)(\d*)")


class VersionInfo(NamedTuple):
major: int
minor: int
micro: int
releaselevel: str
serial: int

@classmethod
def from_str(cls, v: str) -> "VersionInfo":
groups = _re_version.match(v).groups() # type: ignore
major, minor, micro = map(int, groups[:3])
level = (groups[3] or "")[:1]
if level == "a":
level = "alpha"
elif level == "b":
level = "beta"
elif level in ("c", "r"):
level = "candidate"
else:
level = "final"
serial = groups[4]
serial = int(serial) if serial else 0
return cls(major, minor, micro, level, serial)

def __str__(self):
v = f"{self.major}.{self.minor}.{self.micro}"
level = self.releaselevel
Expand All @@ -19,16 +52,6 @@ def __str__(self):
return v


version = "1.1.0"

version_info = VersionInfo(1, 1, 0, "final", 0)

version_js = "14.4.0"

version_info_js = VersionInfo(14, 4, 0, "final", 0)
version_info = VersionInfo.from_str(version)

warn(
"GraphQL-core-next has been discontinued."
" It is now released as GraphQL-core v3 and newer.",
DeprecationWarning,
)
version_info_js = VersionInfo.from_str(version_js)
149 changes: 99 additions & 50 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -1,58 +1,107 @@
import re

import graphql
from graphql import version, version_info, version_js, version_info_js
from graphql.version import (
VersionInfo,
version,
version_info,
version_js,
version_info_js,
)

_re_version = re.compile(r"(\d+)\.(\d+)\.(\d+)(?:(a|b|c)(\d+))?$")


def describe_version():
def test_module_version():
assert graphql.__version__ == version
assert graphql.version == version

def test_module_version_info():
assert graphql.__version_info__ == version_info
assert graphql.version_info == version_info

def test_module_version_js():
assert graphql.__version_js__ == version_js
assert graphql.version_js == version_js

def test_module_version_info_js():
assert graphql.__version_info_js__ == version_info_js
assert graphql.version_info_js == version_info_js

def test_version():
assert isinstance(version, str)
assert _re_version.match(version)

def test_version_info():
assert isinstance(version_info, tuple)
assert str(version_info) == version
groups = _re_version.match(version).groups()
assert version_info.major == int(groups[0])
assert version_info.minor == int(groups[1])
assert version_info.micro == int(groups[2])
if groups[3] is None:
assert groups[4] is None
else:
assert version_info.releaselevel[:1] == groups[3]
assert version_info.serial == int(groups[4])

def test_version_js():
assert isinstance(version_js, str)
assert _re_version.match(version_js)

def test_version_info_js():
assert isinstance(version_info_js, tuple)
assert str(version_info_js) == version_js
groups = _re_version.match(version_js).groups()
assert version_info_js.major == int(groups[0])
assert version_info_js.minor == int(groups[1])
assert version_info_js.micro == int(groups[2])
if groups[3] is None:
assert groups[4] is None
else:
assert version_info_js.releaselevel[:1] == groups[3]
assert version_info_js.serial == int(groups[4])
def describe_version_info_class():
def create_version_info_from_fields():
v = VersionInfo(1, 2, 3, "alpha", 4)
assert v.major == 1
assert v.minor == 2
assert v.micro == 3
assert v.releaselevel == "alpha"
assert v.serial == 4

def create_version_info_from_str():
v = VersionInfo.from_str("1.2.3")
assert v.major == 1
assert v.minor == 2
assert v.micro == 3
assert v.releaselevel == "final"
assert v.serial == 0
v = VersionInfo.from_str("1.2.3a4")
assert v.major == 1
assert v.minor == 2
assert v.micro == 3
assert v.releaselevel == "alpha"
assert v.serial == 4
v = VersionInfo.from_str("1.2.3beta4")
assert v.major == 1
assert v.minor == 2
assert v.micro == 3
assert v.releaselevel == "beta"
assert v.serial == 4
v = VersionInfo.from_str("12.34.56rc789")
assert v.major == 12
assert v.minor == 34
assert v.micro == 56
assert v.releaselevel == "candidate"
assert v.serial == 789

def serialize_as_str():
v = VersionInfo(1, 2, 3, "final", 0)
assert str(v) == "1.2.3"
v = VersionInfo(1, 2, 3, "alpha", 4)
assert str(v) == "1.2.3a4"

def describe_graphql_core_version():
def base_package_has_correct_version():
assert graphql.__version__ == version
assert graphql.version == version

def base_package_has_correct_version_info():
assert graphql.__version_info__ is version_info
assert graphql.version_info is version_info

def version_has_correct_format():
assert isinstance(version, str)
assert _re_version.match(version)

def version_info_has_correct_fields():
assert isinstance(version_info, tuple)
assert str(version_info) == version
groups = _re_version.match(version).groups()
assert version_info.major == int(groups[0])
assert version_info.minor == int(groups[1])
assert version_info.micro == int(groups[2])
if groups[3] is None:
assert groups[4] is None
else:
assert version_info.releaselevel[:1] == groups[3]
assert version_info.serial == int(groups[4])

def describe_graphql_js_version():
def base_package_has_correct_version_js():
assert graphql.__version_js__ == version_js
assert graphql.version_js == version_js

def base_package_has_correct_version_info_js():
assert graphql.__version_info_js__ is version_info_js
assert graphql.version_info_js is version_info_js

def version_js_has_correct_format():
assert isinstance(version_js, str)
assert _re_version.match(version_js)

def version_info_js_has_correct_fields():
assert isinstance(version_info_js, tuple)
assert str(version_info_js) == version_js
groups = _re_version.match(version_js).groups()
assert version_info_js.major == int(groups[0])
assert version_info_js.minor == int(groups[1])
assert version_info_js.micro == int(groups[2])
if groups[3] is None:
assert groups[4] is None
else:
assert version_info_js.releaselevel[:1] == groups[3]
assert version_info_js.serial == int(groups[4])

0 comments on commit 400c86f

Please sign in to comment.