Skip to content

Commit

Permalink
move test_entry.py's content into test_entries.py
Browse files Browse the repository at this point in the history
  • Loading branch information
whtsky committed Dec 10, 2017
1 parent e2b032f commit 49ab16c
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 70 deletions.
70 changes: 69 additions & 1 deletion tests/messages/test_entries.py
@@ -1,4 +1,72 @@
from werobot.messages.entries import get_value
# -*- coding: utf-8 -*-

import six
from werobot.messages.entries import get_value, StringEntry, FloatEntry, IntEntry
from werobot.utils import to_text


class NoNameMessage(object):
test_int = IntEntry("TestInt")
test_string_to_int = IntEntry("TestStringToInt")
test_float_to_int = IntEntry("TestFloatToInt")
test_int_none = IntEntry("MIAOMIAOMIAO")

test_float = FloatEntry("TestFloat")
test_string_to_float = FloatEntry("TestStringToFloat")
test_float_none = FloatEntry("WANGWANG")

test_string = StringEntry("TestString")
test_int_to_string = StringEntry("TestIntToString")
test_float_to_string = StringEntry("TestFloatToString")
test_chinese = StringEntry("TestChinese")
test_string_none = StringEntry("HAHAHA")

def __init__(self):
message = {
"TestInt": 123,
"TestFloat": 0.00001,
"TestString": "hello",
"TestStringToInt": "123",
"TestFloatToInt": 123.000,
"TestStringToFloat": "0.00001",
"TestIntToString": 123,
"TestFloatToString": 0.00001,
"TestChinese": "喵",
}
self.__dict__.update(message)


t = NoNameMessage()


def test_int_entry():
assert isinstance(t.test_int, int)
assert t.test_int == 123
assert isinstance(t.test_string_to_int, int)
assert t.test_string_to_int == 123
assert isinstance(t.test_float_to_int, int)
assert t.test_float_to_int == 123
assert t.test_int_none is None


def test_float_entry():
assert isinstance(t.test_float, float)
assert t.test_float == 0.00001
assert isinstance(t.test_string_to_float, float)
assert t.test_string_to_float == 0.00001
assert t.test_float_none is None


def test_string_entry():
assert isinstance(t.test_string, six.text_type)
assert t.test_string == "hello"
assert isinstance(t.test_int_to_string, six.text_type)
assert t.test_int_to_string == "123"
assert isinstance(t.test_float_to_string, six.text_type)
assert t.test_float_to_string == "1e-05"
assert isinstance(t.test_chinese, six.text_type)
assert t.test_chinese == to_text("喵")
assert t.test_string_none is None


class FakeIntance:
Expand Down
69 changes: 0 additions & 69 deletions tests/test_entry.py

This file was deleted.

0 comments on commit 49ab16c

Please sign in to comment.