Skip to content

Commit

Permalink
Merge pull request #49 from ripe-tech/hg/cleanup
Browse files Browse the repository at this point in the history
style: cleanup
  • Loading branch information
hugo-gomes authored Feb 2, 2023
2 parents 4c9b4cc + ea44694 commit 0e0bed9
Show file tree
Hide file tree
Showing 3 changed files with 218 additions and 218 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

* Added `create_issue_order` - [ripe-core/#4700](https://github.com/ripe-tech/ripe-core/issues/4700)
* Added `create_issue_order` - [ripe-core/#4700](https://github.com/ripe-tech/ripe-core/issues/4700)

### Changed

Expand Down
180 changes: 90 additions & 90 deletions src/ripe/test/util.py
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

import unittest

import ripe


class UtilAPITest(unittest.TestCase):
def test__query_to_spec(self):
result = ripe.API._query_to_spec(
"brand=dummy&model=dummy&locale=en_us&format=webp&initials=AAA&engraving=grey&initials_extra=main:AAA:grey&p=side:leather_dmy:black&p=piping:leather_dmy:black&p=top0_bottom:leather_dmy:black&p=shadow:default:default"
)
self.assertEqual(
result,
dict(
brand="dummy",
model="dummy",
parts=dict(
side=dict(material="leather_dmy", color="black"),
piping=dict(material="leather_dmy", color="black"),
top0_bottom=dict(material="leather_dmy", color="black"),
shadow=dict(material="default", color="default"),
),
initials="AAA",
engraving="grey",
initials_extra=dict(main=dict(engraving="grey", initials="AAA")),
),
)

def test__unpack_query(self):
result = ripe.API._unpack_query(
"brand=dummy&model=dummy&p=sole:rubber:red&p=laces:metal:black"
)
self.assertEqual(
result,
dict(
brand="dummy", model="dummy", p=["sole:rubber:red", "laces:metal:black"]
),
)

result = ripe.API._unpack_query(
"?brand=dummy&model=dummy&p=sole:rubber:red&p=laces:metal:black"
)
self.assertEqual(
result,
dict(
brand="dummy", model="dummy", p=["sole:rubber:red", "laces:metal:black"]
),
)

def test__parse_extra_s(self):
result = ripe.API._parse_extra_s(["name1:aaa:black", "name2:bbb:white"])
self.assertEqual(
result,
dict(
name1=dict(initials="aaa", engraving="black"),
name2=dict(initials="bbb", engraving="white"),
),
)

def test__tuples_to_parts(self):
result = ripe.API._tuples_to_parts(
["sole:rubber:red", "laces:metal:black", "side:rubber:white"]
)
self.assertEqual(
result,
[
dict(name="sole", material="rubber", color="red"),
dict(name="laces", material="metal", color="black"),
dict(name="side", material="rubber", color="white"),
],
)

def test__parts_to_parts_m(self):
result = ripe.API._parts_to_parts_m(
[
dict(name="sole", material="rubber", color="red"),
dict(name="laces", material="metal", color="black"),
dict(name="side", material="rubber", color="white"),
]
)
self.assertEqual(
result,
dict(
sole=dict(material="rubber", color="red"),
laces=dict(material="metal", color="black"),
side=dict(material="rubber", color="white"),
),
)
#!/usr/bin/python
# -*- coding: utf-8 -*-

import unittest

import ripe


class UtilAPITest(unittest.TestCase):
def test__query_to_spec(self):
result = ripe.API._query_to_spec(
"brand=dummy&model=dummy&locale=en_us&format=webp&initials=AAA&engraving=grey&initials_extra=main:AAA:grey&p=side:leather_dmy:black&p=piping:leather_dmy:black&p=top0_bottom:leather_dmy:black&p=shadow:default:default"
)
self.assertEqual(
result,
dict(
brand="dummy",
model="dummy",
parts=dict(
side=dict(material="leather_dmy", color="black"),
piping=dict(material="leather_dmy", color="black"),
top0_bottom=dict(material="leather_dmy", color="black"),
shadow=dict(material="default", color="default"),
),
initials="AAA",
engraving="grey",
initials_extra=dict(main=dict(engraving="grey", initials="AAA")),
),
)

def test__unpack_query(self):
result = ripe.API._unpack_query(
"brand=dummy&model=dummy&p=sole:rubber:red&p=laces:metal:black"
)
self.assertEqual(
result,
dict(
brand="dummy", model="dummy", p=["sole:rubber:red", "laces:metal:black"]
),
)

result = ripe.API._unpack_query(
"?brand=dummy&model=dummy&p=sole:rubber:red&p=laces:metal:black"
)
self.assertEqual(
result,
dict(
brand="dummy", model="dummy", p=["sole:rubber:red", "laces:metal:black"]
),
)

def test__parse_extra_s(self):
result = ripe.API._parse_extra_s(["name1:aaa:black", "name2:bbb:white"])
self.assertEqual(
result,
dict(
name1=dict(initials="aaa", engraving="black"),
name2=dict(initials="bbb", engraving="white"),
),
)

def test__tuples_to_parts(self):
result = ripe.API._tuples_to_parts(
["sole:rubber:red", "laces:metal:black", "side:rubber:white"]
)
self.assertEqual(
result,
[
dict(name="sole", material="rubber", color="red"),
dict(name="laces", material="metal", color="black"),
dict(name="side", material="rubber", color="white"),
],
)

def test__parts_to_parts_m(self):
result = ripe.API._parts_to_parts_m(
[
dict(name="sole", material="rubber", color="red"),
dict(name="laces", material="metal", color="black"),
dict(name="side", material="rubber", color="white"),
]
)
self.assertEqual(
result,
dict(
sole=dict(material="rubber", color="red"),
laces=dict(material="metal", color="black"),
side=dict(material="rubber", color="white"),
),
)
Loading

0 comments on commit 0e0bed9

Please sign in to comment.