Skip to content
This repository was archived by the owner on Aug 10, 2022. It is now read-only.

Commit 6fc067d

Browse files
committed
Add sequence_name to BatchInfo
1 parent 3f4a623 commit 6fc067d

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

eyes_common/applitools/common/config/configuration.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from applitools.common.geometry import RectangleSize
99
from applitools.common.match import ImageMatchSettings, MatchLevel
1010
from applitools.common.server import FailureReports, SessionType
11-
from applitools.common.utils import general_utils
11+
from applitools.common.utils import general_utils, argument_guard
1212
from applitools.common.utils.json_utils import JsonInclude
1313

1414
__all__ = ("BatchInfo", "Configuration")
@@ -28,6 +28,10 @@ class BatchInfo(object):
2828
factory=lambda: os.environ.get("APPLITOOLS_BATCH_NAME"),
2929
metadata={JsonInclude.THIS: True},
3030
) # type: Optional[Text]
31+
sequence_name = attr.ib(
32+
factory=lambda: os.environ.get("APPLITOOLS_BATCH_SEQUENCE"),
33+
metadata={JsonInclude.NAME: "batchSequenceName"},
34+
) # type: Optional[Text]
3135
started_at = attr.ib(
3236
factory=lambda: datetime.now(general_utils.UTC),
3337
metadata={JsonInclude.THIS: True},
@@ -46,6 +50,11 @@ def id_(self):
4650
def id_(self, value):
4751
self.id = value
4852

53+
def with_batch_id(self, id):
54+
argument_guard.not_none(id)
55+
self.id = id
56+
return self
57+
4958

5059
@attr.s
5160
class Configuration(object):

tests/unit/eyes_common/test_batch_info.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,33 @@ def test_create_batch_info(monkeypatch):
2020
) as mocked_datetime:
2121
mocked_datetime.now.return_value = now
2222
bi = BatchInfo(batch_name)
23+
bi.sequence_name = "sequence name"
2324

2425
assert bi.name == batch_name
2526
assert bi.id == uuid_value
2627
assert bi.started_at == now
28+
assert bi.sequence_name == "sequence name"
29+
30+
31+
def test_create_batch_with_batch_id():
32+
bi = BatchInfo("My name").with_batch_id("custom id")
33+
assert bi.id == "custom id"
2734

2835

2936
def test_set_env_params_in_batch_info():
3037
with patch.dict(
31-
os.environ, {"APPLITOOLS_BATCH_NAME": "name", "APPLITOOLS_BATCH_ID": "id"}
38+
os.environ,
39+
{
40+
"APPLITOOLS_BATCH_NAME": "name",
41+
"APPLITOOLS_BATCH_ID": "id",
42+
"APPLITOOLS_BATCH_SEQUENCE": "sequence name",
43+
},
3244
):
3345
bi = BatchInfo()
3446

3547
assert bi.name == "name"
3648
assert bi.id == "id"
49+
assert bi.sequence_name == "sequence name"
3750

3851

3952
def test_get_set_id_in_batch_info():

0 commit comments

Comments
 (0)