-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
188 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# todo add to osbot utils | ||
from osbot_utils.utils.Misc import random_guid | ||
|
||
class Random_Guid(str): | ||
def __new__(cls, value=None): | ||
if value is None: | ||
value = random_guid() | ||
return str.__new__(cls, value) | ||
|
||
def __init__(self, value=None): | ||
self.value = value if value is not None else random_guid() | ||
|
||
def __str__(self): | ||
return self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v1.34.3 | ||
v1.38.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "osbot_utils" | ||
version = "v1.34.3" | ||
version = "v1.38.2" | ||
description = "OWASP Security Bot - Utils" | ||
authors = ["Dinis Cruz <[email protected]>"] | ||
license = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from unittest import TestCase | ||
|
||
from osbot_utils.helpers.Random_Guid import Random_Guid | ||
from osbot_utils.utils.Json import json_to_str, json_round_trip | ||
from osbot_utils.utils.Misc import is_guid | ||
from osbot_utils.utils.Objects import base_types | ||
|
||
|
||
class test_Random_Guid(TestCase): | ||
|
||
def test__init__(self): | ||
random_guid = Random_Guid() | ||
assert len(random_guid) == 36 | ||
assert type(random_guid) is Random_Guid | ||
assert type(str(random_guid)) is not str # a bit weird why this is not a str | ||
assert base_types(random_guid) == [str, object] | ||
assert str(random_guid) == random_guid | ||
|
||
assert is_guid (random_guid) | ||
assert isinstance (random_guid, str) | ||
|
||
assert Random_Guid() != Random_Guid() | ||
assert str(Random_Guid()) != str(Random_Guid()) | ||
|
||
|
||
assert json_to_str(random_guid) == f'"{random_guid}"' | ||
assert json_round_trip(random_guid) == str(random_guid) | ||
assert type(json_round_trip(random_guid)) is str |
Oops, something went wrong.